diff --git a/0001-split-start-window.patch b/0001-split-start-window.patch deleted file mode 100644 index ceca8499..00000000 --- a/0001-split-start-window.patch +++ /dev/null @@ -1,1002 +0,0 @@ -From a61cddfc9b4601dcbd0486e43fc3c33653c01c88 Mon Sep 17 00:00:00 2001 -From: xingyanan -Date: Mon, 27 Jun 2022 21:30:52 +0800 -Subject: [PATCH] split start window - -Signed-off-by: xingyanan -Change-Id: I9cfbd934932be339cd4381bc541cc4cac658e77b ---- - interfaces/innerkits/wm/wm_common.h | 1 + - .../config/rk3568/window_manager_config.xml | 2 +- - resources/media/BUILD.gn | 12 +- - resources/media/img/bg_place_holder.png | Bin 0 -> 3500 bytes - utils/BUILD.gn | 2 + - utils/draw_surface.cpp | 195 ++++++++++++++++++ - utils/include/draw_surface.h | 48 +++++ - utils/include/surface_draw.h | 18 ++ - utils/src/surface_draw.cpp | 170 +++++++++++++++ - wm/src/window_impl.cpp | 4 + - wmserver/BUILD.gn | 1 + - wmserver/include/window_inner_manager.h | 33 +++ - wmserver/include/window_pair.h | 1 + - wmserver/include/window_zorder_policy.h | 1 + - wmserver/src/window_inner_manager.cpp | 183 +++++++++++++++- - wmserver/src/window_pair.cpp | 20 +- - 16 files changed, 685 insertions(+), 6 deletions(-) - create mode 100644 resources/media/img/bg_place_holder.png - create mode 100644 utils/draw_surface.cpp - create mode 100644 utils/include/draw_surface.h - -diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h -index 24da28ce..bf4a8ccf 100644 ---- a/interfaces/innerkits/wm/wm_common.h -+++ b/interfaces/innerkits/wm/wm_common.h -@@ -43,6 +43,7 @@ enum class WindowType : uint32_t { - ABOVE_APP_SYSTEM_WINDOW_BASE = 2100, - WINDOW_TYPE_APP_LAUNCHING = ABOVE_APP_SYSTEM_WINDOW_BASE, - WINDOW_TYPE_DOCK_SLICE, -+ WINDOW_TYPE_PLACE_HOLDER, - WINDOW_TYPE_INCOMING_CALL, - WINDOW_TYPE_SEARCHING_BAR, - WINDOW_TYPE_SYSTEM_ALARM_WINDOW, -diff --git a/resources/config/rk3568/window_manager_config.xml b/resources/config/rk3568/window_manager_config.xml -index 70ca77e2..9c11c5a9 100644 ---- a/resources/config/rk3568/window_manager_config.xml -+++ b/resources/config/rk3568/window_manager_config.xml -@@ -15,7 +15,7 @@ - --> - - -- -+ - - 100 - -diff --git a/resources/media/BUILD.gn b/resources/media/BUILD.gn -index 1f2b8c85..6d152d78 100644 ---- a/resources/media/BUILD.gn -+++ b/resources/media/BUILD.gn -@@ -19,6 +19,16 @@ ohos_prebuilt_etc("window_divider_image") { - relative_install_dir = "window/resources" - } - -+ohos_prebuilt_etc("window_place_holder_image") { -+ source = "//foundation/windowmanager/resources/media/img/bg_place_holder.png" -+ part_name = "window_manager" -+ subsystem_name = "window" -+ relative_install_dir = "window/resources" -+} -+ -+ - group("window_resources_media") { -- deps = [ ":window_divider_image" ] -+ deps = [ ":window_divider_image", -+ ":window_place_holder_image" -+ ] - } -diff --git a/resources/media/img/bg_place_holder.png b/resources/media/img/bg_place_holder.png -new file mode 100644 -index 0000000000000000000000000000000000000000..9936aee1a38039dba2ddfacaf56ce9d8c94a1f59 -GIT binary patch -literal 3500 -zcmeH~k55xa9Ker?ii(mfnUINK+>EJHV2sg*m0zM$>I71M01padt|~SyqSykZ1%JUd -z9cXA+#-L1H!Htyq>$O0kW$U2P1}ma1Qr;{0<~sH))v~tK(ss{3V+qOKeJ|hp=DwHv -z-re_e-{fTNS-bkZ)c}CCnR|CJ03Z=v5(rsAh<_`eydlJ@lY8?|0}%86+Zt3UP2~~B -zMVY(O4_3C>ko`>?b9d@yPXGE)cpH&WcWj|g+#+4OvR_d{Qh#`|yq-`*TZGCvo{AquG0d|HOioJ+%QLFrXv0z$A9a={ -zNeot>f|FqvE@;D|!9udLJW^?#tf59`d3~ay7M9SIuD??Vmqa{>3uWcE@KQRWk*TS| -z&&MmK6r6-*0EFer;3tsMC#u~h4aKNMP1r<3$pp%qiVKy>aL9OOV^`^9F_XzGEG|xM -zw|Z`I%z5m00eF?>M7?pLW}3mvG1r$wD9R&E{N-t6>AhI>!u6Vf&uyznN>=yv^-X<(oIE9{9WtB<4-eORYEWWvG)d>|{r;W?#)C)R -zCY=-2(+onUNht{dy?j{AI3YX2=4g6wHJtd;?R^Xh@UxuO&Y7B&=!e$%8?1bnRQzUq -zxYn$QH_W@99qX_)>9DdJ08~=Bxi6bk$lOUk9{UmOb{tj?U8R3R+a)c}0?sDRZ85 -zXJ{21=iJAEuJKauKizVX^ZD?l;fv8Ag$5gOR=&R`qMlKdj|T4Nh}v9o`P@KnZv+>y -z>TWtd1%1_^6y$YiO -z!Xf(XW&lz|8Eg(>;~ikz3hCvs00c)6#_Jli_bm2oj2Z(UzDt1T)n4D1fys-)<1!9G -zb2YRmIbVg0QXBPmwiAG#LV}Ht1*sMUm8909#KW2gQ~3nMD;>AgDq5V*UJTVFNAM6<|tlM_vzLuVn$0NwjhU%TZc~p -zK>G?7$H(d&cC*3>;eKn%f)Vs4k6{E`-pC_?y0G5}k58ZmrSNZNP!63eHC8XOMuGt? -zxJ}s#52*ycqUIg@BW(#Qrz)s;WFc668ED3|j$uqw)Tpz?zB+d0T$>pN5F< -P7s%Y5wX0|67w7&1Q$p_} - -literal 0 -HcmV?d00001 - -diff --git a/utils/BUILD.gn b/utils/BUILD.gn -index a04be886..6723a668 100644 ---- a/utils/BUILD.gn -+++ b/utils/BUILD.gn -@@ -45,6 +45,7 @@ ohos_shared_library("libwmutil") { - "src/window_property.cpp", - "src/window_transition_info.cpp", - "src/wm_trace.cpp", -+ "draw_surface.cpp" - ] - - configs = [ ":libwmutil_private_config" ] -@@ -54,6 +55,7 @@ ohos_shared_library("libwmutil") { - deps = [ - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", -+ "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics", - "//third_party/flutter/build/skia:ace_skia_ohos", - ] - -diff --git a/utils/draw_surface.cpp b/utils/draw_surface.cpp -new file mode 100644 -index 00000000..06a0aa5a ---- /dev/null -+++ b/utils/draw_surface.cpp -@@ -0,0 +1,195 @@ -+/* -+ * Copyright (c) 2022-2022 Huawei Device Co., Ltd. -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#include "draw_surface.h" -+#include "image/bitmap.h" -+#include "image_source.h" -+#include "image_type.h" -+#include "image_utils.h" -+#include "pixel_map.h" -+#include "window_manager_hilog.h" -+ -+namespace OHOS { -+namespace Rosen { -+namespace { -+ constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "DrawSurface"}; -+} // namespace -+ -+bool DrawSurface::DrawImage(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, -+ const std::string& imagePath) -+{ -+ sptr layer = GetLayer(surfaceNode); -+ if (layer == nullptr) { -+ WLOGFE("layer is nullptr"); -+ return false; -+ } -+ sptr buffer = GetSurfaceBuffer(layer, bufferWidth, bufferHeight); -+ if (buffer == nullptr || buffer->GetVirAddr() == nullptr) { -+ return false; -+ } -+ auto addr = static_cast(buffer->GetVirAddr()); -+ if (!DoDraw(addr, buffer->GetWidth(), buffer->GetHeight(), imagePath)) { -+ WLOGE("draw window pixel failed"); -+ return false; -+ } -+ OHOS::BufferFlushConfig flushConfig = { -+ .damage = { -+ .w = buffer->GetWidth(), -+ .h = buffer->GetHeight(), -+ }, -+ }; -+ OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig); -+ if (ret != OHOS::SurfaceError::SURFACE_ERROR_OK) { -+ WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); -+ return false; -+ } -+ return true; -+} -+ -+bool DrawSurface::DrawColor(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, -+ uint32_t color) -+{ -+ sptr layer = GetLayer(surfaceNode); -+ if (layer == nullptr) { -+ WLOGFE("layer is nullptr"); -+ return false; -+ } -+ sptr buffer = GetSurfaceBuffer(layer, bufferWidth, bufferHeight); -+ if (buffer == nullptr || buffer->GetVirAddr() == nullptr) { -+ return false; -+ } -+ auto addr = static_cast(buffer->GetVirAddr()); -+ if (!DoDraw(addr, buffer->GetWidth(), buffer->GetHeight(), color)) { -+ WLOGE("draw window color failed"); -+ return false; -+ } -+ OHOS::BufferFlushConfig flushConfig = { -+ .damage = { -+ .w = buffer->GetWidth(), -+ .h = buffer->GetHeight(), -+ }, -+ }; -+ OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig); -+ if (ret != OHOS::SurfaceError::SURFACE_ERROR_OK) { -+ WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); -+ return false; -+ } -+ return true; -+} -+ -+sptr DrawSurface::GetLayer(std::shared_ptr surfaceNode) -+{ -+ if (surfaceNode == nullptr) { -+ return nullptr; -+ } -+ return surfaceNode->GetSurface(); -+} -+ -+sptr DrawSurface::GetSurfaceBuffer(sptr layer, -+ int32_t bufferWidth, int32_t bufferHeight) -+{ -+ sptr buffer; -+ int32_t releaseFence = 0; -+ OHOS::BufferRequestConfig config = { -+ .width = bufferWidth, -+ .height = bufferHeight, -+ .strideAlignment = 0x8, -+ .format = PIXEL_FMT_RGBA_8888, -+ .usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA, -+ }; -+ -+ OHOS::SurfaceError ret = layer->RequestBuffer(buffer, releaseFence, config); -+ if (ret != OHOS::SURFACE_ERROR_OK) { -+ WLOGFE("request buffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); -+ return nullptr; -+ } -+ return buffer; -+} -+ -+std::unique_ptr DrawSurface::DecodeImageToPixelMap(const std::string &imagePath) -+{ -+ OHOS::Media::SourceOptions opts; -+ opts.formatHint = "image/png"; -+ uint32_t ret = 0; -+ auto imageSource = OHOS::Media::ImageSource::CreateImageSource(imagePath, opts, ret); -+ // CHKPP(imageSource); -+ std::set formats; -+ ret = imageSource->GetSupportedFormats(formats); -+ WLOGFD("get supported format ret:%{public}u", ret); -+ -+ OHOS::Media::DecodeOptions decodeOpts; -+ std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, ret); -+ if (pixelMap == nullptr) { -+ WLOGFE("pixelMap is nullptr"); -+ } -+ return pixelMap; -+} -+ -+void DrawSurface::DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath) -+{ -+ std::unique_ptr pixelmap = DecodeImageToPixelMap(imagePath); -+ if (pixelmap == nullptr) { -+ WLOGFE("drawing pixel map is nullptr"); -+ return; -+ } -+ OHOS::Rosen::Drawing::Pen pen; -+ pen.SetAntiAlias(true); -+ pen.SetColor(OHOS::Rosen::Drawing::Color::COLOR_BLUE); -+ OHOS::Rosen::Drawing::scalar penWidth = 1; -+ pen.SetWidth(penWidth); -+ canvas.AttachPen(pen); -+ canvas.DrawBitmap(*pixelmap, 0, 0); -+} -+ -+bool DrawSurface::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath) -+{ -+ OHOS::Rosen::Drawing::Bitmap bitmap; -+ OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888, -+ OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE }; -+ bitmap.Build(width, height, format); -+ OHOS::Rosen::Drawing::Canvas canvas; -+ canvas.Bind(bitmap); -+ canvas.Clear(OHOS::Rosen::Drawing::Color::COLOR_TRANSPARENT); -+ DrawPixelmap(canvas, imagePath); -+ static constexpr uint32_t stride = 4; -+ uint32_t addrSize = width * height * stride; -+ errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize); -+ if (ret != EOK) { -+ WLOGFE("draw failed"); -+ return false; -+ } -+ return true; -+} -+bool DrawSurface::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color) -+{ -+ OHOS::Rosen::Drawing::Bitmap bitmap; -+ OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888, -+ OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE }; -+ bitmap.Build(width, height, format); -+ OHOS::Rosen::Drawing::Canvas canvas; -+ canvas.Bind(bitmap); -+ canvas.Clear(color); -+ -+ static constexpr uint32_t stride = 4; -+ uint32_t addrSize = width * height * stride; -+ errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize); -+ if (ret != EOK) { -+ WLOGFE("draw failed"); -+ return false; -+ } -+ return true; -+} -+} // Rosen -+} // OHOS -\ No newline at end of file -diff --git a/utils/include/draw_surface.h b/utils/include/draw_surface.h -new file mode 100644 -index 00000000..1dd19395 ---- /dev/null -+++ b/utils/include/draw_surface.h -@@ -0,0 +1,48 @@ -+/* -+ * Copyright (c) 2022-2022 Huawei Device Co., Ltd. -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#ifndef DRAW_SURFACE_H -+#define DRAW_SURFACE_H -+ -+#include "draw/canvas.h" -+#include "nocopyable.h" -+#include "pixel_map.h" -+#include "refbase.h" -+#include "ui/rs_surface_node.h" -+#include "wm_common.h" -+#include "window.h" -+ -+namespace OHOS { -+namespace Rosen { -+class DrawSurface { -+public: -+ ~DrawSurface() = default; -+ static bool DrawColor(std::shared_ptr surfaceNode, int32_t bufferWidth, -+ int32_t bufferHeight, uint32_t color); -+ static bool DrawImage(std::shared_ptr surfaceNode, int32_t bufferWidth, -+ int32_t bufferHeight,const std::string& imagePath); -+private: -+ DrawSurface() {}; -+ static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath); -+ static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color); -+ static sptr GetLayer(std::shared_ptr surfaceNode); -+ static sptr GetSurfaceBuffer(sptr layer, -+ int32_t bufferWidth, int32_t bufferHeight); -+ static void DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath); -+ static std::unique_ptr DecodeImageToPixelMap(const std::string &imagePath); -+}; -+} // Rosen -+} // OHOS -+#endif // DRAW_SURFACE_H -\ No newline at end of file -diff --git a/utils/include/surface_draw.h b/utils/include/surface_draw.h -index b312159f..8db73f64 100644 ---- a/utils/include/surface_draw.h -+++ b/utils/include/surface_draw.h -@@ -23,6 +23,11 @@ - #endif - #include "refbase.h" - #include "wm_common.h" -+#include "window.h" -+ -+#include "draw/canvas.h" -+#include "nocopyable.h" -+#include "pixel_map.h" - - namespace OHOS { - namespace Rosen { -@@ -37,6 +42,19 @@ public: - bool DecodeImageFile(const char* filename, SkBitmap& bitmap); - void DrawSkImage(std::shared_ptr surfaceNode, Rect winRect, - sptr pixelMap, uint32_t bkgColor); -+ -+ bool DrawWindow(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, -+ uint32_t color); -+ bool DrawWindow(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, -+ const std::string& imagePath); -+ bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath); -+ bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color); -+ sptr GetLayer(std::shared_ptr surfaceNode); -+ sptr GetSurfaceBuffer(sptr layer, -+ int32_t bufferWidth, int32_t bufferHeight) const; -+ -+ void DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath); -+ std::unique_ptr DecodeImageToPixelMap(const std::string &imagePath); - private: - - std::shared_ptr PrepareDraw(std::shared_ptr surfaceNode, -diff --git a/utils/src/surface_draw.cpp b/utils/src/surface_draw.cpp -index d4ebc775..70c0fa83 100644 ---- a/utils/src/surface_draw.cpp -+++ b/utils/src/surface_draw.cpp -@@ -24,6 +24,12 @@ - #include "include/core/SkData.h" - #include "include/core/SkImage.h" - #include "include/core/SkPixmap.h" -+ -+#include "image/bitmap.h" -+#include "image_source.h" -+#include "image_type.h" -+#include "image_utils.h" -+#include "pixel_map.h" - namespace OHOS { - namespace Rosen { - namespace { -@@ -234,5 +240,169 @@ void SurfaceDraw::DrawSkImage(std::shared_ptr surfaceNode, Rect w - } - return; - } -+ -+bool SurfaceDraw::DrawWindow(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, -+ const std::string& imagePath) -+{ -+ sptr layer = GetLayer(surfaceNode); -+ if (layer == nullptr) { -+ WLOGFE("layer is nullptr"); -+ return false; -+ } -+ sptr buffer = GetSurfaceBuffer(layer, bufferWidth, bufferHeight); -+ if (buffer == nullptr || buffer->GetVirAddr() == nullptr) { -+ return false; -+ } -+ auto addr = static_cast(buffer->GetVirAddr()); -+ if (!DoDraw(addr, buffer->GetWidth(), buffer->GetHeight(), imagePath)) { -+ WLOGE("draw window pixel failed"); -+ return false; -+ } -+ OHOS::BufferFlushConfig flushConfig = { -+ .damage = { -+ .w = buffer->GetWidth(), -+ .h = buffer->GetHeight(), -+ }, -+ }; -+ OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig); -+ if (ret != OHOS::SurfaceError::SURFACE_ERROR_OK) { -+ WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); -+ return false; -+ } -+ return true; -+} -+ -+bool SurfaceDraw::DrawWindow(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, -+ uint32_t color) -+{ -+ sptr layer = GetLayer(surfaceNode); -+ if (layer == nullptr) { -+ WLOGFE("layer is nullptr"); -+ return false; -+ } -+ sptr buffer = GetSurfaceBuffer(layer, bufferWidth, bufferHeight); -+ if (buffer == nullptr || buffer->GetVirAddr() == nullptr) { -+ return false; -+ } -+ auto addr = static_cast(buffer->GetVirAddr()); -+ if (!DoDraw(addr, buffer->GetWidth(), buffer->GetHeight(), color)) { -+ WLOGE("draw window color failed"); -+ return false; -+ } -+ OHOS::BufferFlushConfig flushConfig = { -+ .damage = { -+ .w = buffer->GetWidth(), -+ .h = buffer->GetHeight(), -+ }, -+ }; -+ OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig); -+ if (ret != OHOS::SurfaceError::SURFACE_ERROR_OK) { -+ WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); -+ return false; -+ } -+ return true; -+} -+ -+sptr SurfaceDraw::GetLayer(std::shared_ptr surfaceNode) -+{ -+ if (surfaceNode == nullptr) { -+ return nullptr; -+ } -+ return surfaceNode->GetSurface(); -+} -+ -+sptr SurfaceDraw::GetSurfaceBuffer(sptr layer, int32_t bufferWidth, -+ int32_t bufferHeight) const -+{ -+ sptr buffer; -+ int32_t releaseFence = 0; -+ OHOS::BufferRequestConfig config = { -+ .width = bufferWidth, -+ .height = bufferHeight, -+ .strideAlignment = 0x8, -+ .format = PIXEL_FMT_RGBA_8888, -+ .usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA, -+ }; -+ -+ OHOS::SurfaceError ret = layer->RequestBuffer(buffer, releaseFence, config); -+ if (ret != OHOS::SURFACE_ERROR_OK) { -+ WLOGFE("request buffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); -+ return nullptr; -+ } -+ return buffer; -+} -+ -+std::unique_ptr SurfaceDraw::DecodeImageToPixelMap(const std::string &imagePath) -+{ -+ OHOS::Media::SourceOptions opts; -+ opts.formatHint = "image/png"; -+ uint32_t ret = 0; -+ auto imageSource = OHOS::Media::ImageSource::CreateImageSource(imagePath, opts, ret); -+ // CHKPP(imageSource); -+ std::set formats; -+ ret = imageSource->GetSupportedFormats(formats); -+ WLOGFD("get supported format ret:%{public}u", ret); -+ -+ OHOS::Media::DecodeOptions decodeOpts; -+ std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, ret); -+ if (pixelMap == nullptr) { -+ WLOGFE("pixelMap is nullptr"); -+ } -+ return pixelMap; -+} -+ -+void SurfaceDraw::DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath) -+{ -+ std::unique_ptr pixelmap = DecodeImageToPixelMap(imagePath); -+ if (pixelmap == nullptr) { -+ WLOGFE("drawing pixel map is nullptr"); -+ return; -+ } -+ OHOS::Rosen::Drawing::Pen pen; -+ pen.SetAntiAlias(true); -+ pen.SetColor(OHOS::Rosen::Drawing::Color::COLOR_BLUE); -+ OHOS::Rosen::Drawing::scalar penWidth = 1; -+ pen.SetWidth(penWidth); -+ canvas.AttachPen(pen); -+ canvas.DrawBitmap(*pixelmap, 0, 0); -+} -+ -+bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath) -+{ -+ OHOS::Rosen::Drawing::Bitmap bitmap; -+ OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888, -+ OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE }; -+ bitmap.Build(width, height, format); -+ OHOS::Rosen::Drawing::Canvas canvas; -+ canvas.Bind(bitmap); -+ canvas.Clear(OHOS::Rosen::Drawing::Color::COLOR_TRANSPARENT); -+ DrawPixelmap(canvas, imagePath); -+ static constexpr uint32_t stride = 4; -+ uint32_t addrSize = width * height * stride; -+ errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize); -+ if (ret != EOK) { -+ WLOGFE("draw failed"); -+ return false; -+ } -+ return true; -+} -+bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color) -+{ -+ OHOS::Rosen::Drawing::Bitmap bitmap; -+ OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888, -+ OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE }; -+ bitmap.Build(width, height, format); -+ OHOS::Rosen::Drawing::Canvas canvas; -+ canvas.Bind(bitmap); -+ canvas.Clear(color); -+ static constexpr uint32_t stride = 4; -+ uint32_t addrSize = width * height * stride; -+ errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize); -+ if (ret != EOK) { -+ WLOGFE("draw failed"); -+ return false; -+ } -+ return true; -+} - } // Rosen - } // OHOS -\ No newline at end of file -diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp -index 0dcecf56..03d40f2f 100644 ---- a/wm/src/window_impl.cpp -+++ b/wm/src/window_impl.cpp -@@ -2305,6 +2305,10 @@ void WindowImpl::SetDefaultOption() - property_->SetFocusable(false); - break; - } -+ case WindowType::WINDOW_TYPE_PLACE_HOLDER: { -+ AddWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE); -+ break; -+ } - default: - break; - } -diff --git a/wmserver/BUILD.gn b/wmserver/BUILD.gn -index 6637bc4c..e76a11db 100644 ---- a/wmserver/BUILD.gn -+++ b/wmserver/BUILD.gn -@@ -73,6 +73,7 @@ ohos_shared_library("libwms") { - - deps = [ - "//foundation/arkui/ace_engine/interfaces/inner_api/ui_service_manager:ui_service_mgr", -+ "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", - "//foundation/windowmanager/dm:libdm", - "//foundation/windowmanager/dmserver:libdms", -diff --git a/wmserver/include/window_inner_manager.h b/wmserver/include/window_inner_manager.h -index 3ab54045..b8a40e95 100644 ---- a/wmserver/include/window_inner_manager.h -+++ b/wmserver/include/window_inner_manager.h -@@ -20,12 +20,35 @@ - #include "event_handler.h" - #include "event_runner.h" - -+#include -+#include "draw/canvas.h" -+#include "nocopyable.h" -+#include "pixel_map.h" -+ - #include "wm_common.h" - #include "wm_single_instance.h" -+#include "window.h" - - namespace OHOS { - namespace Rosen { -+class TouchOutsideListener : public ITouchOutsideListener { -+ virtual void OnTouchOutside(); -+}; -+class InputListener : public IInputEventListener { -+ virtual void OnKeyEvent(std::shared_ptr& keyEvent); -+ virtual void OnPointerInputEvent(std::shared_ptr& pointerEvent); -+}; -+class LifeCycle : public IWindowLifeCycle { -+ virtual void AfterForeground() {}; -+ virtual void AfterBackground() {}; -+ virtual void AfterFocused() {}; -+ virtual void AfterInactive(); -+ virtual void AfterUnfocused() {}; -+}; - class WindowInnerManager : public RefBase { -+friend class TouchOutsideListener; -+friend class InputListener; -+friend class LifeCycle; - WM_DECLARE_SINGLE_INSTANCE_BASE(WindowInnerManager); - using EventRunner = OHOS::AppExecFwk::EventRunner; - using EventHandler = OHOS::AppExecFwk::EventHandler; -@@ -34,6 +57,8 @@ public: - void Stop(); - void CreateWindow(std::string name, WindowType type, Rect rect); - void DestroyWindow(); -+ void CreatePlaceHolderWindow(WindowMode mode, DisplayId displayId); -+ void DestroyPlaceHolderWindow(); - public: - enum class InnerWMRunningState { - STATE_NOT_START, -@@ -45,8 +70,15 @@ private: - WindowInnerManager(); - bool Init(); - void HandleCreateWindow(std::string name, WindowType type, Rect rect); -+ void HandleCreatePlaceHolderWindow(WindowMode mode, DisplayId displayId); - void HandleDestroyWindow(); - -+ sptr GetLayer(); -+ sptr GetSurfaceBuffer(sptr layer) const; -+ void DoDraw(uint8_t *addr, uint32_t width, uint32_t height); -+ void DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas); -+ std::unique_ptr DecodeImageToPixelMap(const std::string &imagePath); -+ - private: - int32_t dialogId_ = -1; - std::shared_ptr eventHandler_; -@@ -54,6 +86,7 @@ private: - InnerWMRunningState state_; - std::string dividerParams_ = ""; - const std::string INNER_WM_THREAD_NAME = "inner_window_manager"; -+ sptr placeHolderwindow_ = nullptr; - }; - } // namespace Rosen - } // namespace OHOS -diff --git a/wmserver/include/window_pair.h b/wmserver/include/window_pair.h -index 86d8391c..237cdc4a 100644 ---- a/wmserver/include/window_pair.h -+++ b/wmserver/include/window_pair.h -@@ -250,6 +250,7 @@ private: - sptr primary_; - sptr secondary_; - sptr divider_; -+ // sptr placeholder_; - WindowPairStatus status_ = {WindowPairStatus::STATUS_EMPTY}; - DisplayGroupWindowTree& displayGroupWindowTree_; - bool isAllAppWindowsRestoring_ { false }; -diff --git a/wmserver/include/window_zorder_policy.h b/wmserver/include/window_zorder_policy.h -index 8df41594..4f52082f 100644 ---- a/wmserver/include/window_zorder_policy.h -+++ b/wmserver/include/window_zorder_policy.h -@@ -45,6 +45,7 @@ private: - { WindowType::WINDOW_TYPE_APP_COMPONENT, 2 }, - { WindowType::WINDOW_TYPE_APP_LAUNCHING, 101 }, - { WindowType::WINDOW_TYPE_DOCK_SLICE, 0 }, -+ { WindowType::WINDOW_TYPE_PLACE_HOLDER, 0 }, - { WindowType::WINDOW_TYPE_LAUNCHER_RECENT, 102 }, - { WindowType::WINDOW_TYPE_LAUNCHER_DOCK, 103 }, - { WindowType::WINDOW_TYPE_INCOMING_CALL, 104 }, -diff --git a/wmserver/src/window_inner_manager.cpp b/wmserver/src/window_inner_manager.cpp -index 5cddc9f0..c4e35708 100644 ---- a/wmserver/src/window_inner_manager.cpp -+++ b/wmserver/src/window_inner_manager.cpp -@@ -15,14 +15,22 @@ - - #include "window_inner_manager.h" - -+#include "draw_surface.h" - #include "ui_service_mgr_client.h" - #include "window_manager_hilog.h" --#include "window.h" -+#include "image/bitmap.h" -+#include "image_source.h" -+#include "image_type.h" -+#include "image_utils.h" -+#include "pixel_map.h" - - namespace OHOS { - namespace Rosen { - namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowInnerManager"}; -+ const std::string IMAGE_PLACE_HOLDER_PNG_PATH = "/etc/window/resources/bg_place_holder.png"; -+ const int32_t IMAGE_WIDTH = 512; -+ const int32_t IMAGE_HEIGHT = 512; - } - WM_IMPLEMENT_SINGLE_INSTANCE(WindowInnerManager) - -@@ -90,6 +98,179 @@ void WindowInnerManager::HandleCreateWindow(std::string name, WindowType type, R - return; - } - -+std::unique_ptr WindowInnerManager::DecodeImageToPixelMap(const std::string &imagePath) -+{ -+ OHOS::Media::SourceOptions opts; -+ opts.formatHint = "image/png"; -+ uint32_t ret = 0; -+ auto imageSource = OHOS::Media::ImageSource::CreateImageSource(imagePath, opts, ret); -+ // CHKPP(imageSource); -+ std::set formats; -+ ret = imageSource->GetSupportedFormats(formats); -+ WLOGFD("get supported format ret:%{public}u", ret); -+ -+ OHOS::Media::DecodeOptions decodeOpts; -+ std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, ret); -+ if (pixelMap == nullptr) { -+ WLOGFE("pixelMap is nullptr"); -+ } -+ return pixelMap; -+} -+ -+void WindowInnerManager::DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas) -+{ -+ std::unique_ptr pixelmap = DecodeImageToPixelMap(IMAGE_PLACE_HOLDER_PNG_PATH); -+ OHOS::Rosen::Drawing::Pen pen; -+ pen.SetAntiAlias(true); -+ pen.SetColor(OHOS::Rosen::Drawing::Color::COLOR_BLUE); -+ OHOS::Rosen::Drawing::scalar penWidth = 1; -+ pen.SetWidth(penWidth); -+ canvas.AttachPen(pen); -+ canvas.DrawBitmap(*pixelmap, 0, 0); -+} -+ -+void WindowInnerManager::DoDraw(uint8_t *addr, uint32_t width, uint32_t height) -+{ -+ OHOS::Rosen::Drawing::Bitmap bitmap; -+ OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888, -+ OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE }; -+ bitmap.Build(width, height, format); -+ OHOS::Rosen::Drawing::Canvas canvas; -+ canvas.Bind(bitmap); -+ canvas.Clear(OHOS::Rosen::Drawing::Color::COLOR_TRANSPARENT); -+ DrawPixelmap(canvas); -+ static constexpr uint32_t stride = 4; -+ uint32_t addrSize = width * height * stride; -+ errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize); -+ if (ret != EOK) { -+ return; -+ } -+} -+void WindowInnerManager::DestroyPlaceHolderWindow() -+{ -+ if (placeHolderwindow_ != nullptr) { -+ placeHolderwindow_->Destroy(); -+ placeHolderwindow_ = nullptr; -+ } -+} -+ -+void WindowInnerManager::CreatePlaceHolderWindow(WindowMode mode, DisplayId displayId) -+{ -+ eventHandler_->PostTask([this, mode, displayId]() { -+ HandleCreatePlaceHolderWindow(mode, displayId); -+ }); -+ return; -+} -+ -+void TouchOutsideListener::OnTouchOutside() -+{ -+ WindowInnerManager::GetInstance().DestroyPlaceHolderWindow(); -+} -+ -+void InputListener::OnKeyEvent(std::shared_ptr& keyEvent) -+{ -+ WindowInnerManager::GetInstance().DestroyPlaceHolderWindow(); -+} -+ -+void InputListener::OnPointerInputEvent(std::shared_ptr& pointerEvent) -+{ -+ WindowInnerManager::GetInstance().DestroyPlaceHolderWindow(); -+} -+ -+void LifeCycle::AfterInactive() -+{ -+ WindowInnerManager::GetInstance().DestroyPlaceHolderWindow(); -+} -+ -+void WindowInnerManager::HandleCreatePlaceHolderWindow(WindowMode mode, DisplayId displayId) -+{ -+ if (placeHolderwindow_ != nullptr) { -+ return; -+ } -+ sptr opt = new (std::nothrow) WindowOption(); -+ if (opt == nullptr) { -+ WLOGFE("Window option is nullptr."); -+ return; -+ } -+ opt->SetWindowType(WindowType::WINDOW_TYPE_PLACE_HOLDER); -+ opt->SetFocusable(false); -+ opt->SetWindowMode(mode); -+ placeHolderwindow_ = Window::Create("place_holder" + std::to_string(displayId), opt); -+ if (placeHolderwindow_ == nullptr) { -+ WLOGFE("Window is nullptr."); -+ return; -+ } -+ sptr touchOutsideListener = new TouchOutsideListener(); -+ // sptr inputListener = new InputListener(); -+ sptr lifeCycleListener = new LifeCycle(); -+ placeHolderwindow_->RegisterTouchOutsideListener(touchOutsideListener); -+ // placeHolderwindow_->RegisterInputEventListener(inputListener); -+ placeHolderwindow_->RegisterLifeCycleListener(lifeCycleListener); -+ // placeHolderwindow_->Show(); -+ if (!OHOS::Rosen::DrawSurface::DrawImage(placeHolderwindow_->GetSurfaceNode(), -+ IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_PLACE_HOLDER_PNG_PATH)) { -+ WLOGE("draw surface failed"); -+ return; -+ } -+ // sptr layer = GetLayer(); -+ // if (layer == nullptr) { -+ // placeHolderwindow_->Destroy(); -+ // placeHolderwindow_ = nullptr; -+ // return; -+ // } -+ -+ // sptr buffer = GetSurfaceBuffer(layer); -+ // if (buffer == nullptr || buffer->GetVirAddr() == nullptr) { -+ // placeHolderwindow_->Destroy(); -+ // placeHolderwindow_ = nullptr; -+ // return; -+ // } -+ -+ // auto addr = static_cast(buffer->GetVirAddr()); -+ // DoDraw(addr, buffer->GetWidth(), buffer->GetHeight()); -+ // OHOS::BufferFlushConfig flushConfig = { -+ // .damage = { -+ // .w = buffer->GetWidth(), -+ // .h = buffer->GetHeight(), -+ // }, -+ // }; -+ // OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig); -+ // WLOGFD("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); -+ placeHolderwindow_->Show(); -+ return; -+} -+ -+sptr WindowInnerManager::GetLayer() -+{ -+ std::shared_ptr surfaceNode = placeHolderwindow_->GetSurfaceNode(); -+ if (surfaceNode == nullptr) { -+ placeHolderwindow_->Destroy(); -+ placeHolderwindow_ = nullptr; -+ return nullptr; -+ } -+ return surfaceNode->GetSurface(); -+} -+ -+sptr WindowInnerManager::GetSurfaceBuffer(sptr layer) const -+{ -+ sptr buffer; -+ int32_t releaseFence = 0; -+ OHOS::BufferRequestConfig config = { -+ .width = IMAGE_WIDTH, -+ .height = IMAGE_HEIGHT, -+ .strideAlignment = 0x8, -+ .format = PIXEL_FMT_RGBA_8888, -+ .usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA, -+ }; -+ -+ OHOS::SurfaceError ret = layer->RequestBuffer(buffer, releaseFence, config); -+ if (ret != OHOS::SURFACE_ERROR_OK) { -+ WLOGFE("request buffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); -+ return nullptr; -+ } -+ return buffer; -+} -+ - void WindowInnerManager::HandleDestroyWindow() - { - if (dialogId_ == -1) { -diff --git a/wmserver/src/window_pair.cpp b/wmserver/src/window_pair.cpp -index 095b4add..3b018ba3 100644 ---- a/wmserver/src/window_pair.cpp -+++ b/wmserver/src/window_pair.cpp -@@ -327,15 +327,21 @@ void WindowPair::UpdateIfSplitRelated(sptr& node) - WLOGI("Window id: %{public}u is not split related and paired.", node->GetWindowId()); - return; - } -+ if ((node->GetWindowType() == WindowType::WINDOW_TYPE_PLACE_HOLDER) && -+ ((primary_ != nullptr && primary_->GetWindowMode() == node->GetWindowMode()) || -+ (secondary_ != nullptr && secondary_->GetWindowMode() == node->GetWindowMode()))) { -+ WindowInnerManager::GetInstance().DestroyPlaceHolderWindow(); -+ return; -+ } - WLOGI("Current status: %{public}u, window id: %{public}u mode: %{public}u", - status_, node->GetWindowId(), node->GetWindowMode()); - if (status_ == WindowPairStatus::STATUS_EMPTY) { - Insert(node); - if (!isAllAppWindowsRestoring_) { - // find pairable window from trees or send broadcast -- sptr pairableNode = GetPairableWindow(node); -- // insert pairable node -- Insert(pairableNode); -+ WindowMode holderMode = node->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY ? -+ WindowMode::WINDOW_MODE_SPLIT_SECONDARY : WindowMode::WINDOW_MODE_SPLIT_PRIMARY; -+ WindowInnerManager::GetInstance().CreatePlaceHolderWindow(holderMode, displayId_); - } - } else { - if (Find(node) == nullptr) { -@@ -432,6 +438,10 @@ void WindowPair::Insert(sptr& node) - if (node == nullptr) { - return; - } -+ // if (node->GetWindowType() == WindowType::WINDOW_TYPE_PLACE_HOLDER) { -+ // placeholder_ = node; -+ // return; -+ // } - WLOGI("Insert a window to pair id: %{public}u", node->GetWindowId()); - sptr pairedNode; - if (node->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY) { -@@ -448,6 +458,10 @@ void WindowPair::Insert(sptr& node) - if (pairedNode != nullptr && pairedNode->abilityToken_ != nullptr) { - MinimizeApp::AddNeedMinimizeApp(pairedNode, MinimizeReason::SPLIT_REPLACE); - } -+ // if (placeholder_ != nullptr) { -+ // WindowInnerManager::GetInstance().DestroyPlaceHolderWindow(); -+ // placeholder_ = nullptr; -+ // } - UpdateWindowPairStatus(); - } - --- -2.25.1 - diff --git a/dm/test/systemtest/screenshot_cmd_test.cpp b/dm/test/systemtest/screenshot_cmd_test.cpp index 1c0ccb60..72f16b37 100644 --- a/dm/test/systemtest/screenshot_cmd_test.cpp +++ b/dm/test/systemtest/screenshot_cmd_test.cpp @@ -32,7 +32,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenshotCmdTest"}; } -using utils = DisplayTestUtils; +using Utils = DisplayTestUtils; class ScreenshotCmdTest : public testing::Test { public: static void SetUpTestCase(); diff --git a/dm/test/systemtest/screenshot_test.cpp b/dm/test/systemtest/screenshot_test.cpp index ee31ee98..fe7823bf 100644 --- a/dm/test/systemtest/screenshot_test.cpp +++ b/dm/test/systemtest/screenshot_test.cpp @@ -28,7 +28,7 @@ namespace Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenshotTest"}; } -using utils = DisplayTestUtils; +using Utils = DisplayTestUtils; class ScreenshotTest : public testing::Test { public: static void SetUpTestCase(); @@ -109,7 +109,7 @@ HWTEST_F(ScreenshotTest, ScreenShotValid03, Function | MediumTest | Level2) ASSERT_NE(nullptr, screenshot); Media::Size screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize)); + ASSERT_TRUE(Utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize)); } /** @@ -137,20 +137,20 @@ HWTEST_F(ScreenshotTest, ScreenShotValid05, Function | MediumTest | Level2) defaultImage_, defaultRot_); ASSERT_NE(nullptr, screenshot); Media::Size screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqual(defaultImage_, screenSize)); + ASSERT_TRUE(Utils::SizeEqual(defaultImage_, screenSize)); Media::Size halfDefault_ = {defaultImage_.width / 2, defaultImage_.height / 2}; Media::Rect halfRect = {defaultScreen_.left, defaultScreen_.top, halfDefault_.width, halfDefault_.height}; screenshot = dm.GetScreenshot(defaultId_, halfRect, defaultImage_, defaultRot_); ASSERT_NE(nullptr, screenshot); screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqual(defaultImage_, screenSize)); + ASSERT_TRUE(Utils::SizeEqual(defaultImage_, screenSize)); Media::Size halfSize = {halfDefault_.width, halfDefault_.height}; screenshot = dm.GetScreenshot(defaultId_, defaultScreen_, halfSize, defaultRot_); ASSERT_NE(nullptr, screenshot); screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqual(halfSize, screenSize)); + ASSERT_TRUE(Utils::SizeEqual(halfSize, screenSize)); } /** @@ -165,7 +165,7 @@ HWTEST_F(ScreenshotTest, ScreenShotValid06, Function | MediumTest | Level2) defaultImage_, defaultRot_); ASSERT_NE(nullptr, screenshot); Media::Size screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize)); + ASSERT_TRUE(Utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize)); } /** diff --git a/dm/test/unittest/screenshot_test.cpp b/dm/test/unittest/screenshot_test.cpp index 57f50f2c..17da915b 100644 --- a/dm/test/unittest/screenshot_test.cpp +++ b/dm/test/unittest/screenshot_test.cpp @@ -26,7 +26,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = TestUtils; +using Utils = TestUtils; constexpr int32_t TEST_IMAGE_HEIGHT = 1080; constexpr int32_t TEST_IMAGE_WIDTH = 1920; using Mocker = SingletonMocker; diff --git a/dmserver/include/display_manager_service.h b/dmserver/include/display_manager_service.h index 430a002c..1611bbc5 100644 --- a/dmserver/include/display_manager_service.h +++ b/dmserver/include/display_manager_service.h @@ -98,7 +98,7 @@ public: bool SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override; static float GetCustomVirtualPixelRatio(); void RegisterDisplayChangeListener(sptr listener); - void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation); + void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation); private: DisplayManagerService(); ~DisplayManagerService() = default; diff --git a/dmserver/include/display_manager_service_inner.h b/dmserver/include/display_manager_service_inner.h index 90e4d1d2..ed8e6c4f 100644 --- a/dmserver/include/display_manager_service_inner.h +++ b/dmserver/include/display_manager_service_inner.h @@ -46,7 +46,7 @@ public: bool SetOrientationFromWindow(DisplayId displayId, Orientation orientation); bool SetRotationFromWindow(DisplayId displayId, Rotation targetRotation); void SetGravitySensorSubscriptionEnabled(); - void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation); + void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation); }; } // namespace OHOS::Rosen diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index d96c7b09..21153b61 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -133,10 +133,10 @@ void DisplayManagerService::NotifyDisplayStateChange(DisplayId defaultDisplayId, } } -void DisplayManagerService::GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) +void DisplayManagerService::GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) { if (displayChangeListener_ != nullptr) { - displayChangeListener_->OnGetFullScreenWindowRequestedOrientation(displayId, orientation); + displayChangeListener_->OnGetWindowPreferredOrientation(displayId, orientation); } } diff --git a/dmserver/src/display_manager_service_inner.cpp b/dmserver/src/display_manager_service_inner.cpp index 43020920..1d95e999 100644 --- a/dmserver/src/display_manager_service_inner.cpp +++ b/dmserver/src/display_manager_service_inner.cpp @@ -148,9 +148,9 @@ bool DisplayManagerServiceInner::SetRotationFromWindow(DisplayId displayId, Rota SetRotationFromWindow(displayInfo->GetScreenId(), targetRotation); } -void DisplayManagerServiceInner::GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) +void DisplayManagerServiceInner::GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) { - DisplayManagerService::GetInstance().GetFullScreenWindowRequestedOrientation(displayId, orientation); + DisplayManagerService::GetInstance().GetWindowPreferredOrientation(displayId, orientation); } void DisplayManagerServiceInner::SetGravitySensorSubscriptionEnabled() diff --git a/dmserver/src/screen_rotation_controller.cpp b/dmserver/src/screen_rotation_controller.cpp index 140999ba..d4c414fb 100644 --- a/dmserver/src/screen_rotation_controller.cpp +++ b/dmserver/src/screen_rotation_controller.cpp @@ -36,7 +36,7 @@ DisplayId ScreenRotationController::defaultDisplayId_ = 0; bool ScreenRotationController::isGravitySensorSubscribed_ = false; SensorUser ScreenRotationController::user_; Rotation ScreenRotationController::currentDisplayRotation_; -bool ScreenRotationController::isScreenRotationLocked_ = false; +bool ScreenRotationController::isScreenRotationLocked_ = true; long ScreenRotationController::lastCallbackTime_ = 0; uint32_t ScreenRotationController::defaultDeviceRotationOffset_ = 0; Orientation ScreenRotationController::lastOrientationType_ = Orientation::UNSPECIFIED; @@ -55,10 +55,16 @@ void ScreenRotationController::SubscribeGravitySensor() } user_.userData = nullptr; user_.callback = &HandleGravitySensorEventCallback; - SubscribeSensor(SENSOR_TYPE_ID_GRAVITY, &user_); + if (SubscribeSensor(SENSOR_TYPE_ID_GRAVITY, &user_) != 0) { + WLOGFE("Subscribe gravity sensor failed"); + return; + } SetBatch(SENSOR_TYPE_ID_GRAVITY, &user_, ORIENTATION_SENSOR_SAMPLING_RATE, ORIENTATION_SENSOR_REPORTING_RATE); SetMode(SENSOR_TYPE_ID_GRAVITY, &user_, SENSOR_ON_CHANGE); - ActivateSensor(SENSOR_TYPE_ID_GRAVITY, &user_); + if (ActivateSensor(SENSOR_TYPE_ID_GRAVITY, &user_) != 0) { + WLOGFE("Activate gravity sensor failed"); + return; + } isGravitySensorSubscribed_ = true; } @@ -109,6 +115,7 @@ void ScreenRotationController::HandleGravitySensorEventCallback(SensorEvent *eve currentDisplayRotation_ = GetCurrentDisplayRotation(); HandleUnspecifiedOrientation(orientation); if (!IsSensorRelatedOrientation(orientation)) { + lastOrientationType_ = orientation; return; } @@ -128,6 +135,7 @@ void ScreenRotationController::HandleGravitySensorEventCallback(SensorEvent *eve ProcessRotationWhenSensorDataNotValid(orientation); return; } + lastOrientationType_ = orientation; if ((ConvertToDeviceRotation(currentSensorRotation) == currentDisplayRotation_) && (orientation == Orientation::SENSOR || orientation == Orientation::AUTO_ROTATION_RESTRICTED)) { return; @@ -164,7 +172,7 @@ Rotation ScreenRotationController::GetCurrentDisplayRotation() Orientation ScreenRotationController::GetRequestedOrientation() { Orientation orientation = Orientation::UNSPECIFIED; - DisplayManagerServiceInner::GetInstance().GetFullScreenWindowRequestedOrientation(defaultDisplayId_, orientation); + DisplayManagerServiceInner::GetInstance().GetWindowPreferredOrientation(defaultDisplayId_, orientation); return orientation; } @@ -181,6 +189,7 @@ Rotation ScreenRotationController::CalcTargetDisplayRotation( case Orientation::SENSOR_HORIZONTAL: { return ProcessAutoRotationLandscapeOrientation(sensorRotation); } + case Orientation::UNSPECIFIED: case Orientation::AUTO_ROTATION_RESTRICTED: { if (isScreenRotationLocked_) { return currentDisplayRotation_; @@ -260,7 +269,7 @@ Rotation ScreenRotationController::ConvertToDeviceRotation(Rotation sensorRotati bool ScreenRotationController::IsSensorRelatedOrientation(Orientation orientation) { - if ((orientation >= Orientation::BEGIN && orientation <= Orientation::REVERSE_HORIZONTAL) || + if ((orientation >= Orientation::VERTICAL && orientation <= Orientation::REVERSE_HORIZONTAL) || orientation == Orientation::LOCKED) { return false; } @@ -272,7 +281,7 @@ void ScreenRotationController::HandleUnspecifiedOrientation(Orientation orientat if (lastOrientationType_ == orientation) { return; } - if (orientation == Orientation::UNSPECIFIED) { + if (orientation == Orientation::UNSPECIFIED && isScreenRotationLocked_) { SetScreenRotation(Rotation::ROTATION_0); lastOrientationType_ = orientation; } diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index cc4b6510..54cbe6f2 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -169,7 +169,9 @@ public: virtual WMError SetWindowType(WindowType type) = 0; virtual WMError SetWindowMode(WindowMode mode) = 0; virtual WMError SetWindowBackgroundBlur(WindowBlurLevel level) = 0; - virtual WMError SetAlpha(float alpha) = 0; + virtual void SetAlpha(float alpha) = 0; + virtual void SetTransform(const Transform& trans) = 0; + virtual Transform GetTransform() const = 0; virtual WMError AddWindowFlag(WindowFlag flag) = 0; virtual WMError RemoveWindowFlag(WindowFlag flag) = 0; virtual WMError SetWindowFlags(uint32_t flags) = 0; @@ -178,8 +180,8 @@ public: virtual WMError SetLayoutFullScreen(bool status) = 0; virtual WMError SetFullScreen(bool status) = 0; virtual WMError Destroy() = 0; - virtual WMError Show(uint32_t reason = 0) = 0; - virtual WMError Hide(uint32_t reason = 0) = 0; + virtual WMError Show(uint32_t reason = 0, bool isCustomAnimation = false) = 0; + virtual WMError Hide(uint32_t reason = 0, bool isCustomAnimation = false) = 0; virtual WMError MoveTo(int32_t x, int32_t y) = 0; virtual WMError Resize(uint32_t width, uint32_t height) = 0; @@ -230,8 +232,8 @@ public: virtual void OnNewWant(const AAFwk::Want& want) = 0; virtual void SetRequestedOrientation(Orientation) = 0; virtual Orientation GetRequestedOrientation() = 0; - virtual void SetModeSupportInfo(uint32_t modeSupportInfo) = 0; - virtual uint32_t GetModeSupportInfo() const = 0; + virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) = 0; + virtual uint32_t GetRequestModeSupportInfo() const = 0; virtual WMError SetTouchHotAreas(const std::vector& rects) = 0; virtual void GetRequestedTouchHotAreas(std::vector& rects) const = 0; diff --git a/interfaces/innerkits/wm/window_option.h b/interfaces/innerkits/wm/window_option.h index fb2dd7ed..83dffb17 100644 --- a/interfaces/innerkits/wm/window_option.h +++ b/interfaces/innerkits/wm/window_option.h @@ -33,7 +33,6 @@ public: void SetWindowType(WindowType type); void SetWindowMode(WindowMode mode); void SetWindowBackgroundBlur(WindowBlurLevel level); - void SetAlpha(float alpha); void SetFocusable(bool isFocusable); void SetTouchable(bool isTouchable); void SetDisplayId(DisplayId displayId); @@ -58,7 +57,6 @@ public: WindowType GetWindowType() const; WindowMode GetWindowMode() const; WindowBlurLevel GetWindowBackgroundBlur() const; - float GetAlpha() const; bool GetFocusable() const; bool GetTouchable() const; DisplayId GetDisplayId() const; @@ -75,7 +73,6 @@ private: WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; WindowMode mode_ { WindowMode::WINDOW_MODE_FULLSCREEN }; WindowBlurLevel level_ { WindowBlurLevel::WINDOW_BLUR_OFF }; - float alpha_ { 1.0f }; bool focusable_ { true }; bool touchable_ { true }; DisplayId displayId_ { 0 }; diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index bf4a8ccf..958e12da 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -43,7 +43,7 @@ enum class WindowType : uint32_t { ABOVE_APP_SYSTEM_WINDOW_BASE = 2100, WINDOW_TYPE_APP_LAUNCHING = ABOVE_APP_SYSTEM_WINDOW_BASE, WINDOW_TYPE_DOCK_SLICE, - WINDOW_TYPE_PLACE_HOLDER, + WINDOW_TYPE_PLACEHOLDER, WINDOW_TYPE_INCOMING_CALL, WINDOW_TYPE_SEARCHING_BAR, WINDOW_TYPE_SYSTEM_ALARM_WINDOW, @@ -173,6 +173,25 @@ namespace { constexpr int32_t INVALID_UID = -1; } +class Transform { +public: + Transform() + : pivotX_(0.5f), pivotY_(0.5f), scaleX_(1.f), scaleY_(1.f), rotationX_(0.f), rotationY_(0.f), rotationZ_(0.f), + translateX_(0.f), translateY_(0.f), translateZ_(0.f) + {} + ~Transform() {} + float pivotX_; + float pivotY_; + float scaleX_; + float scaleY_; + float rotationX_; + float rotationY_; + float rotationZ_; + float translateX_; + float translateY_; + float translateZ_; +}; + struct SystemBarProperty { bool enable_; uint32_t backgroundColor_; @@ -298,6 +317,7 @@ enum class WindowUpdateType : int32_t { WINDOW_UPDATE_FOCUSED, WINDOW_UPDATE_BOUNDS, WINDOW_UPDATE_ACTIVE, + WINDOW_UPDATE_PROPERTY, }; struct SystemConfig { diff --git a/interfaces/kits/napi/window_runtime/BUILD.gn b/interfaces/kits/napi/window_runtime/BUILD.gn index 2d3c1a75..c06c8e0a 100644 --- a/interfaces/kits/napi/window_runtime/BUILD.gn +++ b/interfaces/kits/napi/window_runtime/BUILD.gn @@ -50,6 +50,7 @@ ohos_shared_library("window_native_kit") { configs = [ ":window_native_kit_config" ] deps = [ + "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", "//foundation/windowmanager/utils:libwmutil", "//foundation/windowmanager/wm:libwm", "//foundation/windowmanager/wmserver:libwms", diff --git a/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts b/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts index dfd3821b..55fe7e34 100644 --- a/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts +++ b/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts @@ -91,6 +91,82 @@ declare namespace window { */ TYPE_KEYBOARD } + + /** + * Describes the scale Transition Options of window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @systemapi + */ + declare interface ScaleOptions { + /** + * The scale param of x direction. Default is 1.f + */ + x?: number; + /** + * The scale param of y direction. Default is 1.f + */ + y?: number; + /** + * The scale param of pivot point of x. Default is 0.5f, Interval is 0.f - 1.f + */ + pivotX?: number; + /** + * The scale param of pivot point of y. Default is 0.5f, Interval is 0.f - 1.f + */ + pivotY?: number; + } + + /** + * Describes the rotate Transition Options of window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @systemapi + */ + declare interface RotateOptions { + /** + * The rotate degree of x direction. Default value is 0.f + */ + x?: number; + /** + * The rotate degree of y direction. Default value is 0.f + */ + y?: number; + /** + * The rotate degree of z direction. Default value is 0.f + */ + z?: number; + /** + * The param of pivot point of x. Default is 0.5f, Interval is 0.f - 1.f + */ + pivotX?: number; + /** + * The param of pivot point of y. Default is 0.5f, Interval is 0.f - 1.f + */ + pivotY?: number; + } + + /** + * Describes the translate Transition Options of window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @systemapi + */ + declare interface TranslateOptions { + /** + * The translate pixel param of x direction. Default is 0.f + */ + x?: number; + /** + * The translate pixel param of y direction. Default is 0.f + */ + y?: number; + /** + * The translate pixel param of z direction. Default is 0.f + */ + z?: number; + } + /** * Describes the window mode of an application * @systemapi Hide this for inner system use. @@ -961,7 +1037,7 @@ declare namespace window { * @since 9 */ setPreferredOrientation(orientation: Orientation, callback: AsyncCallback): void; - + /** * disable window decoration. It must be called before loadContent. * @systemapi @@ -985,7 +1061,7 @@ declare namespace window { * @systemapi * @since 9 */ - setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback): void; + setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback): void; /** * set the flag of the window is forbidden to move in split screen mode @@ -994,7 +1070,35 @@ declare namespace window { * @systemapi * @since 9 */ - setForbidSplitMove(isForbidSplitMove: boolean): Promise; + setForbidSplitMove(isForbidSplitMove: boolean): Promise; + /** + * Sets opacity of window + * @param opacity Interval is 0.f-1.f. + * @systemapi + * @since 9 + */ + setOpacitySync(opacity: number): void; + /** + * Sets scale options of window. + * @param scaleOptions scale param of window. + * @systemapi + * @since 9 + */ + setScaleSync(scaleOptions: ScaleOptions): void; + /** + * Sets rotate options of window. + * @param rotateOptions rotate param of window. + * @systemapi + * @since 9 + */ + setRotateSync(rotateOptions: RotateOptions): void; + /** + * Sets whether is transparent or not. + * @param translateOptions translate param of window. + * @systemapi + * @since 9 + */ + setTranslateSync(translateOptions: TranslateOptions): void; } enum WindowStageEventType { diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index a2df4b41..cb8148f0 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -15,8 +15,10 @@ #include "js_window.h" #include +#include #include "js_window_utils.h" #include "window.h" +#include "window_helper.h" #include "window_manager_hilog.h" #include "window_option.h" namespace OHOS { @@ -29,24 +31,28 @@ namespace { static thread_local std::map> g_jsWindowMap; std::recursive_mutex g_mutex; +static int ctorCnt = 0; +static int dtorCnt = 0; +static int finalizerCnt = 0; JsWindow::JsWindow(const sptr& window) : windowToken_(window), registerManager_(std::make_unique()) { NotifyNativeWinDestroyFunc func = [](std::string windowName) { std::lock_guard lock(g_mutex); if (windowName.empty() || g_jsWindowMap.count(windowName) == 0) { - WLOGE("[NAPI]Can not find window %{public}s ", windowName.c_str()); + WLOGFE("[NAPI]Can not find window %{public}s ", windowName.c_str()); return; } g_jsWindowMap.erase(windowName); - WLOGE("[NAPI]Destroy window %{public}s in js window", windowName.c_str()); + WLOGFI("[NAPI]Destroy window %{public}s in js window", windowName.c_str()); }; windowToken_->RegisterWindowDestroyedListener(func); + WLOGFI("[NAPI] JsWindow constructor Count: %{public}d", ++ctorCnt); } JsWindow::~JsWindow() { - WLOGFI("[NAPI]~JsWindow"); + WLOGFI("[NAPI]~JsWindow deconstructor Count:%{public}d", ++dtorCnt); windowToken_ = nullptr; } @@ -60,7 +66,7 @@ std::string JsWindow::GetWindowName() void JsWindow::Finalizer(NativeEngine* engine, void* data, void* hint) { - WLOGFI("[NAPI]Finalizer"); + WLOGFI("[NAPI]Finalizer Count:%{public}d", ++finalizerCnt); auto jsWin = std::unique_ptr(static_cast(data)); if (jsWin == nullptr) { WLOGFE("[NAPI]jsWin is nullptr"); @@ -313,6 +319,34 @@ NativeValue* JsWindow::SetForbidSplitMove(NativeEngine* engine, NativeCallbackIn return (me != nullptr) ? me->OnSetForbidSplitMove(*engine, *info) : nullptr; } +NativeValue* JsWindow::SetOpacitySync(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("[NAPI]SetOpacitySync"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetOpacitySync(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::SetScaleSync(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("[NAPI]SetScaleSync"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetScaleSync(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::SetRotateSync(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("[NAPI]SetRotateSync"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetRotateSync(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::SetTranslateSync(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("[NAPI]SetTranslateSync"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetTranslateSync(*engine, *info) : nullptr; +} + NativeValue* JsWindow::OnShow(NativeEngine& engine, NativeCallbackInfo& info) { WMError errCode = WMError::WM_OK; @@ -1643,6 +1677,199 @@ NativeValue* JsWindow::OnSetForbidSplitMove(NativeEngine& engine, NativeCallback return result; } +NativeValue* JsWindow::OnSetOpacitySync(NativeEngine& engine, NativeCallbackInfo& info) +{ + if (info.argc != 1 || windowToken_ == nullptr) { + WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc); + return engine.CreateUndefined(); + } + if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) { + WLOGFE("[NAPI]SetOpacitySync is not allowed since window is not system window"); + return engine.CreateUndefined(); + } + NativeNumber* nativeVal = ConvertNativeValueTo(info.argv[0]); + if (nativeVal == nullptr) { + WLOGFE("[NAPI]Failed to convert parameter to alpha"); + return engine.CreateUndefined(); + } + float alpha = static_cast(*nativeVal); + windowToken_->SetAlpha(alpha); + WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetOpacitySync end, alpha = %{public}f", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), alpha); + return engine.CreateUndefined(); +} + +bool JsWindow::ParseScaleOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans) +{ + auto surfaceNode = windowToken_->GetSurfaceNode(); + if (surfaceNode == nullptr) { + WLOGFE("[NAPI] surfaceNode is nullptr"); + return false; + } + double data = 0.0f; + if (ParseJsDoubleValue(jsObject, engine, "pivotX", data)) { + surfaceNode->SetPivotX(data); + trans.pivotX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "pivotY", data)) { + surfaceNode->SetPivotY(data); + trans.pivotY_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "x", data)) { + surfaceNode->SetScaleX(data); + trans.scaleX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "y", data)) { + surfaceNode->SetScaleY(data); + trans.scaleY_ = data; + } + return true; +} + +NativeValue* JsWindow::OnSetScaleSync(NativeEngine& engine, NativeCallbackInfo& info) +{ + if (info.argc != 1 || windowToken_ == nullptr) { + WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc); + return engine.CreateUndefined(); + } + if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) { + WLOGFE("[NAPI]SetScaleSync is not allowed since window is not system window"); + return engine.CreateUndefined(); + } + NativeObject* nativeObj = ConvertNativeValueTo(info.argv[0]); + if (nativeObj == nullptr) { + WLOGFE("[NAPI]Failed to convert object to ScaleOptions"); + return engine.CreateUndefined(); + } + auto trans = windowToken_->GetTransform(); + if (!ParseScaleOption(engine, nativeObj, trans)) { + return engine.CreateUndefined(); + } + windowToken_->SetTransform(trans); + WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetScaleSync end", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str()); + WLOGFI("[NAPI]scaleX = %{public}f, scaleY = %{public}f, pivotX = %{public}f pivotY = %{public}f", + trans.scaleX_, trans.scaleY_, trans.pivotX_, trans.pivotY_); + return engine.CreateUndefined(); +} + +bool JsWindow::ParseRotateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans) +{ + auto surfaceNode = windowToken_->GetSurfaceNode(); + if (surfaceNode == nullptr) { + WLOGFE("[NAPI] surfaceNode is nullptr"); + return false; + } + double data = 0.0f; + if (ParseJsDoubleValue(jsObject, engine, "pivotX", data)) { + surfaceNode->SetPivotX(data); + trans.pivotX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "pivotY", data)) { + surfaceNode->SetPivotY(data); + trans.pivotY_ = data; + } + double coeff = 0.5 * 3.14 / 180; // 0.5 means half; 3.14 means pi; 180 means degree + if (ParseJsDoubleValue(jsObject, engine, "x", data)) { + float w = std::cos(data * coeff); + float x = std::sin(data * coeff); + surfaceNode->SetRotation(Quaternion(x, 0, 0, w)); + trans.rotationX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "y", data)) { + float w = std::cos(data * coeff); + float y = std::sin(data * coeff); + surfaceNode->SetRotation(Quaternion(0, y, 0, w)); + trans.rotationY_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "z", data)) { + float w = std::cos(data * coeff); + float z = std::sin(data * coeff); + surfaceNode->SetRotation(Quaternion(0, 0, z, w)); + trans.rotationZ_ = data; + } + return true; +} + +NativeValue* JsWindow::OnSetRotateSync(NativeEngine& engine, NativeCallbackInfo& info) +{ + if (info.argc != 1 || windowToken_ == nullptr) { + WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc); + return engine.CreateUndefined(); + } + if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) { + WLOGFE("[NAPI]SetRotateSync is not allowed since window is not system window"); + return engine.CreateUndefined(); + } + NativeObject* nativeObj = ConvertNativeValueTo(info.argv[0]); + if (nativeObj == nullptr) { + WLOGFE("[NAPI]Failed to convert object to RotateOptions"); + return engine.CreateUndefined(); + } + // cannot use sync task since next transform base on current transform + auto trans = windowToken_->GetTransform(); + if (!ParseRotateOption(engine, nativeObj, trans)) { + return engine.CreateUndefined(); + } + windowToken_->SetTransform(trans); + WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetRotateSync end", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str()); + WLOGFI("[NAPI]rotateX = %{public}f, rotateY = %{public}f," \ + "rotateZ = %{public}f pivotX = %{public}f pivotY = %{public}f", + trans.rotationX_, trans.rotationY_, trans.rotationZ_, trans.pivotX_, trans.pivotY_); + return engine.CreateUndefined(); +} + +bool JsWindow::ParseTranslateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans) +{ + auto surfaceNode = windowToken_->GetSurfaceNode(); + if (surfaceNode == nullptr) { + WLOGFE("[NAPI] surfaceNode is nullptr"); + return false; + } + double data = 0.0f; + if (ParseJsDoubleValue(jsObject, engine, "x", data)) { + surfaceNode->SetTranslateX(data); + trans.translateX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "y", data)) { + surfaceNode->SetTranslateY(data); + trans.translateY_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "z", data)) { + surfaceNode->SetTranslateZ(data); + trans.translateZ_ = data; + } + return true; +} + +NativeValue* JsWindow::OnSetTranslateSync(NativeEngine& engine, NativeCallbackInfo& info) +{ + if (info.argc != 1 || windowToken_ == nullptr) { + WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc); + return engine.CreateUndefined(); + } + if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) { + WLOGFE("[NAPI]SetTranslateSync is not allowed since window is not system window"); + return engine.CreateUndefined(); + } + NativeObject* nativeObj = ConvertNativeValueTo(info.argv[0]); + if (nativeObj == nullptr) { + WLOGFE("[NAPI]Failed to convert object to TranslateOptions"); + return engine.CreateUndefined(); + } + auto trans = windowToken_->GetTransform(); + if (!ParseTranslateOption(engine, nativeObj, trans)) { + return engine.CreateUndefined(); + } + windowToken_->SetTransform(trans); + WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetRotateSync end," \ + "translateX = %{public}f, translateY = %{public}f, translateZ = %{public}f", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), + trans.translateX_, trans.translateY_, trans.translateZ_); + return engine.CreateUndefined(); +} + std::shared_ptr FindJsWindowObject(std::string windowName) { WLOGFI("[NAPI]Try to find window %{public}s in g_jsWindowMap", windowName.c_str()); @@ -1716,6 +1943,10 @@ void BindFunctions(NativeEngine& engine, NativeObject* object) BindNativeFunction(engine, *object, "dump", JsWindow::Dump); BindNativeFunction(engine, *object, "setForbidSplitMove", JsWindow::SetForbidSplitMove); BindNativeFunction(engine, *object, "setPreferredOrientation", JsWindow::SetPreferredOrientation); + BindNativeFunction(engine, *object, "setOpacitySync", JsWindow::SetOpacitySync); + BindNativeFunction(engine, *object, "setScaleSync", JsWindow::SetScaleSync); + BindNativeFunction(engine, *object, "setRotateSync", JsWindow::SetRotateSync); + BindNativeFunction(engine, *object, "setTranslateSync", JsWindow::SetTranslateSync); } } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 6a83610f..e6c2296f 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -69,8 +69,16 @@ public: static NativeValue* Dump(NativeEngine* engine, NativeCallbackInfo* info); static NativeValue* SetForbidSplitMove(NativeEngine* engine, NativeCallbackInfo* info); + // animation config + static NativeValue* SetOpacitySync(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* SetScaleSync(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* SetRotateSync(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* SetTranslateSync(NativeEngine* engine, NativeCallbackInfo* info); private: std::string GetWindowName(); + bool ParseScaleOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans); + bool ParseRotateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans); + bool ParseTranslateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans); NativeValue* OnShow(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnDestroy(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnHide(NativeEngine& engine, NativeCallbackInfo& info); @@ -108,6 +116,11 @@ private: NativeValue* OnDump(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnSetForbidSplitMove(NativeEngine& engine, NativeCallbackInfo& info); + // animation Config + NativeValue* OnSetOpacitySync(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnSetScaleSync(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnSetRotateSync(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnSetTranslateSync(NativeEngine& engine, NativeCallbackInfo& info); sptr windowToken_ = nullptr; std::unique_ptr registerManager_ = nullptr; }; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index cdbc05b4..926627e3 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -15,6 +15,7 @@ #include "js_window_listener.h" #include "js_runtime_utils.h" #include "window_manager_hilog.h" + namespace OHOS { namespace Rosen { using namespace AbilityRuntime; @@ -47,7 +48,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason) WLOGFI("[NAPI]OnSizeChange, wh[%{public}u, %{public}u], reason = %{public}u", rect.width_, rect.height_, reason); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( - [self = wptr(this), rect, eng = engine_] (NativeEngine &engine, + [self = weakRef_, rect, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -83,7 +84,7 @@ void JsWindowListener::OnSystemBarPropertyChange(DisplayId displayId, const Syst WLOGFI("[NAPI]OnSystemBarPropertyChange"); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( - [self = wptr(this), displayId, tints, eng = engine_] (NativeEngine &engine, + [self = weakRef_, displayId, tints, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -114,7 +115,7 @@ void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaTy WLOGFI("[NAPI]OnAvoidAreaChanged"); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( - [self = wptr(this), avoidArea, type, eng = engine_] (NativeEngine &engine, + [self = weakRef_, avoidArea, type, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -145,7 +146,7 @@ void JsWindowListener::LifeCycleCallBack(LifeCycleEventType eventType) { WLOGFI("[NAPI]LifeCycleCallBack, envent type: %{public}u", eventType); std::unique_ptr complete = std::make_unique( - [self = wptr(this), eventType, eng = engine_] (NativeEngine &engine, + [self = weakRef_, eventType, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -189,7 +190,7 @@ void JsWindowListener::OnSizeChange(const sptr& info) info->rect_.posX_, info->rect_.posY_, info->rect_.width_, info->rect_.height_); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( - [self = wptr(this), info, eng = engine_] (NativeEngine &engine, + [self = weakRef_, info, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -210,7 +211,7 @@ void JsWindowListener::OnSizeChange(const sptr& info) void JsWindowListener::OnTouchOutside() { std::unique_ptr complete = std::make_unique ( - [self = wptr(this)] (NativeEngine &engine, AsyncTask &task, int32_t status) { + [self = weakRef_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr) { WLOGFE("[NAPI]this listener is nullptr"); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h index 8a39f121..e1d59458 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h @@ -47,7 +47,7 @@ class JsWindowListener : public IWindowChangeListener, public ITouchOutsideListener { public: JsWindowListener(NativeEngine* engine, std::shared_ptr callback) - : engine_(engine), jsCallBack_(callback) {} + : engine_(engine), jsCallBack_(callback), weakRef_(wptr (this)) {} ~JsWindowListener(); void OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) override; void OnSizeChange(Rect rect, WindowSizeChangeReason reason) override; @@ -64,6 +64,7 @@ private: void LifeCycleCallBack(LifeCycleEventType eventType); NativeEngine* engine_ = nullptr; std::shared_ptr jsCallBack_ = nullptr; + wptr weakRef_ = nullptr; DEFINE_VAR_DEFAULT_FUNC_SET(bool, IsDeprecatedInterface, isDeprecatedInterface, false) }; } // namespace Rosen diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 9253f519..7baa240e 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -484,5 +484,20 @@ bool GetAPI7Ability(NativeEngine& engine, AppExecFwk::Ability* &ability) } return true; } + +bool ParseJsDoubleValue(NativeObject* jsObject, NativeEngine& engine, const std::string& name, double data) +{ + NativeValue* value = jsObject->GetProperty(name.c_str()); + if (value->TypeOf() != NATIVE_UNDEFINED) { + if (!ConvertFromJsValue(engine, value, data)) { + WLOGFE("[NAPI]Failed to convert parameter to scale %{public}s", name.c_str()); + return false; + } + } else { + WLOGFI("[NAPI]no property with: %{public}s", name.c_str()); + return false; + } + return true; +} } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 4765a8ad..b8c5c77a 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -165,6 +165,7 @@ const std::map JS_TO_NATIVE_ORIENTATION_MAP { NativeValue* WindowStageEventTypeInit(NativeEngine* engine); NativeValue* WindowLayoutModeInit(NativeEngine* engine); bool GetAPI7Ability(NativeEngine& engine, AppExecFwk::Ability* &ability); + bool ParseJsDoubleValue(NativeObject* jsObject, NativeEngine& engine, const std::string& name, double data); template inline bool ConvertNativeValueToVector(NativeEngine& engine, NativeValue* nativeValue, std::vector& out) { diff --git a/resources/config/rk3568/window_manager_config.xml b/resources/config/rk3568/window_manager_config.xml index 9c11c5a9..a0489639 100644 --- a/resources/config/rk3568/window_manager_config.xml +++ b/resources/config/rk3568/window_manager_config.xml @@ -25,7 +25,7 @@ - 0.1 0.9 + 0.1 0.9 0.5 0.33 0.67 \ No newline at end of file diff --git a/resources/dialog_ui/divider_dialog_ui/js/pages/index/index.hml b/resources/dialog_ui/divider_dialog_ui/js/pages/index/index.hml index 3668bde1..25f53f0a 100644 --- a/resources/dialog_ui/divider_dialog_ui/js/pages/index/index.hml +++ b/resources/dialog_ui/divider_dialog_ui/js/pages/index/index.hml @@ -15,9 +15,8 @@ */ --> -
-
diff --git a/resources/dialog_ui/divider_dialog_ui/js/pages/index/index.js b/resources/dialog_ui/divider_dialog_ui/js/pages/index/index.js index 6ba3538c..7abba589 100644 --- a/resources/dialog_ui/divider_dialog_ui/js/pages/index/index.js +++ b/resources/dialog_ui/divider_dialog_ui/js/pages/index/index.js @@ -13,37 +13,11 @@ limitations under the License. */ -import router from '@ohos.router' -import window from '@ohos.window'; - export default { data: { backgroundColor:"black" }, - onInit() { - callNativeHandler("EVENT_INIT", ""); - }, - onCancel() { - callNativeHandler("EVENT_CANCEL", ""); - }, - onExit() { - callNativeHandler("EVENT_CANCEL", ""); - }, - onExchange() { - }, onExchangeDoubleClick() { console.info('double click exchange'); - }, - onFocus(){ - this.backgroundColor = "black" - }, - recoveryColor(){ - this.backgroundColor = "gray" - }, - onTouching(){ - this.backgroundColor = "gray" - }, - onTouchEnd(){ - this.backgroundColor = "black" } } \ No newline at end of file diff --git a/resources/media/BUILD.gn b/resources/media/BUILD.gn index 6d152d78..adcc1a02 100644 --- a/resources/media/BUILD.gn +++ b/resources/media/BUILD.gn @@ -26,9 +26,9 @@ ohos_prebuilt_etc("window_place_holder_image") { relative_install_dir = "window/resources" } - group("window_resources_media") { - deps = [ ":window_divider_image", - ":window_place_holder_image" - ] + deps = [ + ":window_divider_image", + ":window_place_holder_image", + ] } diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 92a89935..6c867581 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -45,7 +45,6 @@ ohos_shared_library("libwmutil") { "src/window_property.cpp", "src/window_transition_info.cpp", "src/wm_trace.cpp", - "src/draw_surface.cpp" ] configs = [ ":libwmutil_private_config" ] @@ -53,9 +52,9 @@ ohos_shared_library("libwmutil") { public_configs = [ ":libwmutil_public_config" ] deps = [ + "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics", "//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base", "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", - "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics", "//third_party/flutter/build/skia:ace_skia_ohos", ] diff --git a/utils/include/display_change_listener.h b/utils/include/display_change_listener.h index 62a5a8d2..abd0c7af 100644 --- a/utils/include/display_change_listener.h +++ b/utils/include/display_change_listener.h @@ -35,7 +35,7 @@ class IDisplayChangeListener : public RefBase { public: virtual void OnDisplayStateChange(DisplayId defaultDisplayId, sptr info, const std::map>& displayInfoMap, DisplayStateChangeType type) = 0; - virtual void OnGetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) = 0; + virtual void OnGetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) = 0; }; } } diff --git a/utils/include/draw_surface.h b/utils/include/draw_surface.h deleted file mode 100644 index 1dd19395..00000000 --- a/utils/include/draw_surface.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2022-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DRAW_SURFACE_H -#define DRAW_SURFACE_H - -#include "draw/canvas.h" -#include "nocopyable.h" -#include "pixel_map.h" -#include "refbase.h" -#include "ui/rs_surface_node.h" -#include "wm_common.h" -#include "window.h" - -namespace OHOS { -namespace Rosen { -class DrawSurface { -public: - ~DrawSurface() = default; - static bool DrawColor(std::shared_ptr surfaceNode, int32_t bufferWidth, - int32_t bufferHeight, uint32_t color); - static bool DrawImage(std::shared_ptr surfaceNode, int32_t bufferWidth, - int32_t bufferHeight,const std::string& imagePath); -private: - DrawSurface() {}; - static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath); - static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color); - static sptr GetLayer(std::shared_ptr surfaceNode); - static sptr GetSurfaceBuffer(sptr layer, - int32_t bufferWidth, int32_t bufferHeight); - static void DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath); - static std::unique_ptr DecodeImageToPixelMap(const std::string &imagePath); -}; -} // Rosen -} // OHOS -#endif // DRAW_SURFACE_H \ No newline at end of file diff --git a/utils/include/surface_draw.h b/utils/include/surface_draw.h index f44ac6e5..da7a8ceb 100644 --- a/utils/include/surface_draw.h +++ b/utils/include/surface_draw.h @@ -18,9 +18,7 @@ #include #include "pixel_map.h" -#ifdef ACE_ENABLE_GL -#include "render_context/render_context.h" -#endif + #include "refbase.h" #include "wm_common.h" #include "draw/canvas.h" @@ -33,21 +31,14 @@ class SurfaceDraw { public: SurfaceDraw() = default; ~SurfaceDraw() = default; - void Init(); - void DrawBackgroundColor(std::shared_ptr surfaceNode, Rect winRect, uint32_t bkgColor); - void DrawBitmap(std::shared_ptr surfaceNode, Rect winRect, - SkBitmap& bitmap, uint32_t bkgColor); - bool DecodeImageFile(const char* filename, SkBitmap& bitmap); - void DrawSkImage(std::shared_ptr surfaceNode, Rect winRect, - sptr pixelMap, uint32_t bkgColor); static bool DrawColor(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, uint32_t color); static bool DrawImage(std::shared_ptr surfaceNode, int32_t bufferWidth, - int32_t bufferHeight,const std::string& imagePath); -private: + int32_t bufferHeight, const std::string& imagePath); + static bool DrawImageRect(std::shared_ptr surfaceNode, Rect winRect, + sptr pixelMap, uint32_t bkgColor); - std::shared_ptr PrepareDraw(std::shared_ptr surfaceNode, - std::unique_ptr& frame, SkCanvas*& canvas, uint32_t width, uint32_t height); +private: static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath); static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color); static sptr GetLayer(std::shared_ptr surfaceNode); @@ -55,10 +46,8 @@ private: int32_t bufferWidth, int32_t bufferHeight); static void DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath); static std::unique_ptr DecodeImageToPixelMap(const std::string &imagePath); - -#ifdef ACE_ENABLE_GL - std::unique_ptr rc_ = nullptr; -#endif + static bool DoDrawImageRect(uint8_t *addr, int32_t winWidth, int32_t winHeight, sptr pixelMap, + uint32_t color); }; } // Rosen } // OHOS diff --git a/utils/include/window_helper.h b/utils/include/window_helper.h index f1653100..c879ce70 100644 --- a/utils/include/window_helper.h +++ b/utils/include/window_helper.h @@ -332,6 +332,30 @@ public: return isOk; } + static bool IsRectSatisfiedWithSizeLimits(const Rect& rect, const WindowSizeLimits& sizeLimits) + { + if (rect.height_ == 0) { + return false; + } + auto curRatio = static_cast(rect.width_) / static_cast(rect.height_); + if (sizeLimits.minWidth_ <= rect.width_ && rect.width_ <= sizeLimits.maxWidth_ && + sizeLimits.minHeight_ <= rect.height_ && rect.height_ <= sizeLimits.maxHeight_ && + sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_) { + return true; + } + return false; + } + + static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t modeSupportInfo) + { + uint32_t splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + if (isShowWhenLocked && (splitModeInfo == modeSupportInfo)) { + return true; + } + return false; + } + private: WindowHelper() = default; ~WindowHelper() = default; diff --git a/utils/include/window_property.h b/utils/include/window_property.h index 7aec8721..9244d2e0 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -19,8 +19,7 @@ #include #include #include -#include "parcel.h" - +#include #include "class_var_definition.h" #include "dm_common.h" #include "wm_common.h" @@ -68,12 +67,15 @@ public: void SetWindowSizeChangeReason(WindowSizeChangeReason reason); void SetTokenState(bool hasToken); void SetModeSupportInfo(uint32_t modeSupportInfo); + void SetRequestModeSupportInfo(uint32_t requestModeSupportInfo); void SetDragType(DragType dragType); void SetStretchable(bool stretchable); void SetOriginRect(const Rect& rect); void SetTouchHotAreas(const std::vector& rects); void SetAccessTokenId(uint32_t accessTokenId); + void SetSizeLimits(const WindowSizeLimits& sizeLimits); WindowSizeChangeReason GetWindowSizeChangeReason() const; + void SetTransform(const Transform& trans); const std::string& GetWindowName() const; Rect GetRequestRect() const; @@ -104,11 +106,14 @@ public: const PointInfo& GetHitOffset() const; uint32_t GetAnimationFlag() const; uint32_t GetModeSupportInfo() const; + uint32_t GetRequestModeSupportInfo() const; DragType GetDragType() const; bool GetStretchable() const; const Rect& GetOriginRect() const; void GetTouchHotAreas(std::vector& rects) const; uint32_t GetAccessTokenId() const; + Transform GetTransform() const; + WindowSizeLimits GetSizeLimits() const; virtual bool Marshalling(Parcel& parcel) const override; static WindowProperty* Unmarshalling(Parcel& parcel); @@ -120,6 +125,10 @@ private: static void MapUnmarshalling(Parcel& parcel, WindowProperty* property); bool MarshallingTouchHotAreas(Parcel& parcel) const; static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowProperty* property); + bool MarshallingTransform(Parcel& parcel) const; + static void UnmarshallingTransform(Parcel& parcel, WindowProperty* property); + bool MarshallingWindowSizeLimits(Parcel& parcel) const; + static void UnmarshallingWindowSizeLimits(Parcel& parcel, WindowProperty* property); std::string windowName_; Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size) @@ -146,7 +155,10 @@ private: uint32_t parentId_ { 0 }; PointInfo hitOffset_ { 0, 0 }; uint32_t animationFlag_ { static_cast(WindowAnimation::DEFAULT) }; + // modeSupportInfo_ means supported modes in runtime, which can be changed uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; + // requestModeSupportInfo_ is configured in abilityInfo, usually can't be changed + uint32_t requestModeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED; std::unordered_map sysBarPropMap_ { { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() }, @@ -158,7 +170,10 @@ private: DragType dragType_ = DragType::DRAG_UNDEFINED; std::vector touchHotAreas_; // coordinates relative to window. uint32_t accessTokenId_ { 0 }; + Transform trans_; DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED); + DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, CustomAnimation, isCustomAnimation, false); + WindowSizeLimits sizeLimits_; }; } } diff --git a/utils/include/window_transition_info.h b/utils/include/window_transition_info.h index 3d4de65c..ad959acf 100644 --- a/utils/include/window_transition_info.h +++ b/utils/include/window_transition_info.h @@ -52,6 +52,8 @@ public: void SetWindowType(WindowType windowType); WindowType GetWindowType(); void SetShowFlagWhenLocked(bool isShow); + void SetWindowSupportModes(const std::vector supportModes); + std::vector GetWindowSupportModes(); bool GetShowFlagWhenLocked(); void SetTransitionReason(TransitionReason reason); TransitionReason GetTransitionReason(); @@ -68,6 +70,7 @@ private: bool isShowWhenLocked_ = false; bool isRecent_ = false; TransitionReason reason_ = TransitionReason::ABILITY_TRANSITION; + std::vector supportWindowModes_; }; } // Rosen } // OHOS diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index 2e95688c..ef0c164d 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -16,6 +16,7 @@ #ifndef OHOS_ROSEN_WM_COMMON_INNER_H #define OHOS_ROSEN_WM_COMMON_INNER_H +#include #include #include "wm_common.h" @@ -84,6 +85,7 @@ enum class PropertyChangeAction : uint32_t { ACTION_UPDATE_SET_BRIGHTNESS = 1 << 10, ACTION_UPDATE_MODE_SUPPORT_INFO = 1 << 11, ACTION_UPDATE_TOUCH_HOT_AREA = 1 << 12, + ACTION_UPDATE_TRANSFORM_PROPERTY = 1 << 13, }; struct ModeChangeHotZonesConfig { @@ -93,16 +95,19 @@ struct ModeChangeHotZonesConfig { uint32_t secondaryRange_; }; -struct FloatingWindowLimitsConfig { - bool isFloatingWindowLimitsConfigured_; +struct WindowSizeLimits { uint32_t maxWidth_; uint32_t maxHeight_; uint32_t minWidth_; uint32_t minHeight_; float maxRatio_; float minRatio_; - FloatingWindowLimitsConfig() : isFloatingWindowLimitsConfigured_(false), maxWidth_(0), maxHeight_(0), minWidth_(0), - minHeight_(0), maxRatio_(0.0f), minRatio_(0.0f) {} + WindowSizeLimits() : maxWidth_(UINT32_MAX), maxHeight_(UINT32_MAX), minWidth_(0), + minHeight_(0), maxRatio_(FLT_MAX), minRatio_(0.0f) {} + WindowSizeLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth, + uint32_t minHeight, float maxRatio, float minRatio) + : maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth), + minHeight_(minHeight), maxRatio_(maxRatio), minRatio_(minRatio) {} }; struct ModeChangeHotZones { @@ -135,6 +140,7 @@ enum class TraceTaskId : int32_t { namespace { constexpr float DEFAULT_SPLIT_RATIO = 0.5; constexpr float DEFAULT_ASPECT_RATIO = 0.66; + constexpr int32_t IVALID_DIALOG_WINDOW_ID = -1; constexpr uint32_t DIVIDER_WIDTH = 8; constexpr uint32_t WINDOW_TITLE_BAR_HEIGHT = 37; constexpr uint32_t WINDOW_FRAME_WIDTH = 5; @@ -146,6 +152,7 @@ namespace { constexpr uint32_t MIN_HORIZONTAL_SPLIT_WIDTH = 320; constexpr uint32_t MAX_FLOATING_SIZE = 2560; const Rect INVALID_EMPTY_RECT = {0, 0, 0, 0}; + const Rect DEFAULT_PLACE_HOLDER_RECT = {0, 0, 512, 512}; } } } diff --git a/utils/src/draw_surface.cpp b/utils/src/draw_surface.cpp deleted file mode 100644 index 06a0aa5a..00000000 --- a/utils/src/draw_surface.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2022-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "draw_surface.h" -#include "image/bitmap.h" -#include "image_source.h" -#include "image_type.h" -#include "image_utils.h" -#include "pixel_map.h" -#include "window_manager_hilog.h" - -namespace OHOS { -namespace Rosen { -namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "DrawSurface"}; -} // namespace - -bool DrawSurface::DrawImage(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, - const std::string& imagePath) -{ - sptr layer = GetLayer(surfaceNode); - if (layer == nullptr) { - WLOGFE("layer is nullptr"); - return false; - } - sptr buffer = GetSurfaceBuffer(layer, bufferWidth, bufferHeight); - if (buffer == nullptr || buffer->GetVirAddr() == nullptr) { - return false; - } - auto addr = static_cast(buffer->GetVirAddr()); - if (!DoDraw(addr, buffer->GetWidth(), buffer->GetHeight(), imagePath)) { - WLOGE("draw window pixel failed"); - return false; - } - OHOS::BufferFlushConfig flushConfig = { - .damage = { - .w = buffer->GetWidth(), - .h = buffer->GetHeight(), - }, - }; - OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig); - if (ret != OHOS::SurfaceError::SURFACE_ERROR_OK) { - WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); - return false; - } - return true; -} - -bool DrawSurface::DrawColor(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, - uint32_t color) -{ - sptr layer = GetLayer(surfaceNode); - if (layer == nullptr) { - WLOGFE("layer is nullptr"); - return false; - } - sptr buffer = GetSurfaceBuffer(layer, bufferWidth, bufferHeight); - if (buffer == nullptr || buffer->GetVirAddr() == nullptr) { - return false; - } - auto addr = static_cast(buffer->GetVirAddr()); - if (!DoDraw(addr, buffer->GetWidth(), buffer->GetHeight(), color)) { - WLOGE("draw window color failed"); - return false; - } - OHOS::BufferFlushConfig flushConfig = { - .damage = { - .w = buffer->GetWidth(), - .h = buffer->GetHeight(), - }, - }; - OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig); - if (ret != OHOS::SurfaceError::SURFACE_ERROR_OK) { - WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); - return false; - } - return true; -} - -sptr DrawSurface::GetLayer(std::shared_ptr surfaceNode) -{ - if (surfaceNode == nullptr) { - return nullptr; - } - return surfaceNode->GetSurface(); -} - -sptr DrawSurface::GetSurfaceBuffer(sptr layer, - int32_t bufferWidth, int32_t bufferHeight) -{ - sptr buffer; - int32_t releaseFence = 0; - OHOS::BufferRequestConfig config = { - .width = bufferWidth, - .height = bufferHeight, - .strideAlignment = 0x8, - .format = PIXEL_FMT_RGBA_8888, - .usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA, - }; - - OHOS::SurfaceError ret = layer->RequestBuffer(buffer, releaseFence, config); - if (ret != OHOS::SURFACE_ERROR_OK) { - WLOGFE("request buffer ret:%{public}s", SurfaceErrorStr(ret).c_str()); - return nullptr; - } - return buffer; -} - -std::unique_ptr DrawSurface::DecodeImageToPixelMap(const std::string &imagePath) -{ - OHOS::Media::SourceOptions opts; - opts.formatHint = "image/png"; - uint32_t ret = 0; - auto imageSource = OHOS::Media::ImageSource::CreateImageSource(imagePath, opts, ret); - // CHKPP(imageSource); - std::set formats; - ret = imageSource->GetSupportedFormats(formats); - WLOGFD("get supported format ret:%{public}u", ret); - - OHOS::Media::DecodeOptions decodeOpts; - std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, ret); - if (pixelMap == nullptr) { - WLOGFE("pixelMap is nullptr"); - } - return pixelMap; -} - -void DrawSurface::DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath) -{ - std::unique_ptr pixelmap = DecodeImageToPixelMap(imagePath); - if (pixelmap == nullptr) { - WLOGFE("drawing pixel map is nullptr"); - return; - } - OHOS::Rosen::Drawing::Pen pen; - pen.SetAntiAlias(true); - pen.SetColor(OHOS::Rosen::Drawing::Color::COLOR_BLUE); - OHOS::Rosen::Drawing::scalar penWidth = 1; - pen.SetWidth(penWidth); - canvas.AttachPen(pen); - canvas.DrawBitmap(*pixelmap, 0, 0); -} - -bool DrawSurface::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath) -{ - OHOS::Rosen::Drawing::Bitmap bitmap; - OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888, - OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE }; - bitmap.Build(width, height, format); - OHOS::Rosen::Drawing::Canvas canvas; - canvas.Bind(bitmap); - canvas.Clear(OHOS::Rosen::Drawing::Color::COLOR_TRANSPARENT); - DrawPixelmap(canvas, imagePath); - static constexpr uint32_t stride = 4; - uint32_t addrSize = width * height * stride; - errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize); - if (ret != EOK) { - WLOGFE("draw failed"); - return false; - } - return true; -} -bool DrawSurface::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color) -{ - OHOS::Rosen::Drawing::Bitmap bitmap; - OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888, - OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE }; - bitmap.Build(width, height, format); - OHOS::Rosen::Drawing::Canvas canvas; - canvas.Bind(bitmap); - canvas.Clear(color); - - static constexpr uint32_t stride = 4; - uint32_t addrSize = width * height * stride; - errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize); - if (ret != EOK) { - WLOGFE("draw failed"); - return false; - } - return true; -} -} // Rosen -} // OHOS \ No newline at end of file diff --git a/utils/src/surface_draw.cpp b/utils/src/surface_draw.cpp index 26488bfe..0cdc7827 100644 --- a/utils/src/surface_draw.cpp +++ b/utils/src/surface_draw.cpp @@ -19,11 +19,7 @@ #include #include #include "window_manager_hilog.h" -#include "include/core/SkCanvas.h" -#include "include/codec/SkCodec.h" -#include "include/core/SkData.h" -#include "include/core/SkImage.h" -#include "include/core/SkPixmap.h" + #include "image/bitmap.h" #include "image_source.h" #include "image_type.h" @@ -36,213 +32,8 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SurfaceDraw"}; } // namespace -void SurfaceDraw::Init() -{ -#ifdef ACE_ENABLE_GL - WLOGFI("Draw divider on gpu"); - if (!rc_) { - rc_ = std::make_unique(); - rc_->InitializeEglContext(); - WLOGFI("Draw Init Success"); - } -#endif -} - -std::shared_ptr SurfaceDraw::PrepareDraw(std::shared_ptr surfaceNode, - std::unique_ptr& frame, SkCanvas*& canvas, uint32_t width, uint32_t height) -{ - std::shared_ptr rsSurface = RSSurfaceExtractor::ExtractRSSurface(surfaceNode); - if (rsSurface == nullptr) { - WLOGFE("RSSurface is nullptr"); - return nullptr; - } -#ifdef ACE_ENABLE_GL - rsSurface->SetRenderContext(rc_.get()); -#endif - frame = rsSurface->RequestFrame(width, height); - if (frame == nullptr) { - WLOGFE("DrawBackgroundColor frameptr is nullptr"); - return nullptr; - } - canvas = frame->GetCanvas(); - if (canvas == nullptr) { - WLOGFE("DrawBackgroundColor canvas is nullptr"); - return nullptr; - } - return rsSurface; -} - -void SurfaceDraw::DrawBackgroundColor(std::shared_ptr surfaceNode, Rect winRect, uint32_t bkgColor) -{ - WLOGFI("DrawBackgroundColor winRect, [%{public}d, %{public}d, %{public}d, %{public}d], bkgColor:%{public}x", - winRect.posX_, winRect.posY_, winRect.width_, winRect.height_, bkgColor); - auto width = winRect.width_; - auto height = winRect.height_; - std::unique_ptr frame; - SkCanvas* canvas; - auto rsSurface = PrepareDraw(surfaceNode, frame, canvas, width, height); - if (rsSurface == nullptr) { - return; - } - SkPaint bkgPaint; - bkgPaint.setColor(bkgColor); - canvas->drawRect(SkRect::MakeXYWH(0.0, 0.0, width, height), bkgPaint); - rsSurface->FlushFrame(frame); -} - -// just for test -static bool g_isLoaded = false; - -bool SurfaceDraw::DecodeImageFile(const char* filename, SkBitmap& bitmap) -{ - if (g_isLoaded) { - return true; - } - sk_sp data(SkData::MakeFromFileName(filename)); - std::unique_ptr codec = SkCodec::MakeFromData(std::move(data)); - if (codec == nullptr) { - return false; - } - SkColorType colorType = kN32_SkColorType; - SkImageInfo info = codec->getInfo().makeColorType(colorType); - if (!bitmap.tryAllocPixels(info)) { - return false; - } - g_isLoaded = true; - return SkCodec::kSuccess == codec->getPixels(info, bitmap.getPixels(), bitmap.rowBytes()); -} - -void SurfaceDraw::DrawBitmap(std::shared_ptr surfaceNode, Rect winRect, - SkBitmap& bitmap, uint32_t bkgColor) -{ - if (bitmap.isNull() || bitmap.width() == 0 || bitmap.height() == 0) { - WLOGFE("bitmap is empty or width/height is 0"); - return; - } - WLOGFI("DrawBitmap winRect, x : %{public}d, y : %{public}d, width: %{public}d, height: %{public}d", - winRect.posX_, winRect.posY_, winRect.width_, winRect.height_); - auto width = static_cast(winRect.width_); - auto height = static_cast(winRect.height_); - std::unique_ptr frame; - SkCanvas* canvas; - auto rsSurface = PrepareDraw(surfaceNode, frame, canvas, width, height); - if (rsSurface == nullptr) { - return; - } - SkPaint bkgPaint; - bkgPaint.setColor(bkgColor); - canvas->drawRect(SkRect::MakeXYWH(0.0, 0.0, width, height), bkgPaint); - SkPaint paint; - SkRect rect; - int realHeight = std::min(height, bitmap.height()); // need to scale - int realWidth = std::min(width, bitmap.width()); - int pointX = (width - realWidth) / 2; - int pointY = (height - realHeight) / 2; - rect.setXYWH(pointX, pointY, realWidth, realHeight); - sk_sp image = SkImage::MakeFromBitmap(bitmap); - if (!image) { - WLOGFE("image is nullptr"); - return; - } - canvas->drawImageRect(image.get(), rect, &paint); - rsSurface->FlushFrame(frame); -} - -static SkAlphaType AlphaTypeToSkAlphaType(const sptr& pixmap) -{ - switch (pixmap->GetAlphaType()) { - case Media::AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN: - return SkAlphaType::kUnknown_SkAlphaType; - case Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE: - return SkAlphaType::kOpaque_SkAlphaType; - case Media::AlphaType::IMAGE_ALPHA_TYPE_PREMUL: - return SkAlphaType::kPremul_SkAlphaType; - case Media::AlphaType::IMAGE_ALPHA_TYPE_UNPREMUL: - return SkAlphaType::kUnpremul_SkAlphaType; - default: - return SkAlphaType::kUnknown_SkAlphaType; - } -} - -static SkColorType PixelFormatToSkColorType(const sptr& pixmap) -{ - switch (pixmap->GetPixelFormat()) { - case Media::PixelFormat::RGB_565: - return SkColorType::kRGB_565_SkColorType; - case Media::PixelFormat::RGBA_8888: - return SkColorType::kRGBA_8888_SkColorType; - case Media::PixelFormat::BGRA_8888: - return SkColorType::kBGRA_8888_SkColorType; - case Media::PixelFormat::ALPHA_8: - return SkColorType::kAlpha_8_SkColorType; - case Media::PixelFormat::RGBA_F16: - return SkColorType::kRGBA_F16_SkColorType; - case Media::PixelFormat::UNKNOWN: - case Media::PixelFormat::ARGB_8888: - case Media::PixelFormat::RGB_888: - case Media::PixelFormat::NV21: - case Media::PixelFormat::NV12: - case Media::PixelFormat::CMYK: - default: - return SkColorType::kUnknown_SkColorType; - } -} - -static SkImageInfo MakeSkImageInfoFromPixelMap(sptr& pixmap) -{ - SkColorType colorType = PixelFormatToSkColorType(pixmap); - SkAlphaType alphaType = AlphaTypeToSkAlphaType(pixmap); - sk_sp colorSpace = SkColorSpace::MakeSRGB(); - return SkImageInfo::Make(pixmap->GetWidth(), pixmap->GetHeight(), colorType, alphaType, colorSpace); -} - -void SurfaceDraw::DrawSkImage(std::shared_ptr surfaceNode, Rect winRect, - sptr pixelMap, uint32_t bkgColor) -{ - // Get canvas - WLOGFI("DrawSkImage winRect, [%{public}d, %{public}d, %{public}d, %{public}d], bkgColor:%{public}x", - winRect.posX_, winRect.posY_, winRect.width_, winRect.height_, bkgColor); - auto width = static_cast(winRect.width_); - auto height = static_cast(winRect.height_); - std::unique_ptr frame; - SkCanvas* canvas; - auto rsSurface = PrepareDraw(surfaceNode, frame, canvas, width, height); - if (rsSurface == nullptr) { - return; - } - SkPaint bkgPaint; - bkgPaint.setColor(bkgColor); - canvas->drawRect(SkRect::MakeXYWH(0.0, 0.0, width, height), bkgPaint); - - // Create SkPixmap from PixelMap - auto imageInfo = MakeSkImageInfoFromPixelMap(pixelMap); - SkPixmap imagePixmap(imageInfo, reinterpret_cast(pixelMap->GetPixels()), pixelMap->GetRowBytes()); - - // Create SkImage from SkPixmap - sk_sp skImage = SkImage::MakeFromRaster(imagePixmap, nullptr, nullptr); - if (!skImage) { - WLOGFE("sk image is null"); - return; - } - - SkPaint paint; - SkRect rect; - int realHeight = std::min(height, skImage->height()); // need to scale - int realWidth = std::min(width, skImage->width()); - int pointX = (width - realWidth) / 2; // 2 is mid point - int pointY = (height - realHeight) / 2; // 2 is mid point - rect.setXYWH(pointX, pointY, realWidth, realHeight); - - canvas->drawImageRect(skImage.get(), rect, &paint); - if (!rsSurface->FlushFrame(frame)) { - WLOGFE("fail to flush frame"); - return; - } - return; -} - -bool SurfaceDraw::DrawImage(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, - const std::string& imagePath) +bool SurfaceDraw::DrawImage(std::shared_ptr surfaceNode, int32_t bufferWidth, + int32_t bufferHeight, const std::string& imagePath) { sptr layer = GetLayer(surfaceNode); if (layer == nullptr) { @@ -272,8 +63,8 @@ bool SurfaceDraw::DrawImage(std::shared_ptr surfaceN return true; } -bool SurfaceDraw::DrawColor(std::shared_ptr surfaceNode, int32_t bufferWidth, int32_t bufferHeight, - uint32_t color) +bool SurfaceDraw::DrawColor(std::shared_ptr surfaceNode, int32_t bufferWidth, + int32_t bufferHeight, uint32_t color) { sptr layer = GetLayer(surfaceNode); if (layer == nullptr) { @@ -338,7 +129,10 @@ std::unique_ptr SurfaceDraw::DecodeImageToPixelMap(const opts.formatHint = "image/png"; uint32_t ret = 0; auto imageSource = OHOS::Media::ImageSource::CreateImageSource(imagePath, opts, ret); - // CHKPP(imageSource); + if (imageSource == nullptr) { + WLOGFE("invalid image path."); + return nullptr; + } std::set formats; ret = imageSource->GetSupportedFormats(formats); WLOGFD("get supported format ret:%{public}u", ret); @@ -370,8 +164,8 @@ void SurfaceDraw::DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std:: bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath) { OHOS::Rosen::Drawing::Bitmap bitmap; - OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888, - OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE }; + OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::ColorType::COLORTYPE_RGBA_8888, + OHOS::Rosen::Drawing::AlphaType::ALPHATYPE_OPAQUYE }; bitmap.Build(width, height, format); OHOS::Rosen::Drawing::Canvas canvas; canvas.Bind(bitmap); @@ -390,8 +184,8 @@ bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const s bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color) { OHOS::Rosen::Drawing::Bitmap bitmap; - OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888, - OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE }; + OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::ColorType::COLORTYPE_RGBA_8888, + OHOS::Rosen::Drawing::AlphaType::ALPHATYPE_OPAQUYE }; bitmap.Build(width, height, format); OHOS::Rosen::Drawing::Canvas canvas; canvas.Bind(bitmap); @@ -406,5 +200,79 @@ bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_ } return true; } + +bool SurfaceDraw::DrawImageRect(std::shared_ptr surfaceNode, Rect rect, + sptr pixelMap, uint32_t color) +{ + int32_t winHeight = static_cast(rect.height_); + int32_t winWidth = static_cast(rect.width_); + sptr layer = GetLayer(surfaceNode); + if (layer == nullptr) { + WLOGFE("layer is nullptr"); + return false; + } + sptr buffer = GetSurfaceBuffer(layer, winWidth, winHeight); + if (buffer == nullptr || buffer->GetVirAddr() == nullptr) { + return false; + } + auto addr = static_cast(buffer->GetVirAddr()); + if (!DoDrawImageRect(addr, winWidth, winHeight, pixelMap, color)) { + WLOGE("draw image rect failed."); + return false; + } + OHOS::BufferFlushConfig flushConfig = { + .damage = { + .w = buffer->GetWidth(), + .h = buffer->GetHeight(), + }, + }; + OHOS::SurfaceError surfaceRet = layer->FlushBuffer(buffer, -1, flushConfig); + if (surfaceRet != OHOS::SurfaceError::SURFACE_ERROR_OK) { + WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(surfaceRet).c_str()); + return false; + } + return true; +} + +bool SurfaceDraw::DoDrawImageRect(uint8_t *addr, int32_t winWidth, int32_t winHeight, + sptr pixelMap, uint32_t color) +{ + OHOS::Rosen::Drawing::Bitmap bitmap; + OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::ColorType::COLORTYPE_RGBA_8888, + OHOS::Rosen::Drawing::AlphaType::ALPHATYPE_OPAQUYE }; + bitmap.Build(winWidth, winHeight, format); + OHOS::Rosen::Drawing::Canvas canvas; + canvas.Bind(bitmap); + canvas.Clear(color); + if (pixelMap == nullptr) { + WLOGFE("drawing pixel map is nullptr"); + return false; + } + uint32_t iconHeight = pixelMap->GetHeight(); + uint32_t iconWidth = pixelMap->GetWidth(); + Drawing::Image image; + OHOS::Rosen::Drawing::Bitmap iconBitmap; + iconBitmap.Build(iconWidth, iconHeight, format); + iconBitmap.SetPixels(const_cast(pixelMap->GetPixels())); + image.BuildFromBitmap(iconBitmap); + Drawing::SamplingOptions sampling = Drawing::SamplingOptions(Drawing::FilterMode::NEAREST, + Drawing::MipmapMode::NEAREST); + + int realHeight = std::min(winHeight, pixelMap->GetHeight()); // need to scale + int realWidth = std::min(winWidth, pixelMap->GetWidth()); + int pointX = (winWidth - realWidth) / 2; // 2 is mid point + int pointY = (winHeight - realHeight) / 2; // 2 is mid point + Drawing::Rect dst(pointX, pointY, pointX + realWidth, pointY + realHeight); + canvas.DrawImageRect(image, dst, sampling); + + uint32_t stride = 4; + uint32_t addrSize = winWidth * winHeight * stride; + errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize); + if (ret != EOK) { + WLOGFE("draw failed"); + return false; + } + return true; +} } // Rosen } // OHOS \ No newline at end of file diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index fa4f73d9..046c7ac3 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -51,7 +51,7 @@ void WindowProperty::SetWindowType(WindowType type) void WindowProperty::SetWindowMode(WindowMode mode) { - if (!WindowHelper::IsValidWindowMode(mode)) { + if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) { return; } if (!WindowHelper::IsSplitWindowMode(mode_)) { @@ -62,6 +62,9 @@ void WindowProperty::SetWindowMode(WindowMode mode) void WindowProperty::SetLastWindowMode(WindowMode mode) { + if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) { + return; + } lastMode_ = mode; } @@ -103,6 +106,11 @@ void WindowProperty::SetAlpha(float alpha) alpha_ = alpha; } +void WindowProperty::SetTransform(const Transform& trans) +{ + trans_ = trans; +} + void WindowProperty::SetBrightness(float brightness) { brightness_ = brightness; @@ -133,6 +141,11 @@ void WindowProperty::SetWindowFlags(uint32_t flags) flags_ = flags; } +void WindowProperty::SetSizeLimits(const WindowSizeLimits& sizeLimits) +{ + sizeLimits_ = sizeLimits; +} + void WindowProperty::AddWindowFlag(WindowFlag flag) { flags_ |= static_cast(flag); @@ -192,6 +205,9 @@ WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const void WindowProperty::ResumeLastWindowMode() { + if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, lastMode_)) { + return; + } mode_ = lastMode_; } @@ -270,6 +286,11 @@ float WindowProperty::GetAlpha() const return alpha_; } +Transform WindowProperty::GetTransform() const +{ + return trans_; +} + float WindowProperty::GetBrightness() const { return brightness_; @@ -325,6 +346,11 @@ void WindowProperty::SetModeSupportInfo(uint32_t modeSupportInfo) modeSupportInfo_ = modeSupportInfo; } +void WindowProperty::SetRequestModeSupportInfo(uint32_t requestModeSupportInfo) +{ + requestModeSupportInfo_ = requestModeSupportInfo; +} + uint32_t WindowProperty::GetWindowId() const { return windowId_; @@ -350,6 +376,11 @@ uint32_t WindowProperty::GetModeSupportInfo() const return modeSupportInfo_; } +uint32_t WindowProperty::GetRequestModeSupportInfo() const +{ + return requestModeSupportInfo_; +} + bool WindowProperty::GetTokenState() const { return tokenState_; @@ -370,6 +401,11 @@ bool WindowProperty::GetStretchable() const return isStretchable_; } +WindowSizeLimits WindowProperty::GetSizeLimits() const +{ + return sizeLimits_; +} + void WindowProperty::SetTouchHotAreas(const std::vector& rects) { touchHotAreas_ = rects; @@ -407,7 +443,6 @@ bool WindowProperty::MapMarshalling(Parcel& parcel) const void WindowProperty::MapUnmarshalling(Parcel& parcel, WindowProperty* property) { - std::unordered_map sysBarPropMap; uint32_t size = parcel.ReadUint32(); for (uint32_t i = 0; i < size; i++) { WindowType type = static_cast(parcel.ReadUint32()); @@ -440,6 +475,48 @@ void WindowProperty::UnmarshallingTouchHotAreas(Parcel& parcel, WindowProperty* } } +bool WindowProperty::MarshallingTransform(Parcel& parcel) const +{ + return parcel.WriteFloat(trans_.pivotX_) && parcel.WriteFloat(trans_.pivotY_) && + parcel.WriteFloat(trans_.scaleX_) && parcel.WriteFloat(trans_.scaleY_) && + parcel.WriteFloat(trans_.rotationX_) && parcel.WriteFloat(trans_.rotationY_) && + parcel.WriteFloat(trans_.rotationZ_) && parcel.WriteFloat(trans_.translateX_) && + parcel.WriteFloat(trans_.translateY_) && parcel.WriteFloat(trans_.translateZ_); +} + +void WindowProperty::UnmarshallingTransform(Parcel& parcel, WindowProperty* property) +{ + Transform trans; + trans.pivotX_ = parcel.ReadFloat(); + trans.pivotY_ = parcel.ReadFloat(); + trans.scaleX_ = parcel.ReadFloat(); + trans.scaleY_ = parcel.ReadFloat(); + trans.rotationX_ = parcel.ReadFloat(); + trans.rotationY_ = parcel.ReadFloat(); + trans.rotationZ_ = parcel.ReadFloat(); + trans.translateX_ = parcel.ReadFloat(); + trans.translateY_ = parcel.ReadFloat(); + trans.translateZ_ = parcel.ReadFloat(); + property->SetTransform(trans); +} + +bool WindowProperty::MarshallingWindowSizeLimits(Parcel& parcel) const +{ + if (parcel.WriteUint32(sizeLimits_.maxWidth_) && parcel.WriteUint32(sizeLimits_.maxHeight_) && + parcel.WriteUint32(sizeLimits_.minWidth_) && parcel.WriteUint32(sizeLimits_.minHeight_) && + parcel.WriteFloat(sizeLimits_.maxRatio_) && parcel.WriteFloat(sizeLimits_.minRatio_)) { + return true; + } + return false; +} + +void WindowProperty::UnmarshallingWindowSizeLimits(Parcel& parcel, WindowProperty* property) +{ + WindowSizeLimits sizeLimits = { parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(), + parcel.ReadFloat(), parcel.ReadFloat() }; + property->SetSizeLimits(sizeLimits); +} + bool WindowProperty::Marshalling(Parcel& parcel) const { return parcel.WriteString(windowName_) && parcel.WriteInt32(windowRect_.posX_) && @@ -458,9 +535,12 @@ bool WindowProperty::Marshalling(Parcel& parcel) const parcel.WriteUint32(static_cast(windowSizeChangeReason_)) && parcel.WriteBool(tokenState_) && parcel.WriteUint32(callingWindow_) && parcel.WriteUint32(static_cast(requestedOrientation_)) && parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) && - parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(static_cast(dragType_)) && + parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(requestModeSupportInfo_) && + parcel.WriteUint32(static_cast(dragType_)) && parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) && - parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_); + parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_) && + parcel.WriteBool(isCustomAnimation_) && MarshallingTransform(parcel) && + MarshallingWindowSizeLimits(parcel); } WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) @@ -502,6 +582,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) property->SetTurnScreenOn(parcel.ReadBool()); property->SetKeepScreenOn(parcel.ReadBool()); property->SetModeSupportInfo(parcel.ReadUint32()); + property->SetRequestModeSupportInfo(parcel.ReadUint32()); property->SetDragType(static_cast(parcel.ReadUint32())); uint32_t w = parcel.ReadUint32(); uint32_t h = parcel.ReadUint32(); @@ -509,6 +590,9 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) property->SetStretchable(parcel.ReadBool()); UnmarshallingTouchHotAreas(parcel, property); property->SetAccessTokenId(parcel.ReadUint32()); + property->SetCustomAnimation(parcel.ReadBool()); + UnmarshallingTransform(parcel, property); + UnmarshallingWindowSizeLimits(parcel, property); return property; } @@ -560,6 +644,9 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action) case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: ret &= MarshallingTouchHotAreas(parcel); break; + case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY: + ret &= MarshallingTransform(parcel); + break; default: break; } @@ -613,6 +700,9 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action) case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: UnmarshallingTouchHotAreas(parcel, this); break; + case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY: + UnmarshallingTransform(parcel, this); + break; default: break; } @@ -650,11 +740,15 @@ void WindowProperty::CopyFrom(const sptr& property) turnScreenOn_ = property->turnScreenOn_; keepScreenOn_ = property->keepScreenOn_; modeSupportInfo_ = property->modeSupportInfo_; + requestModeSupportInfo_ = property->requestModeSupportInfo_; dragType_ = property->dragType_; originRect_ = property->originRect_; isStretchable_ = property->isStretchable_; touchHotAreas_ = property->touchHotAreas_; accessTokenId_ = property->accessTokenId_; + isCustomAnimation_ = property->isCustomAnimation_; + trans_ = property->trans_; + sizeLimits_ = property->sizeLimits_; } } } diff --git a/utils/src/window_transition_info.cpp b/utils/src/window_transition_info.cpp index e8784341..6774fb1e 100644 --- a/utils/src/window_transition_info.cpp +++ b/utils/src/window_transition_info.cpp @@ -26,6 +26,7 @@ WindowTransitionInfo::WindowTransitionInfo(sptr in displayId_ = info->displayId_; isShowWhenLocked_ = info->isShowWhenLocked_; isRecent_ = info->isRecent_; + supportWindowModes_ = { 0, 1, 2 }; // 0:fullScreen 1:split 2:floating } void WindowTransitionInfo::SetBundleName(std::string name) @@ -103,6 +104,16 @@ void WindowTransitionInfo::SetShowFlagWhenLocked(bool isShow) isShowWhenLocked_ = isShow; } +void WindowTransitionInfo::SetWindowSupportModes(const std::vector supportModes) +{ + supportWindowModes_.assign(supportModes.begin(), supportModes.end()); +} + +std::vector WindowTransitionInfo::GetWindowSupportModes() +{ + return supportWindowModes_; +} + bool WindowTransitionInfo::GetShowFlagWhenLocked() { return isShowWhenLocked_; diff --git a/wm/BUILD.gn b/wm/BUILD.gn index a1a68b14..ac6ee5fd 100644 --- a/wm/BUILD.gn +++ b/wm/BUILD.gn @@ -73,7 +73,7 @@ ohos_shared_library("libwm") { "ability_base:want", "ability_runtime:ability_context_native", "ability_runtime:ability_manager", - "ace_engine_standard:ace_uicontent", + "ace_engine:ace_uicontent", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "graphic_standard:surface", diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index 2be221d5..f749dc9e 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -43,7 +43,6 @@ public: virtual WMError RequestFocus(uint32_t windowId); virtual WMError GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type, AvoidArea& avoidRect); virtual WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level); - virtual WMError SetAlpha(uint32_t windowId, float alpha); virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId); virtual void ProcessPointDown(uint32_t windowId, bool isStartDrag = false); virtual void ProcessPointUp(uint32_t windowId); diff --git a/wm/include/window_agent.h b/wm/include/window_agent.h index 818accd6..78a350bf 100644 --- a/wm/include/window_agent.h +++ b/wm/include/window_agent.h @@ -29,6 +29,7 @@ public: ~WindowAgent() = default; void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) override; void UpdateWindowMode(WindowMode mode) override; + void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override; void UpdateFocusStatus(bool focused) override; void UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; void UpdateWindowState(WindowState state) override; diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index b046dd4b..27213267 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -116,7 +116,7 @@ public: virtual const std::string& GetWindowName() const override; virtual uint32_t GetWindowId() const override; virtual uint32_t GetWindowFlags() const override; - uint32_t GetModeSupportInfo() const override; + uint32_t GetRequestModeSupportInfo() const override; inline NotifyNativeWinDestroyFunc GetNativeDestroyCallback() { return notifyNativefunc_; @@ -127,13 +127,15 @@ public: virtual WMError SetWindowType(WindowType type) override; virtual WMError SetWindowMode(WindowMode mode) override; virtual WMError SetWindowBackgroundBlur(WindowBlurLevel level) override; - virtual WMError SetAlpha(float alpha) override; + virtual void SetAlpha(float alpha) override; + virtual void SetTransform(const Transform& trans) override; virtual WMError AddWindowFlag(WindowFlag flag) override; virtual WMError RemoveWindowFlag(WindowFlag flag) override; virtual WMError SetWindowFlags(uint32_t flags) override; virtual WMError SetSystemBarProperty(WindowType type, const SystemBarProperty& property) override; virtual WMError SetLayoutFullScreen(bool status) override; virtual WMError SetFullScreen(bool status) override; + virtual Transform GetTransform() const override; inline void SetWindowState(WindowState state) { state_ = state; @@ -143,8 +145,8 @@ public: WMError Create(const std::string& parentName, const std::shared_ptr& context = nullptr); virtual WMError Destroy() override; - virtual WMError Show(uint32_t reason = 0) override; - virtual WMError Hide(uint32_t reason = 0) override; + virtual WMError Show(uint32_t reason = 0, bool isCustomAnimation = false) override; + virtual WMError Hide(uint32_t reason = 0, bool isCustomAnimation = false) override; virtual WMError MoveTo(int32_t x, int32_t y) override; virtual WMError Resize(uint32_t width, uint32_t height) override; virtual WMError SetKeepScreenOn(bool keepScreenOn) override; @@ -189,9 +191,10 @@ public: virtual void RegisterTouchOutsideListener(const sptr& listener) override; virtual void UnregisterTouchOutsideListener(const sptr& listener) override; virtual void SetAceAbilityHandler(const sptr& handler) override; - virtual void SetModeSupportInfo(uint32_t modeSupportInfo) override; + virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override; void UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason); void UpdateMode(WindowMode mode); + void UpdateModeSupportInfo(uint32_t modeSupportInfo); virtual void ConsumeKeyEvent(std::shared_ptr& inputEvent) override; virtual void ConsumePointerEvent(std::shared_ptr& inputEvent) override; virtual void RequestFrame() override; @@ -337,7 +340,10 @@ private: void UpdateDragType(); void InitListenerHandler(); bool CheckCameraFloatingWindowMultiCreated(WindowType type); - void SetOrientationFromAbility(); + void GetConfigurationFromAbilityInfo(); + void UpdateTitleButtonVisibility(); + void SetModeSupportInfo(uint32_t modeSupportInfo); + uint32_t GetModeSupportInfo() const; // colorspace, gamut using ColorSpaceConvertMap = struct { diff --git a/wm/include/zidl/window_interface.h b/wm/include/zidl/window_interface.h index bb516d18..e8836552 100644 --- a/wm/include/zidl/window_interface.h +++ b/wm/include/zidl/window_interface.h @@ -31,6 +31,7 @@ public: enum class WindowMessage : uint32_t { TRANS_ID_UPDATE_WINDOW_RECT, TRANS_ID_UPDATE_WINDOW_MODE, + TRANS_ID_UPDATE_MODE_SUPPORT_INFO, TRANS_ID_UPDATE_FOCUS_STATUS, TRANS_ID_UPDATE_AVOID_AREA, TRANS_ID_UPDATE_WINDOW_STATE, @@ -45,6 +46,7 @@ public: virtual void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) = 0; virtual void UpdateWindowMode(WindowMode mode) = 0; + virtual void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) = 0; virtual void UpdateFocusStatus(bool focused) = 0; virtual void UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; virtual void UpdateWindowState(WindowState state) = 0; diff --git a/wm/include/zidl/window_proxy.h b/wm/include/zidl/window_proxy.h index ac492560..c0990ada 100644 --- a/wm/include/zidl/window_proxy.h +++ b/wm/include/zidl/window_proxy.h @@ -30,6 +30,7 @@ public: void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) override; void UpdateWindowMode(WindowMode mode) override; + void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override; void UpdateFocusStatus(bool focused) override; void UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; void UpdateWindowState(WindowState state) override; diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index 2d2285a5..c044c26c 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -113,13 +113,6 @@ WMError WindowAdapter::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLeve return windowManagerServiceProxy_->SetWindowBackgroundBlur(windowId, level); } -WMError WindowAdapter::SetAlpha(uint32_t windowId, float alpha) -{ - INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); - - return windowManagerServiceProxy_->SetAlpha(windowId, alpha); -} - void WindowAdapter::ProcessPointDown(uint32_t windowId, bool isStartDrag) { INIT_PROXY_CHECK_RETURN(); diff --git a/wm/src/window_agent.cpp b/wm/src/window_agent.cpp index e99a5966..46c91c3d 100644 --- a/wm/src/window_agent.cpp +++ b/wm/src/window_agent.cpp @@ -46,6 +46,15 @@ void WindowAgent::UpdateWindowMode(WindowMode mode) window_->UpdateMode(mode); } +void WindowAgent::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) +{ + if (window_ == nullptr) { + WLOGFE("window_ is nullptr"); + return; + } + window_->UpdateModeSupportInfo(modeSupportInfo); +} + void WindowAgent::UpdateFocusStatus(bool focused) { if (window_ == nullptr) { diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 84cf23b1..d97ecb9f 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -48,7 +48,8 @@ const WindowImpl::ColorSpaceConvertMap WindowImpl::colorSpaceConvertMap[] = { std::map>> WindowImpl::windowMap_; std::map>> WindowImpl::subWindowMap_; std::map>> WindowImpl::appFloatingWindowMap_; - +static int ctorCnt = 0; +static int dtorCnt = 0; WindowImpl::WindowImpl(const sptr& option) { property_ = new (std::nothrow) WindowProperty(); @@ -57,7 +58,6 @@ WindowImpl::WindowImpl(const sptr& option) property_->SetWindowType(option->GetWindowType()); property_->SetWindowMode(option->GetWindowMode()); property_->SetWindowBackgroundBlur(option->GetWindowBackgroundBlur()); - property_->SetAlpha(option->GetAlpha()); property_->SetFullScreen(option->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN); property_->SetFocusable(option->GetFocusable()); property_->SetTouchable(option->GetTouchable()); @@ -81,6 +81,7 @@ WindowImpl::WindowImpl(const sptr& option) struct RSSurfaceNodeConfig rsSurfaceNodeConfig; rsSurfaceNodeConfig.SurfaceNodeName = property_->GetWindowName(); surfaceNode_ = RSSurfaceNode::Create(rsSurfaceNodeConfig); + WLOGFI("WindowImpl constructor Count: %{public}d name: %{public}s", ++ctorCnt, property_->GetWindowName().c_str()); } void WindowImpl::InitListenerHandler() @@ -104,7 +105,8 @@ WindowImpl::~WindowImpl() if (eventHandler_ != nullptr) { eventHandler_.reset(); } - WLOGFI("windowName: %{public}s, windowId: %{public}d", GetWindowName().c_str(), GetWindowId()); + WLOGFI("windowName: %{public}s, windowId: %{public}d, dtorCnt: %{public}d, surfaceNode:%{public}d", + GetWindowName().c_str(), GetWindowId(), ++dtorCnt, static_cast(surfaceNode_.use_count())); Destroy(); } @@ -276,6 +278,11 @@ uint32_t WindowImpl::GetWindowFlags() const return property_->GetWindowFlags(); } +uint32_t WindowImpl::GetRequestModeSupportInfo() const +{ + return property_->GetRequestModeSupportInfo(); +} + uint32_t WindowImpl::GetModeSupportInfo() const { return property_->GetModeSupportInfo(); @@ -364,14 +371,29 @@ WMError WindowImpl::SetWindowBackgroundBlur(WindowBlurLevel level) return SingletonContainer::Get().SetWindowBackgroundBlur(property_->GetWindowId(), level); } -WMError WindowImpl::SetAlpha(float alpha) +void WindowImpl::SetAlpha(float alpha) { WLOGFI("[Client] Window %{public}u alpha %{public}f", property_->GetWindowId(), alpha); if (!IsWindowValid()) { - return WMError::WM_ERROR_INVALID_WINDOW; + return; } property_->SetAlpha(alpha); - return SingletonContainer::Get().SetAlpha(property_->GetWindowId(), alpha); + surfaceNode_->SetAlpha(alpha); +} + +void WindowImpl::SetTransform(const Transform& trans) +{ + WLOGFI("[Client] Window %{public}u SetTransform", property_->GetWindowId()); + if (!IsWindowValid()) { + return; + } + property_->SetTransform(trans); + UpdateProperty(PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY); +} + +Transform WindowImpl::GetTransform() const +{ + return property_->GetTransform(); } WMError WindowImpl::AddWindowFlag(WindowFlag flag) @@ -448,9 +470,11 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo, } else { uiContent->Initialize(this, contentInfo, storage); } - // make uiContent_ available after Initialize/Restore + // make uiContent available after Initialize/Restore uiContent_ = std::move(uiContent); + if (state_ == WindowState::STATE_SHOWN) { + UpdateTitleButtonVisibility(); Ace::ViewportConfig config; Rect rect = GetRect(); config.SetSize(rect.width_, rect.height_); @@ -561,7 +585,9 @@ WMError WindowImpl::SetSystemBarProperty(WindowType type, const SystemBarPropert WMError WindowImpl::SetLayoutFullScreen(bool status) { WLOGFI("[Client] Window %{public}u SetLayoutFullScreen: %{public}u", property_->GetWindowId(), status); - if (!IsWindowValid()) { + if (!IsWindowValid() || + !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } WMError ret = SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); @@ -591,6 +617,11 @@ WMError WindowImpl::SetLayoutFullScreen(bool status) WMError WindowImpl::SetFullScreen(bool status) { WLOGFI("[Client] Window %{public}u SetFullScreen: %{public}d", property_->GetWindowId(), status); + if (!IsWindowValid() || + !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); + return WMError::WM_ERROR_INVALID_WINDOW; + } SystemBarProperty statusProperty = GetSystemBarPropertyByType( WindowType::WINDOW_TYPE_STATUS_BAR); SystemBarProperty naviProperty = GetSystemBarPropertyByType( @@ -643,6 +674,68 @@ WMError WindowImpl::UpdateProperty(PropertyChangeAction action) return SingletonContainer::Get().UpdateProperty(property_, action); } +void WindowImpl::GetConfigurationFromAbilityInfo() +{ + auto abilityContext = AbilityRuntime::Context::ConvertTo(context_); + if (abilityContext == nullptr) { + WLOGFE("id:%{public}u is not ability Window", property_->GetWindowId()); + return; + } + auto abilityInfo = abilityContext->GetAbilityInfo(); + if (abilityInfo == nullptr) { + WLOGFE("id:%{public}u Ability window get ability info failed", property_->GetWindowId()); + return; + } + + // get support modes configuration + uint32_t modeSupportInfo = 0; + const auto& supportModes = abilityInfo->windowModes; + for (auto& mode : supportModes) { + if (static_cast(mode) == static_cast(0)) { // 0 : fullScreen + modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; + } else if (static_cast(mode) == static_cast(1)) { // 1 : split + modeSupportInfo |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + } else if (static_cast(mode) == static_cast(2)) { // 2 : floating + modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; + } + } + if (modeSupportInfo == 0) { + WLOGFI("mode config param is 0, set all modes"); + modeSupportInfo = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + } + SetRequestModeSupportInfo(modeSupportInfo); + + // get window size limits configuration + WindowSizeLimits sizeLimits; + sizeLimits.maxWidth_ = abilityInfo->maxWindowWidth; + sizeLimits.maxHeight_ = abilityInfo->maxWindowHeight; + sizeLimits.minWidth_ = abilityInfo->minWindowWidth; + sizeLimits.minHeight_ = abilityInfo->minWindowHeight; + sizeLimits.maxRatio_ = static_cast(abilityInfo->maxWindowRatio); + sizeLimits.minRatio_ = static_cast(abilityInfo->minWindowRatio); + property_->SetSizeLimits(sizeLimits); + + // get orientation configuration + DisplayOrientation displayOrientation = static_cast( + static_cast(abilityInfo->orientation)); + if (ABILITY_TO_WMS_ORIENTATION_MAP.count(displayOrientation) == 0) { + WLOGFE("id:%{public}u Do not support this Orientation type", property_->GetWindowId()); + return; + } + Orientation orientation = ABILITY_TO_WMS_ORIENTATION_MAP.at(displayOrientation); + if (orientation < Orientation::BEGIN || orientation > Orientation::END) { + WLOGFE("Set orientation from ability failed"); + return; + } + property_->SetRequestedOrientation(orientation); +} + +void WindowImpl::UpdateTitleButtonVisibility() +{ + WLOGFI("[Client] UpdateTitleButtonVisibility"); +} + WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr& context) { WLOGFI("[Client] Window [name:%{public}s] Create", name_.c_str()); @@ -688,7 +781,7 @@ WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr< WLOGFI("get stretchable enable:%{public}d", windowSystemConfig_.isStretchable_); property_->SetStretchable(windowSystemConfig_.isStretchable_); } - SetOrientationFromAbility(); + GetConfigurationFromAbilityInfo(); } WMError ret = SingletonContainer::Get().CreateWindow(windowAgent, property_, surfaceNode_, windowId, token); @@ -728,12 +821,13 @@ void WindowImpl::DestroyFloatingWindow() // Destroy app floating window if exist if (appFloatingWindowMap_.count(GetWindowId()) > 0) { - auto floatingWindows = appFloatingWindowMap_.at(GetWindowId()); - for (auto& floatingWindow : floatingWindows) { - if (floatingWindow == nullptr) { + auto& floatingWindows = appFloatingWindowMap_.at(GetWindowId()); + for (auto iter = floatingWindows.begin(); iter != floatingWindows.end(); iter = floatingWindows.begin()) { + if ((*iter) == nullptr) { + floatingWindows.erase(iter); continue; } - floatingWindow->Destroy(); + (*iter)->Destroy(); } appFloatingWindowMap_.erase(GetWindowId()); } @@ -755,12 +849,13 @@ void WindowImpl::DestroySubWindow() } if (subWindowMap_.count(GetWindowId()) > 0) { // remove from subWindowMap_ and windowMap_ - std::vector>& subWindows = subWindowMap_.at(GetWindowId()); - for (auto& subWindow : subWindows) { - if (subWindow == nullptr) { + auto& subWindows = subWindowMap_.at(GetWindowId()); + for (auto iter = subWindows.begin(); iter != subWindows.end(); iter = subWindows.begin()) { + if ((*iter) == nullptr) { + subWindows.erase(iter); continue; } - subWindow->Destroy(false); + (*iter)->Destroy(false); } subWindowMap_[GetWindowId()].clear(); subWindowMap_.erase(GetWindowId()); @@ -833,7 +928,7 @@ WMError WindowImpl::Destroy(bool needNotifyServer) return ret; } -WMError WindowImpl::Show(uint32_t reason) +WMError WindowImpl::Show(uint32_t reason, bool isCustomAnimation) { WLOGFI("[Client] Window [name:%{public}s, id:%{public}u] Show, reason:%{public}u", name_.c_str(), property_->GetWindowId(), reason); @@ -864,6 +959,21 @@ WMError WindowImpl::Show(uint32_t reason) return WMError::WM_OK; } SetDefaultOption(); + // set true success when transitionController exist; set false when complete transition + property_->SetCustomAnimation(isCustomAnimation); + + // show failed when current mode is not support or window only supports split mode and can show when locked + bool isShowWhenLocked = GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED); + if (!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), GetMode()) || + WindowHelper::IsOnlySupportSplitAndShowWhenLocked(isShowWhenLocked, GetModeSupportInfo())) { + WLOGFE("current mode is not be supported, windowId: %{public}u", property_->GetWindowId()); + NotifyForegroundFailed(); + return WMError::WM_ERROR_INVALID_WINDOW; + } + + // update title button visibility when show + UpdateTitleButtonVisibility(); + WMError ret = SingletonContainer::Get().AddWindow(property_); RecordLifeCycleExceptionEvent(LifeCycleEvent::SHOW_EVENT, ret); if (ret == WMError::WM_OK || ret == WMError::WM_ERROR_DEATH_RECIPIENT) { @@ -876,7 +986,7 @@ WMError WindowImpl::Show(uint32_t reason) return ret; } -WMError WindowImpl::Hide(uint32_t reason) +WMError WindowImpl::Hide(uint32_t reason, bool isCustomAnimation) { WLOGFI("[Client] Window [name:%{public}s, id:%{public}u] Hide", name_.c_str(), property_->GetWindowId()); if (!IsWindowValid()) { @@ -892,6 +1002,7 @@ WMError WindowImpl::Hide(uint32_t reason) WLOGFI("window is already hidden id: %{public}u", property_->GetWindowId()); return WMError::WM_OK; } + property_->SetCustomAnimation(isCustomAnimation); WMError ret = SingletonContainer::Get().RemoveWindow(property_->GetWindowId()); RecordLifeCycleExceptionEvent(LifeCycleEvent::HIDE_EVENT, ret); if (ret != WMError::WM_OK) { @@ -1196,6 +1307,9 @@ WMError WindowImpl::NotifyWindowTransition(TransitionReason reason) return WMError::WM_ERROR_NO_MEM; } auto abilityInfo = abilityContext->GetAbilityInfo(); + if (abilityInfo == nullptr) { + return WMError::WM_ERROR_NULLPTR; + } fromInfo->SetBundleName(context_->GetBundleName()); fromInfo->SetAbilityName(abilityInfo->name); fromInfo->SetWindowMode(property_->GetWindowMode()); @@ -1207,32 +1321,6 @@ WMError WindowImpl::NotifyWindowTransition(TransitionReason reason) return SingletonContainer::Get().NotifyWindowTransition(fromInfo, toInfo); } -void WindowImpl::SetOrientationFromAbility() -{ - auto abilityContext = AbilityRuntime::Context::ConvertTo(context_); - if (abilityContext == nullptr) { - WLOGFE("id:%{public}d is not ability Window", property_->GetWindowId()); - return; - } - auto abilityInfo = abilityContext->GetAbilityInfo(); - if (abilityInfo == nullptr) { - WLOGFE("id:%{public}d Ability window get ability info failed", property_->GetWindowId()); - return; - } - DisplayOrientation displayOrientation = static_cast( - static_cast(abilityInfo->orientation)); - if (ABILITY_TO_WMS_ORIENTATION_MAP.count(displayOrientation) == 0) { - WLOGFE("id:%{public}d Do not support this Orientation type", property_->GetWindowId()); - return; - } - Orientation orientation = ABILITY_TO_WMS_ORIENTATION_MAP.at(displayOrientation); - if (orientation < Orientation::BEGIN || orientation > Orientation::END) { - WLOGFE("Set orientation from ability failed"); - return; - } - property_->SetRequestedOrientation(orientation); -} - WMError WindowImpl::Minimize() { WLOGFI("[Client] Window %{public}u Minimize", property_->GetWindowId()); @@ -1526,20 +1614,15 @@ void WindowImpl::SetAceAbilityHandler(const sptr& handler) aceAbilityHandler_ = handler; } +void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo) +{ + property_->SetRequestModeSupportInfo(modeSupportInfo); + SetModeSupportInfo(modeSupportInfo); +} + void WindowImpl::SetModeSupportInfo(uint32_t modeSupportInfo) { property_->SetModeSupportInfo(modeSupportInfo); - UpdateProperty(PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO); - if (!WindowHelper::IsWindowModeSupported(modeSupportInfo, GetMode())) { - WLOGFI("current window mode is not supported, force to transform to appropriate mode. window id:%{public}u", - GetWindowId()); - WindowMode mode = WindowHelper::GetWindowModeFromModeSupportInfo(modeSupportInfo); - if (mode != WindowMode::WINDOW_MODE_UNDEFINED) { - SetWindowMode(mode); - } else { - WLOGFE("invalid modeSupportInfo %{public}u", modeSupportInfo); - } - } } void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) @@ -1559,7 +1642,7 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize return; } property_->SetWindowRect(rect); - const Rect& originRect = property_->GetOriginRect(); + // update originRect when floating window show for the first time. if (!isOriginRectSet_ && WindowHelper::IsMainFloatingWindow(GetType(), GetMode())) { property_->SetOriginRect(rect); @@ -1571,12 +1654,13 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize if (reason == WindowSizeChangeReason::DRAG || reason == WindowSizeChangeReason::DRAG_END || reason == WindowSizeChangeReason::DRAG_START || reason == WindowSizeChangeReason::RECOVER || reason == WindowSizeChangeReason::MOVE) { - rectToAce = originRect; + rectToAce = property_->GetOriginRect(); } else { property_->SetOriginRect(rect); } } WLOGFI("sizeChange callback size: %{public}lu", (unsigned long)windowChangeListeners_.size()); + NotifySizeChange(rectToAce, reason); if (uiContent_ != nullptr) { Ace::ViewportConfig config; @@ -1601,6 +1685,13 @@ void WindowImpl::UpdateMode(WindowMode mode) } } +void WindowImpl::UpdateModeSupportInfo(uint32_t modeSupportInfo) +{ + WLOGI("modeSupportInfo: %{public}u, winId: %{public}u", modeSupportInfo, GetWindowId()); + SetModeSupportInfo(modeSupportInfo); + UpdateTitleButtonVisibility(); +} + void WindowImpl::ConsumeKeyEvent(std::shared_ptr& keyEvent) { NotifyKeyEvent(keyEvent); @@ -2023,8 +2114,7 @@ void WindowImpl::UpdateWindowState(WindowState state) WLOGFD("MinimizeAbility, id: %{public}u", GetWindowId()); AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(abilityContext->GetToken(), true); } else { - state_ = WindowState::STATE_HIDDEN; - NotifyAfterBackground(); + Hide(static_cast(WindowStateChangeReason::TOGGLING)); } break; } @@ -2305,10 +2395,6 @@ void WindowImpl::SetDefaultOption() property_->SetFocusable(false); break; } - case WindowType::WINDOW_TYPE_PLACE_HOLDER: { - AddWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE); - break; - } default: break; } diff --git a/wm/src/window_option.cpp b/wm/src/window_option.cpp index 9c7011d2..60477a89 100644 --- a/wm/src/window_option.cpp +++ b/wm/src/window_option.cpp @@ -50,11 +50,6 @@ void WindowOption::SetWindowBackgroundBlur(WindowBlurLevel level) level_ = level; } -void WindowOption::SetAlpha(float alpha) -{ - alpha_ = alpha; -} - void WindowOption::SetFocusable(bool isFocusable) { focusable_ = isFocusable; @@ -122,11 +117,6 @@ WindowBlurLevel WindowOption::GetWindowBackgroundBlur() const return level_; } -float WindowOption::GetAlpha() const -{ - return alpha_; -} - bool WindowOption::GetFocusable() const { return focusable_; diff --git a/wm/src/zidl/window_proxy.cpp b/wm/src/zidl/window_proxy.cpp index 5b3a448c..1d3cd3e4 100644 --- a/wm/src/zidl/window_proxy.cpp +++ b/wm/src/zidl/window_proxy.cpp @@ -76,6 +76,27 @@ void WindowProxy::UpdateWindowMode(WindowMode mode) return; } +void WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + if (!data.WriteUint32(modeSupportInfo)) { + WLOGFE("Write WindowMode failed"); + return; + } + + if (Remote()->SendRequest(static_cast(WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + } + return; +} + void WindowProxy::UpdateFocusStatus(bool focused) { MessageParcel data; diff --git a/wm/src/zidl/window_stub.cpp b/wm/src/zidl/window_stub.cpp index c8d00110..fdb2ae7d 100644 --- a/wm/src/zidl/window_stub.cpp +++ b/wm/src/zidl/window_stub.cpp @@ -45,6 +45,11 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParce UpdateWindowMode(mode); break; } + case WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO: { + uint32_t modeSupportInfo = data.ReadUint32(); + UpdateWindowModeSupportInfo(modeSupportInfo); + break; + } case WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS: { bool focused = data.ReadBool(); UpdateFocusStatus(focused); diff --git a/wm/test/fuzztest/windowscene_fuzzer/windowscene_fuzzer.cpp b/wm/test/fuzztest/windowscene_fuzzer/windowscene_fuzzer.cpp index c0faa60d..3acf1b7d 100644 --- a/wm/test/fuzztest/windowscene_fuzzer/windowscene_fuzzer.cpp +++ b/wm/test/fuzztest/windowscene_fuzzer/windowscene_fuzzer.cpp @@ -77,9 +77,6 @@ size_t InitWindowOption1(WindowOption &windowOption, const uint8_t *data, size_t uint32_t level; startPos += GetObject(level, data + startPos, size - startPos); windowOption.SetWindowBackgroundBlur(static_cast(level)); - float alpha; - startPos += GetObject(alpha, data + startPos, size - startPos); - windowOption.SetAlpha(alpha); bool focusable; startPos += GetObject(focusable, data + startPos, size - startPos); windowOption.SetFocusable(focusable); diff --git a/wm/test/systemtest/window_drag_test.cpp b/wm/test/systemtest/window_drag_test.cpp index 34ec76d9..af107f63 100644 --- a/wm/test/systemtest/window_drag_test.cpp +++ b/wm/test/systemtest/window_drag_test.cpp @@ -23,7 +23,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_CALLBACK_US = 100000; // 100000 us class TestDragListener : public IWindowDragListener { @@ -49,9 +49,9 @@ public: static sptr firstWindowDragListener_; static sptr secondWindowDragListener_; - utils::TestWindowInfo dragWindowInfo_; - utils::TestWindowInfo firstWindowInfo_; - utils::TestWindowInfo secondWindowInfo_; + Utils::TestWindowInfo dragWindowInfo_; + Utils::TestWindowInfo firstWindowInfo_; + Utils::TestWindowInfo secondWindowInfo_; }; sptr WindowDragTest::firstWindowDragListener_ = @@ -77,7 +77,7 @@ void WindowDragTest::SetUp() firstWindowInfo_ = { .name = "firstWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -87,7 +87,7 @@ void WindowDragTest::SetUp() secondWindowInfo_ = { .name = "secondWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -105,12 +105,12 @@ namespace { * @tc.type: FUNC */ HWTEST_F(WindowDragTest, DragIn, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); - const sptr &dragWindow = utils::CreateTestWindow(dragWindowInfo_); + const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); dragWindow->Show(); dragWindow->MoveTo(300, 300); usleep(WAIT_CALLBACK_US); @@ -129,12 +129,12 @@ HWTEST_F(WindowDragTest, DragIn, Function | MediumTest | Level3) { * @tc.type: FUNC */ HWTEST_F(WindowDragTest, DragMove, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); - const sptr &dragWindow = utils::CreateTestWindow(dragWindowInfo_); + const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); dragWindow->Show(); dragWindow->MoveTo(300, 300); usleep(WAIT_CALLBACK_US); @@ -159,17 +159,17 @@ HWTEST_F(WindowDragTest, DragMove, Function | MediumTest | Level3) { * @tc.type: FUNC */ HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); secondWindowInfo_.rect = {500, 500, 500, 500}; - const sptr &secondWindow = utils::CreateTestWindow(secondWindowInfo_); + const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); secondWindow->RegisterDragListener(secondWindowDragListener_); secondWindow->Show(); - const sptr &dragWindow = utils::CreateTestWindow(dragWindowInfo_); + const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); dragWindow->Show(); dragWindow->MoveTo(300, 300); usleep(WAIT_CALLBACK_US); @@ -203,12 +203,12 @@ HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) { * @tc.type: FUNC */ HWTEST_F(WindowDragTest, DragEnd, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); - const sptr &dragWindow = utils::CreateTestWindow(dragWindowInfo_); + const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); dragWindow->Show(); dragWindow->MoveTo(199, 199); usleep(WAIT_CALLBACK_US); diff --git a/wm/test/systemtest/window_effect_test.cpp b/wm/test/systemtest/window_effect_test.cpp index 8d13f28b..c93cc32a 100644 --- a/wm/test/systemtest/window_effect_test.cpp +++ b/wm/test/systemtest/window_effect_test.cpp @@ -21,14 +21,14 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowEffectTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; }; void WindowEffectTest::SetUpTestCase() @@ -43,7 +43,7 @@ void WindowEffectTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -64,7 +64,7 @@ namespace { */ HWTEST_F(WindowEffectTest, WindowEffect01, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_EQ(WMError::WM_OK, window->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_LOW)); ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_LOW, window->GetWindowBackgroundBlur()); @@ -78,9 +78,9 @@ HWTEST_F(WindowEffectTest, WindowEffect01, Function | MediumTest | Level3) */ HWTEST_F(WindowEffectTest, WindowEffect02, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); - ASSERT_EQ(WMError::WM_OK, window->SetAlpha(1.0f)); + window->SetAlpha(1.0f); ASSERT_EQ(1.0f, window->GetAlpha()); window->Destroy(); diff --git a/wm/test/systemtest/window_focus_test.cpp b/wm/test/systemtest/window_focus_test.cpp index 29b86105..1a4b05db 100644 --- a/wm/test/systemtest/window_focus_test.cpp +++ b/wm/test/systemtest/window_focus_test.cpp @@ -27,7 +27,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowFocusTest"}; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_ASYNC_US = 100000; // 100000us class TestFocusChangedListener : public IFocusChangedListener { @@ -45,9 +45,9 @@ public: virtual void SetUp() override; virtual void TearDown() override; static sptr testFocusChangedListener_; - utils::TestWindowInfo fullScreenAppInfo_; - utils::TestWindowInfo floatAppInfo_; - utils::TestWindowInfo subAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo floatAppInfo_; + Utils::TestWindowInfo subAppInfo_; }; sptr WindowFocusTest::testFocusChangedListener_ = @@ -72,7 +72,7 @@ void WindowFocusTest::SetUpTestCase() WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowFocusTest::TearDownTestCase() @@ -83,7 +83,7 @@ void WindowFocusTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -92,7 +92,7 @@ void WindowFocusTest::SetUp() }; floatAppInfo_ = { .name = "ParentWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -101,7 +101,7 @@ void WindowFocusTest::SetUp() }; subAppInfo_ = { .name = "SubWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -126,23 +126,23 @@ HWTEST_F(WindowFocusTest, FocusChangedTest01, Function | MediumTest | Level3) { fullScreenAppInfo_.name = "FocusChangedTest01_1"; fullScreenAppInfo_.focusable_ = false; - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_NE(nullptr, window1); floatAppInfo_.name = "FocusChangedTest01_2"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& window2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& window2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, window2); floatAppInfo_.name = "FocusChangedTest01_3"; floatAppInfo_.rect = { 250, 150, 300, 500 }; - const sptr& window3 = utils::CreateTestWindow(floatAppInfo_); + const sptr& window3 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, window3); subAppInfo_.name = "FocusChangedTest01_4"; subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = window3->GetWindowName(); - const sptr& subWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& subWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_EQ(WMError::WM_OK, window3->Show()); // Await 100ms and get callback result in listener. @@ -181,14 +181,14 @@ HWTEST_F(WindowFocusTest, FocusChangedTest02, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest02_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow); ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); subAppInfo_.name = "FocusChangedTest02_2"; subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow->GetWindowName(); - const sptr& subWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& subWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, subWindow->Show()); usleep(WAIT_ASYNC_US); @@ -212,20 +212,20 @@ HWTEST_F(WindowFocusTest, FocusChangedTest03, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest03_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); subAppInfo_.name = "FocusChangedTest03_2"; subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow1->GetWindowName(); - const sptr& aboveSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& aboveSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, aboveSubWindow); ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show()); floatAppInfo_.name = "FocusChangedTest03_3"; floatAppInfo_.rect = { 200, 200, 100, 100 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); usleep(WAIT_ASYNC_US); @@ -251,7 +251,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest04, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest04_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); @@ -259,13 +259,13 @@ HWTEST_F(WindowFocusTest, FocusChangedTest04, Function | MediumTest | Level3) subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow1->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow); ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show()); floatAppInfo_.name = "FocusChangedTest04_3"; floatAppInfo_.rect = { 200, 200, 100, 100 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); usleep(WAIT_ASYNC_US); @@ -291,13 +291,13 @@ HWTEST_F(WindowFocusTest, FocusChangedTest05, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest05_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); floatAppInfo_.name = "FocusChangedTest05_2"; floatAppInfo_.rect = { 200, 200, 100, 100 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); @@ -305,7 +305,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest05, Function | MediumTest | Level3) subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow2->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow); ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show()); usleep(WAIT_ASYNC_US); @@ -340,7 +340,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest06_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow); ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); @@ -348,7 +348,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3) subAppInfo_.rect = { 100, 200, 100, 100 }; subAppInfo_.parentName = mainWindow->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow); ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show()); @@ -356,7 +356,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3) subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - const sptr& aboveSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& aboveSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, aboveSubWindow); ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show()); usleep(WAIT_ASYNC_US); @@ -377,19 +377,19 @@ HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest07_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); floatAppInfo_.name = "FocusChangedTest07_2"; floatAppInfo_.rect = { 250, 150, 300, 500 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); floatAppInfo_.name = "FocusChangedTest07_3"; floatAppInfo_.rect = { 300, 400, 10, 400 }; - const sptr& mainWindow3 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow3 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow3); ASSERT_EQ(WMError::WM_OK, mainWindow3->Show()); @@ -397,21 +397,21 @@ HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3) subAppInfo_.rect = { 20, 100, 100, 100 }; subAppInfo_.parentName = mainWindow1->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow1 = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow1 = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow1); subAppInfo_.name = "FocusChangedTest07_5"; subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow2->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - const sptr& aboveSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& aboveSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, aboveSubWindow); subAppInfo_.name = "FocusChangedTest07_6"; subAppInfo_.rect = { 310, 410, 100, 100 }; subAppInfo_.parentName = mainWindow3->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow2 = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow2 = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow2); ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show()); @@ -448,13 +448,13 @@ HWTEST_F(WindowFocusTest, FocusChangedTest08, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest08_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); floatAppInfo_.name = "FocusChangedTest08_2"; floatAppInfo_.rect = { 250, 150, 300, 500 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); @@ -462,7 +462,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest08, Function | MediumTest | Level3) subAppInfo_.rect = { 20, 100, 100, 100 }; subAppInfo_.parentName = mainWindow1->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow); ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show()); usleep(WAIT_ASYNC_US); diff --git a/wm/test/systemtest/window_gamut_test.cpp b/wm/test/systemtest/window_gamut_test.cpp index 195bffcb..f0bad10d 100644 --- a/wm/test/systemtest/window_gamut_test.cpp +++ b/wm/test/systemtest/window_gamut_test.cpp @@ -21,7 +21,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; constexpr uint32_t MAX_WAIT_COUNT = 100; constexpr uint32_t WAIT_DUR = 10 * 1000; @@ -31,7 +31,7 @@ public: static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; }; void WindowGamutTest::SetUpTestCase() @@ -46,7 +46,7 @@ void WindowGamutTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -67,7 +67,7 @@ namespace { */ HWTEST_F(WindowGamutTest, IsSupportWideGamut01, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_EQ(true, window->IsSupportWideGamut()); @@ -81,7 +81,7 @@ HWTEST_F(WindowGamutTest, IsSupportWideGamut01, Function | MediumTest | Level3) */ HWTEST_F(WindowGamutTest, GetColorSpace01, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_EQ(ColorSpace::COLOR_SPACE_DEFAULT, window->GetColorSpace()); @@ -101,7 +101,7 @@ HWTEST_F(WindowGamutTest, SetColorSpace01, Function | MediumTest | Level3) ColorSpace::COLOR_SPACE_WIDE_GAMUT }; ColorSpace colorSpace; - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ColorSpace colorSpaceBackup = window->GetColorSpace(); // backup origin @@ -130,7 +130,7 @@ HWTEST_F(WindowGamutTest, SetColorSpace01, Function | MediumTest | Level3) */ HWTEST_F(WindowGamutTest, SetColorSpace02, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ColorSpace colorSpaceBackup = window->GetColorSpace(); diff --git a/wm/test/systemtest/window_immersive_test.cpp b/wm/test/systemtest/window_immersive_test.cpp index 919c00bf..5185e218 100644 --- a/wm/test/systemtest/window_immersive_test.cpp +++ b/wm/test/systemtest/window_immersive_test.cpp @@ -48,7 +48,7 @@ namespace { const float RATIO = 0.3; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_ASYNC_US = 100000; // 100000us class TestSystemBarChangedListener : public ISystemBarChangedListener { @@ -79,8 +79,8 @@ public: static vector fullScreenExpecteds_; static sptr testSystemBarChangedListener_; static sptr testAvoidAreaChangedListener_; - utils::TestWindowInfo fullScreenAppinfo_; - utils::TestWindowInfo avoidBarInfo_; + Utils::TestWindowInfo fullScreenAppinfo_; + Utils::TestWindowInfo avoidBarInfo_; uint32_t leftAvoidW_; uint32_t leftAvoidH_; uint32_t topAvoidW_; @@ -200,7 +200,7 @@ void WindowImmersiveTest::SetUpTestCase() WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowImmersiveTest::TearDownTestCase() @@ -211,7 +211,7 @@ void WindowImmersiveTest::SetUp() { fullScreenAppinfo_ = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, // immersive setting .needAvoid = false, // immersive setting @@ -225,11 +225,11 @@ void WindowImmersiveTest::SetUp() .mode = WindowMode::WINDOW_MODE_FLOATING, }; // makesure left avoid win w < h - leftAvoidW_ = std::min(utils::displayRect_.width_, static_cast(utils::displayRect_.height_ * RATIO)); - leftAvoidH_ = utils::displayRect_.height_; + leftAvoidW_ = std::min(Utils::displayRect_.width_, static_cast(Utils::displayRect_.height_ * RATIO)); + leftAvoidH_ = Utils::displayRect_.height_; // makesure top avoid win h < w - topAvoidW_ = utils::displayRect_.width_; - topAvoidH_ = std::min(utils::displayRect_.height_, static_cast(utils::displayRect_.width_ * RATIO)); + topAvoidW_ = Utils::displayRect_.width_; + topAvoidH_ = std::min(Utils::displayRect_.height_, static_cast(Utils::displayRect_.width_ * RATIO)); WindowManager::GetInstance().RegisterSystemBarChangedListener(testSystemBarChangedListener_); activeWindows_.clear(); @@ -253,7 +253,7 @@ namespace { HWTEST_F(WindowImmersiveTest, ImmersiveTest01, Function | MediumTest | Level3) { fullScreenAppinfo_.name = "immer01"; - const sptr& window = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window); SetWindowSystemProps(window, TEST_PROPS_1); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -268,11 +268,11 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest01, Function | MediumTest | Level3) */ HWTEST_F(WindowImmersiveTest, ImmersiveTest02, Function | MediumTest | Level3) { - const sptr& window1 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window1); SetWindowSystemProps(window1, TEST_PROPS_1); fullScreenAppinfo_.name = "Immer02"; - const sptr& window2 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window2 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window2); SetWindowSystemProps(window2, TEST_PROPS_2); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -292,12 +292,12 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest02, Function | MediumTest | Level3) */ HWTEST_F(WindowImmersiveTest, ImmersiveTest03, Function | MediumTest | Level3) { - const sptr& window1 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window1); SetWindowSystemProps(window1, TEST_PROPS_1); fullScreenAppinfo_.name = "Immer03"; fullScreenAppinfo_.needAvoid = true; // no immersive setting - const sptr& window2 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window2 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window2); SetWindowSystemProps(window2, TEST_PROPS_2); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -316,7 +316,7 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest03, Function | MediumTest | Level3) HWTEST_F(WindowImmersiveTest, ImmersiveTest04, Function | MediumTest | Level3) { fullScreenAppinfo_.needAvoid = true; // no immersive setting - const sptr& window1 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window1); SetWindowSystemProps(window1, TEST_PROPS_1); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -338,7 +338,7 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest04, Function | MediumTest | Level3) HWTEST_F(WindowImmersiveTest, ImmersiveTest05, Function | MediumTest | Level3) { fullScreenAppinfo_.needAvoid = true; // no immersive setting - const sptr& window1 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window1); SetWindowSystemProps(window1, TEST_PROPS_1); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -362,7 +362,7 @@ HWTEST_F(WindowImmersiveTest, ImmersiveNegativeTest01, Function | MediumTest | L { WindowType::WINDOW_TYPE_KEYGUARD, SYS_BAR_PROP_1, SYS_BAR_REGION_NULL }, { WindowType::WINDOW_TYPE_POINTER, SYS_BAR_PROP_2, SYS_BAR_REGION_NULL }, }; - const sptr& window = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window); SetWindowSystemProps(window, TEST_PROPS_NEGATIVE); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -379,17 +379,17 @@ HWTEST_F(WindowImmersiveTest, ImmersiveNegativeTest01, Function | MediumTest | L HWTEST_F(WindowImmersiveTest, GetAvoidAreaByTypeTest01, Function | MediumTest | Level3) { // Add full screenwindow for call GetAvoidArea, and push_back in activeWindows_ - const sptr& win = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& win = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(win); // Test GetAvoidArea AvoidArea avoidarea; WMError ret = win->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidarea); ASSERT_EQ(WMError::WM_OK, ret); - ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.leftRect_)); - ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.rightRect_)); - ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.topRect_)); - ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.bottomRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.leftRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.rightRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.topRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.bottomRect_)); ASSERT_EQ(WMError::WM_OK, win->Hide()); } @@ -400,10 +400,10 @@ HWTEST_F(WindowImmersiveTest, GetAvoidAreaByTypeTest01, Function | MediumTest | */ HWTEST_F(WindowImmersiveTest, DockWindowTest01, Function | MediumTest | Level3) { - const sptr& dockWindow = utils::CreateDockWindow(); + const sptr& dockWindow = Utils::CreateDockWindow(); ASSERT_EQ(WMError::WM_OK, dockWindow->Show()); - const sptr& window = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppinfo_); usleep(WAIT_ASYNC_US); auto act = testSystemBarChangedListener_->tints_; diff --git a/wm/test/systemtest/window_input_method_test.cpp b/wm/test/systemtest/window_input_method_test.cpp index 222496d4..0f57c7f9 100644 --- a/wm/test/systemtest/window_input_method_test.cpp +++ b/wm/test/systemtest/window_input_method_test.cpp @@ -21,15 +21,15 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowInputMethodTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo inputMethodWindowInfo_; - utils::TestWindowInfo keyGuardWindowInfo_; + Utils::TestWindowInfo inputMethodWindowInfo_; + Utils::TestWindowInfo keyGuardWindowInfo_; }; void WindowInputMethodTest::SetUpTestCase() @@ -37,7 +37,7 @@ void WindowInputMethodTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowInputMethodTest::TearDownTestCase() @@ -48,7 +48,7 @@ void WindowInputMethodTest::SetUp() { inputMethodWindowInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -57,7 +57,7 @@ void WindowInputMethodTest::SetUp() }; keyGuardWindowInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_KEYGUARD, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -79,7 +79,7 @@ namespace { HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Level3) { inputMethodWindowInfo_.name = "input_method.1"; - const sptr& window = utils::CreateTestWindow(inputMethodWindowInfo_); + const sptr& window = Utils::CreateTestWindow(inputMethodWindowInfo_); ASSERT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, window->GetType()); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WMError::WM_OK, window->Hide()); @@ -93,7 +93,7 @@ HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Lev HWTEST_F(WindowInputMethodTest, InputMethodWindow02, Function | MediumTest | Level3) { keyGuardWindowInfo_.name = "keyGuard.1"; - const sptr& window = utils::CreateTestWindow(keyGuardWindowInfo_); + const sptr& window = Utils::CreateTestWindow(keyGuardWindowInfo_); ASSERT_EQ(WindowType::WINDOW_TYPE_KEYGUARD, window->GetType()); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WMError::WM_OK, window->Hide()); @@ -108,12 +108,12 @@ HWTEST_F(WindowInputMethodTest, InputMethodWindow03, Function | MediumTest | Lev { inputMethodWindowInfo_.name = "input_method.2"; keyGuardWindowInfo_.name = "keyGuard.2"; - const sptr& inputMethodWindow = utils::CreateTestWindow(inputMethodWindowInfo_); - const sptr& keyGuardWindow = utils::CreateTestWindow(keyGuardWindowInfo_); + const sptr& inputMethodWindow = Utils::CreateTestWindow(inputMethodWindowInfo_); + const sptr& keyGuardWindow = Utils::CreateTestWindow(keyGuardWindowInfo_); keyGuardWindow->Show(); inputMethodWindow->Show(); - ASSERT_TRUE(utils::RectEqualTo(keyGuardWindow, utils::displayRect_)); - ASSERT_TRUE(utils::RectEqualTo(inputMethodWindow, utils::customAppRect_)); + ASSERT_TRUE(Utils::RectEqualTo(keyGuardWindow, Utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(inputMethodWindow, Utils::customAppRect_)); } } // namespace } // namespace Rosen diff --git a/wm/test/systemtest/window_input_test.cpp b/wm/test/systemtest/window_input_test.cpp index b1577c60..5f57f2a0 100644 --- a/wm/test/systemtest/window_input_test.cpp +++ b/wm/test/systemtest/window_input_test.cpp @@ -24,14 +24,14 @@ namespace Rosen { namespace { constexpr uint32_t WAIT_ASYNC_US = 100000; // 100ms } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowInputTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo fullScreenWindow_; + Utils::TestWindowInfo fullScreenWindow_; }; void WindowInputTest::SetUpTestCase() @@ -39,7 +39,7 @@ void WindowInputTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowInputTest::TearDownTestCase() @@ -50,7 +50,7 @@ void WindowInputTest::SetUp() { fullScreenWindow_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -72,7 +72,7 @@ namespace { HWTEST_F(WindowInputTest, SetTouchHotAreas01, Function | MediumTest | Level3) { fullScreenWindow_.name = "window_hot_areas.1"; - const sptr& window = utils::CreateTestWindow(fullScreenWindow_); + const sptr& window = Utils::CreateTestWindow(fullScreenWindow_); ASSERT_EQ(WMError::WM_OK, window->Show()); std::vector requestedTouchHotAreas; @@ -121,7 +121,7 @@ HWTEST_F(WindowInputTest, SetTouchHotAreas01, Function | MediumTest | Level3) HWTEST_F(WindowInputTest, SetTouchHotAreas02, Function | MediumTest | Level3) { fullScreenWindow_.name = "window_hot_areas.2"; - const sptr& window = utils::CreateTestWindow(fullScreenWindow_); + const sptr& window = Utils::CreateTestWindow(fullScreenWindow_); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_ASYNC_US); diff --git a/wm/test/systemtest/window_layout_test.cpp b/wm/test/systemtest/window_layout_test.cpp index 65f0313b..d84a018b 100644 --- a/wm/test/systemtest/window_layout_test.cpp +++ b/wm/test/systemtest/window_layout_test.cpp @@ -22,7 +22,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowLayoutTest : public testing::Test { public: static void SetUpTestCase(); @@ -44,30 +44,30 @@ void WindowLayoutTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); // calc expected rects Rect expected = { // 0. only statusBar 0, - utils::statusBarRect_.height_, - utils::displayRect_.width_, - utils::displayRect_.height_ - utils::statusBarRect_.height_, + Utils::statusBarRect_.height_, + Utils::displayRect_.width_, + Utils::displayRect_.height_ - Utils::statusBarRect_.height_, }; fullScreenExpecteds_.push_back(expected); expected = { // 1. both statusBar and naviBar 0, - utils::statusBarRect_.height_, - utils::displayRect_.width_, - utils::displayRect_.height_ - utils::statusBarRect_.height_ - utils::naviBarRect_.height_, + Utils::statusBarRect_.height_, + Utils::displayRect_.width_, + Utils::displayRect_.height_ - Utils::statusBarRect_.height_ - Utils::naviBarRect_.height_, }; fullScreenExpecteds_.push_back(expected); expected = { // 2. only naviBar 0, 0, - utils::displayRect_.width_, - utils::displayRect_.height_ - utils::naviBarRect_.height_, + Utils::displayRect_.width_, + Utils::displayRect_.height_ - Utils::naviBarRect_.height_, }; fullScreenExpecteds_.push_back(expected); } @@ -102,7 +102,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3) WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -111,11 +111,11 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -126,24 +126,24 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutWindow02, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - Rect res = utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_); + Rect res = Utils::GetFloatingLimitedRect(Utils::customAppRect_, virtualPixelRatio_); if (window->IsDecorEnable()) { - ASSERT_TRUE(utils::RectEqualTo(window, utils::GetDecorateRect(res, virtualPixelRatio_))); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - ASSERT_TRUE(utils::RectEqualTo(window, res)); + ASSERT_TRUE(Utils::RectEqualTo(window, res)); } ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -156,40 +156,40 @@ HWTEST_F(WindowLayoutTest, LayoutWindow02, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, LayoutWindow04, Function | MediumTest | Level3) { // app window - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, .parentLimit = false, .parentName = "", }; - sptr appWin = utils::CreateTestWindow(info); + sptr appWin = Utils::CreateTestWindow(info); activeWindows_.push_back(appWin); // statusBar window - sptr statBar = utils::CreateStatusBarWindow(); + sptr statBar = Utils::CreateStatusBarWindow(); activeWindows_.push_back(statBar); ASSERT_EQ(WMError::WM_OK, appWin->Show()); - Rect res = utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_); + Rect res = Utils::GetFloatingLimitedRect(Utils::customAppRect_, virtualPixelRatio_); if (appWin->IsDecorEnable()) { - ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetDecorateRect(res, virtualPixelRatio_))); + ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - ASSERT_TRUE(utils::RectEqualTo(appWin, res)); + ASSERT_TRUE(Utils::RectEqualTo(appWin, res)); } ASSERT_EQ(WMError::WM_OK, statBar->Show()); if (appWin->IsDecorEnable()) { - ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetDecorateRect(res, virtualPixelRatio_))); + ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - ASSERT_TRUE(utils::RectEqualTo(appWin, res)); + ASSERT_TRUE(Utils::RectEqualTo(appWin, res)); } ASSERT_EQ(WMError::WM_OK, statBar->Hide()); if (appWin->IsDecorEnable()) { - ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetDecorateRect(res, virtualPixelRatio_))); + ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - ASSERT_TRUE(utils::RectEqualTo(appWin, res)); + ASSERT_TRUE(Utils::RectEqualTo(appWin, res)); } } @@ -201,33 +201,33 @@ HWTEST_F(WindowLayoutTest, LayoutWindow04, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, LayoutWindow06, Function | MediumTest | Level3) { // statusBar window - sptr statBar = utils::CreateStatusBarWindow(); + sptr statBar = Utils::CreateStatusBarWindow(); activeWindows_.push_back(statBar); // naviBar window - sptr naviBar = utils::CreateNavigationBarWindow(); + sptr naviBar = Utils::CreateNavigationBarWindow(); activeWindows_.push_back(naviBar); // sys window - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_PANEL, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, .parentLimit = true, .parentName = "", }; - sptr sysWin = utils::CreateTestWindow(info); + sptr sysWin = Utils::CreateTestWindow(info); activeWindows_.push_back(sysWin); ASSERT_EQ(WMError::WM_OK, statBar->Show()); ASSERT_EQ(WMError::WM_OK, sysWin->Show()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_)); ASSERT_EQ(WMError::WM_OK, naviBar->Show()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_)); ASSERT_EQ(WMError::WM_OK, statBar->Hide()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_)); } /** @@ -238,33 +238,33 @@ HWTEST_F(WindowLayoutTest, LayoutWindow06, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, LayoutWindow07, Function | MediumTest | Level3) { // statusBar window - sptr statBar = utils::CreateStatusBarWindow(); + sptr statBar = Utils::CreateStatusBarWindow(); activeWindows_.push_back(statBar); // naviBar window - sptr naviBar = utils::CreateNavigationBarWindow(); + sptr naviBar = Utils::CreateNavigationBarWindow(); activeWindows_.push_back(naviBar); // sys window - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_PANEL, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, .parentLimit = true, .parentName = "", }; - sptr sysWin = utils::CreateTestWindow(info); + sptr sysWin = Utils::CreateTestWindow(info); activeWindows_.push_back(sysWin); ASSERT_EQ(WMError::WM_OK, statBar->Show()); ASSERT_EQ(WMError::WM_OK, sysWin->Show()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::customAppRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_)); ASSERT_EQ(WMError::WM_OK, naviBar->Show()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::customAppRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_)); ASSERT_EQ(WMError::WM_OK, statBar->Hide()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::customAppRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_)); } /** @@ -274,7 +274,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow07, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -283,11 +283,11 @@ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -298,7 +298,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -307,17 +307,17 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Resize(2u, 2u)); // 2: custom min size Rect finalExcept = { expect.posX_, expect.posY_, 2u, 2u}; // 2: custom min size - finalExcept = utils::GetFloatingLimitedRect(finalExcept, virtualPixelRatio_); - ASSERT_TRUE(utils::RectEqualTo(window, finalExcept)); + finalExcept = Utils::GetFloatingLimitedRect(finalExcept, virtualPixelRatio_); + ASSERT_TRUE(Utils::RectEqualTo(window, finalExcept)); ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -328,7 +328,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -337,15 +337,15 @@ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Maximize()); - ASSERT_TRUE(utils::RectEqualTo(window, utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::displayRect_)); ASSERT_EQ(WMError::WM_OK, window->Recover()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Minimize()); ASSERT_EQ(WMError::WM_OK, window->Close()); } @@ -357,7 +357,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -367,47 +367,47 @@ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3) .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); // init tile window rects and get max tile window num - utils::InitTileWindowRects(window); - uint32_t maxTileNum = utils::GetMaxTileWinNum(); + Utils::InitTileWindowRects(window); + uint32_t maxTileNum = Utils::GetMaxTileWinNum(); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, utils::singleTileRect_)); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::singleTileRect_)); info.name = "test1"; - const sptr& test1 = utils::CreateTestWindow(info); + const sptr& test1 = Utils::CreateTestWindow(info); activeWindows_.push_back(test1); ASSERT_EQ(WMError::WM_OK, test1->Show()); usleep(WAIT_SYANC_US); if (maxTileNum == 1) { - ASSERT_TRUE(utils::RectEqualTo(test1, utils::singleTileRect_)); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::singleTileRect_)); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); return; } - ASSERT_TRUE(utils::RectEqualTo(window, utils::doubleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::doubleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[1])); info.name = "test2"; - const sptr& test2 = utils::CreateTestWindow(info); + const sptr& test2 = Utils::CreateTestWindow(info); activeWindows_.push_back(test2); ASSERT_EQ(WMError::WM_OK, test2->Show()); usleep(WAIT_SYANC_US); if (maxTileNum == 2) { - ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test2, utils::doubleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::doubleTileRects_[1])); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); return; } - ASSERT_TRUE(utils::RectEqualTo(window, utils::tripleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test1, utils::tripleTileRects_[1])); - ASSERT_TRUE(utils::RectEqualTo(test2, utils::tripleTileRects_[2])); // 2 is second rect idx + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::tripleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::tripleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::tripleTileRects_[2])); // 2 is second rect idx WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); } @@ -418,7 +418,7 @@ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {-1, -100, -1, -100}, // -1, -100, -1, -100 is typical negative case nums .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -427,45 +427,45 @@ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); ASSERT_EQ(WMError::WM_OK, window->Show()); // init tile window rects and get max tile window num - utils::InitTileWindowRects(window); - uint32_t maxTileNum = utils::GetMaxTileWinNum(); + Utils::InitTileWindowRects(window); + uint32_t maxTileNum = Utils::GetMaxTileWinNum(); usleep(WAIT_SYANC_US); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, utils::singleTileRect_)); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::singleTileRect_)); info.name = "test1"; - const sptr& test1 = utils::CreateTestWindow(info); + const sptr& test1 = Utils::CreateTestWindow(info); activeWindows_.push_back(test1); ASSERT_EQ(WMError::WM_OK, test1->Show()); usleep(WAIT_SYANC_US); if (maxTileNum == 1) { - ASSERT_TRUE(utils::RectEqualTo(test1, utils::singleTileRect_)); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::singleTileRect_)); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); return; } - ASSERT_TRUE(utils::RectEqualTo(window, utils::doubleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::doubleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[1])); info.name = "test2"; - const sptr& test2 = utils::CreateTestWindow(info); + const sptr& test2 = Utils::CreateTestWindow(info); activeWindows_.push_back(test2); ASSERT_EQ(WMError::WM_OK, test2->Show()); usleep(WAIT_SYANC_US); if (maxTileNum == 2) { - ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test2, utils::doubleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::doubleTileRects_[1])); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); return; } - ASSERT_TRUE(utils::RectEqualTo(window, utils::tripleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test1, utils::tripleTileRects_[1])); - ASSERT_TRUE(utils::RectEqualTo(test2, utils::tripleTileRects_[2])); // 2 is second rect idx + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::tripleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::tripleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::tripleTileRects_[2])); // 2 is second rect idx WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); } @@ -476,7 +476,7 @@ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutNegative01, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -485,12 +485,12 @@ HWTEST_F(WindowLayoutTest, LayoutNegative01, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); } /** @@ -502,7 +502,7 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, Function | MediumTest | Level3) { const uint32_t negativeW = 0; const uint32_t negativeH = 0; - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -511,17 +511,17 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); window->Resize(negativeW, negativeH); usleep(WAIT_SYANC_US); Rect expect2 = {expect.posX_, expect.posY_, negativeW, negativeH}; - expect2 = utils::CalcLimitedRect(expect2, virtualPixelRatio_); - ASSERT_TRUE(utils::RectEqualTo(window, expect2)); + expect2 = Utils::CalcLimitedRect(expect2, virtualPixelRatio_); + ASSERT_TRUE(Utils::RectEqualTo(window, expect2)); } } } // namespace Rosen diff --git a/wm/test/systemtest/window_mode_support_info_test.cpp b/wm/test/systemtest/window_mode_support_info_test.cpp index bd93d8e9..a6289f2e 100644 --- a/wm/test/systemtest/window_mode_support_info_test.cpp +++ b/wm/test/systemtest/window_mode_support_info_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -22,15 +22,15 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowModeSupportInfoTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo fullScreenAppInfo_; - utils::TestWindowInfo floatingScreenAppInfo_; + Utils::TestWindowInfo fullAppInfo_1_; + Utils::TestWindowInfo fullAppInfo_2_; private: static constexpr uint32_t WAIT_SYANC_US = 100000; }; @@ -40,7 +40,7 @@ void WindowModeSupportInfoTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowModeSupportInfoTest::TearDownTestCase() @@ -49,18 +49,18 @@ void WindowModeSupportInfoTest::TearDownTestCase() void WindowModeSupportInfoTest::SetUp() { - fullScreenAppInfo_ = { + fullAppInfo_1_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, .parentLimit = false, .parentName = "", }; - floatingScreenAppInfo_ = { - .name = "FloatingWindow", - .rect = utils::customAppRect_, + fullAppInfo_2_ = { + .name = "FullWindow2", + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -76,99 +76,101 @@ void WindowModeSupportInfoTest::TearDown() namespace { /** * @tc.name: WindowModeSupportInfo01 - * @tc.desc: SetModeSupportInfo | GetModeSupportInfo + * @tc.desc: SetRequestModeSupportInfo | GetRequestModeSupportInfo * @tc.type: FUNC */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); - - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetModeSupportInfo()); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); + + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestModeSupportInfo()); window->Destroy(); } /** * @tc.name: WindowModeSupportInfo02 - * @tc.desc: modeSupportInfo test for single window + * @tc.desc: modeSupportInfo test for single window, only support fullScreen mode * @tc.type: FUNC */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | - WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - - window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); window->Destroy(); } /** * @tc.name: WindowModeSupportInfo03 - * @tc.desc: modeSupportInfo test for single window in case current window mode is not supported. + * @tc.desc: modeSupportInfo test for single window, support both fullScreen and floating mode * @tc.type: FUNC */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); + + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | + WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); + + window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); + window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); + window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); + ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); + + window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); + ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); + + ASSERT_EQ(WMError::WM_OK, window->Hide()); window->Destroy(); } /** * @tc.name: WindowModeSupportInfo04 - * @tc.desc: modeSupportInfo test for layout cascade + * @tc.desc: modeSupportInfo test for single window, window mode is not supported when show, show failed * @tc.type: FUNC */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3) { - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); - window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - const sptr& window2 = utils::CreateTestWindow(utils::TestWindowInfo { - .name = "FullWindow2", - .rect = utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = false, - .parentLimit = false, - .parentName = "", - }); - window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + ASSERT_NE(WMError::WM_OK, window->Show()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); + window->Destroy(); +} + +/** + * @tc.name: WindowModeSupportInfo05 + * @tc.desc: modeSupportInfo test for layout cascade + * @tc.type: FUNC + */ +HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3) +{ + const sptr& window1 = Utils::CreateTestWindow(fullAppInfo_1_); + window1->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + const sptr& window2 = Utils::CreateTestWindow(fullAppInfo_2_); + window2->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); ASSERT_EQ(WMError::WM_OK, window1->Show()); ASSERT_EQ(WMError::WM_OK, window2->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); @@ -182,14 +184,14 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo05 + * @tc.name: WindowModeSupportInfo06 * @tc.desc: modeSupportInfo test for layout tile * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); @@ -200,38 +202,6 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); usleep(WAIT_SYANC_US); } - -/** - * @tc.name: WindowModeSupportInfo06 - * @tc.desc: modeSupportInfo test for split - * @tc.type: FUNC - */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3) -{ - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); - window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); - const sptr& window2 = utils::CreateTestWindow(utils::TestWindowInfo { - .name = "FullWindow2", - .rect = utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = false, - .parentLimit = false, - .parentName = "", - }); - window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - ASSERT_EQ(WMError::WM_OK, window1->Show()); - ASSERT_EQ(WMError::WM_OK, window2->Show()); - usleep(WAIT_SYANC_US); - - window1->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, window1->GetMode()); - ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window2->GetMode()); - - window1->Destroy(); - window2->Destroy(); -} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wm/test/systemtest/window_move_drag_test.cpp b/wm/test/systemtest/window_move_drag_test.cpp index 214865ea..6b0de20f 100644 --- a/wm/test/systemtest/window_move_drag_test.cpp +++ b/wm/test/systemtest/window_move_drag_test.cpp @@ -30,7 +30,7 @@ namespace { constexpr float DRAG_HOTZONE_RATIO = 0.6; constexpr int WAIT_SYANC_MS = 100000; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowMoveDragTest : public testing::Test { public: static void SetUpTestCase(); @@ -81,7 +81,7 @@ void WindowMoveDragTest::SetUp() WLOGFI("GetDefaultDisplay: id %{public}llu, w %{public}d, h %{public}d, fps %{public}u\n", (unsigned long long)display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); hotZone_ = static_cast(HOTZONE * virtualPixelRatio_); @@ -127,19 +127,19 @@ void WindowMoveDragTest::DoMoveOrDrag(bool isMove, bool isDrag) std::shared_ptr pointerEvent = CreatePointerEvent(startPointX_, startPointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_DOWN); window_->ConsumePointerEvent(pointerEvent); - ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), startPointRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(window_->GetRect(), startPointRect_)); pointerEvent = CreatePointerEvent(pointX_, pointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_MOVE); window_->ConsumePointerEvent(pointerEvent); CalExpectRects(); usleep(WAIT_SYANC_MS); - ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), expectRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(window_->GetRect(), expectRect_)); ASSERT_EQ(isMove, window_->startMoveFlag_); ASSERT_EQ(isDrag, window_->startDragFlag_); pointerEvent = CreatePointerEvent(pointX_, pointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_UP); window_->ConsumePointerEvent(pointerEvent); - ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), expectRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(window_->GetRect(), expectRect_)); } void WindowMoveDragTest::CalExpectRects() @@ -180,7 +180,7 @@ void WindowMoveDragTest::CalExpectRects() hasStartMove_ = false; } } - bool isVertical = (utils::displayRect_.width_ < utils::displayRect_.height_) ? true : false; + bool isVertical = (Utils::displayRect_.width_ < Utils::displayRect_.height_) ? true : false; expectRect_ = WindowHelper::GetFixedWindowRectByLimitSize(oriRect, startPointRect_, isVertical, virtualPixelRatio_); } diff --git a/wm/test/systemtest/window_multi_ability_test.cpp b/wm/test/systemtest/window_multi_ability_test.cpp index 48db7bc5..0d8c9811 100644 --- a/wm/test/systemtest/window_multi_ability_test.cpp +++ b/wm/test/systemtest/window_multi_ability_test.cpp @@ -23,7 +23,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowMultiAbilityTest : public testing::Test { public: static void SetUpTestCase(); @@ -54,7 +54,7 @@ static void ShowHideWindowSceneCallable(int i) { unsigned int sleepTimeMs = i * SLEEP_MS; usleep(sleepTimeMs); - sptr scene = utils::CreateWindowScene(); + sptr scene = Utils::CreateWindowScene(); const int loop = 10; int j = 0; for (; j < loop; j++) { @@ -74,7 +74,7 @@ static void CreateDestroyWindowSceneCallable(int i) int j = 0; for (; j < loop; j++) { usleep(sleepTimeMs); - sptr scene = utils::CreateWindowScene(); + sptr scene = Utils::CreateWindowScene(); usleep(sleepTimeMs); ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); usleep(sleepTimeMs); @@ -94,11 +94,11 @@ static void CreateDestroyWindowSceneCallable(int i) */ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow01, Function | MediumTest | Level2) { - sptr scene1 = utils::CreateWindowScene(); - sptr scene2 = utils::CreateWindowScene(); - sptr scene3 = utils::CreateWindowScene(); - sptr scene4 = utils::CreateWindowScene(); - sptr scene5 = utils::CreateWindowScene(); + sptr scene1 = Utils::CreateWindowScene(); + sptr scene2 = Utils::CreateWindowScene(); + sptr scene3 = Utils::CreateWindowScene(); + sptr scene4 = Utils::CreateWindowScene(); + sptr scene5 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene1->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene2->GoForeground()); @@ -162,27 +162,27 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow03, Function | MediumTest | L */ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow04, Function | MediumTest | Level3) { - sptr scene1 = utils::CreateWindowScene(); + sptr scene1 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene1->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene1->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy()); - sptr scene2 = utils::CreateWindowScene(); + sptr scene2 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene2->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene2->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene2->GoDestroy()); - sptr scene3 = utils::CreateWindowScene(); + sptr scene3 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene3->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene3->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy()); - sptr scene4 = utils::CreateWindowScene(); + sptr scene4 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene4->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene4->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene4->GoDestroy()); - sptr scene5 = utils::CreateWindowScene(); + sptr scene5 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene5->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene5->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene5->GoDestroy()); @@ -195,19 +195,19 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow04, Function | MediumTest | L */ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow05, Function | MediumTest | Level3) { - sptr scene1 = utils::CreateWindowScene(); + sptr scene1 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene1->GoForeground()); - sptr scene2 = utils::CreateWindowScene(); - sptr scene3 = utils::CreateWindowScene(); + sptr scene2 = Utils::CreateWindowScene(); + sptr scene3 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene3->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene1->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy()); - sptr scene4 = utils::CreateWindowScene(); + sptr scene4 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene3->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene2->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene4->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene2->GoBackground()); - sptr scene5 = utils::CreateWindowScene(); + sptr scene5 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy()); ASSERT_EQ(WMError::WM_OK, scene5->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene5->GoBackground()); diff --git a/wm/test/systemtest/window_occupied_area_change_test.cpp b/wm/test/systemtest/window_occupied_area_change_test.cpp index 4fea3ec0..8162cb9b 100644 --- a/wm/test/systemtest/window_occupied_area_change_test.cpp +++ b/wm/test/systemtest/window_occupied_area_change_test.cpp @@ -26,7 +26,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowOccupiedAreaChangeTest"}; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_ASYNC_US = 100000; // 100000us class TestOccupiedAreaChangeListener : public IOccupiedAreaChangeListener { @@ -43,8 +43,8 @@ public: virtual void SetUp() override; virtual void TearDown() override; static sptr testOccupiedAreaChangeListener_; - utils::TestWindowInfo fullScreenAppInfo_; - utils::TestWindowInfo imeAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo imeAppInfo_; }; sptr WindowOccupiedAreaChangeTest::testOccupiedAreaChangeListener_ = @@ -65,7 +65,7 @@ void WindowOccupiedAreaChangeTest::SetUpTestCase() WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowOccupiedAreaChangeTest::TearDownTestCase() @@ -76,7 +76,7 @@ void WindowOccupiedAreaChangeTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -85,7 +85,7 @@ void WindowOccupiedAreaChangeTest::SetUp() }; imeAppInfo_ = { .name = "ImeWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, .mode = WindowMode::WINDOW_MODE_FLOATING, }; @@ -104,13 +104,13 @@ namespace { HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest01, Function | MediumTest | Level3) { fullScreenAppInfo_.name = "KeyboardHeightChangeTest01"; - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_NE(nullptr, window1); window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_); imeAppInfo_.name = "imeWindow1"; imeAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& window2 = utils::CreateTestWindow(imeAppInfo_); + const sptr& window2 = Utils::CreateTestWindow(imeAppInfo_); ASSERT_NE(nullptr, window2); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -133,13 +133,13 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest01, Function | Me HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest02, Function | MediumTest | Level3) { fullScreenAppInfo_.name = "KeyboardHeightChangeTest02"; - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_NE(nullptr, window1); window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_); imeAppInfo_.name = "imeWindow2"; imeAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& window2 = utils::CreateTestWindow(imeAppInfo_); + const sptr& window2 = Utils::CreateTestWindow(imeAppInfo_); ASSERT_NE(nullptr, window2); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -162,13 +162,13 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest02, Function | Me HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest03, Function | MediumTest | Level3) { fullScreenAppInfo_.name = "KeyboardHeightChangeTest03"; - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_NE(nullptr, window1); window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_); imeAppInfo_.name = "imeWindow3"; imeAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& window2 = utils::CreateTestWindow(imeAppInfo_); + const sptr& window2 = Utils::CreateTestWindow(imeAppInfo_); ASSERT_NE(nullptr, window2); ASSERT_EQ(WMError::WM_OK, window1->Show()); diff --git a/wm/test/systemtest/window_rotation_test.cpp b/wm/test/systemtest/window_rotation_test.cpp index 5b6d390a..b2bab19c 100644 --- a/wm/test/systemtest/window_rotation_test.cpp +++ b/wm/test/systemtest/window_rotation_test.cpp @@ -27,7 +27,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class DisplayListener : public DisplayManager::IDisplayListener { public: virtual void OnCreate(DisplayId) override; @@ -51,7 +51,7 @@ public: virtual void SetUp() override; virtual void TearDown() override; std::vector> activeWindows_; - utils::TestWindowInfo fullInfo_; + Utils::TestWindowInfo fullInfo_; sptr displayListener_; sptr screenListener_; private: @@ -97,7 +97,7 @@ void WindowRotationTest::SetUp() { fullInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -132,7 +132,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest1, Function | MediumTest | Level3 { fullInfo_.name = "fullscreen.1"; fullInfo_.orientation_ = Orientation::UNSPECIFIED; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); @@ -163,7 +163,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest2, Function | MediumTest | Level3 { fullInfo_.name = "fullscreen.2"; fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); @@ -201,7 +201,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest3, Function | MediumTest | Level3 fullInfo_.name = "fullscreen.4"; fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL; fullInfo_.mode = WindowMode::WINDOW_MODE_FLOATING; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); fullInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); @@ -233,7 +233,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest4, Function | MediumTest | Level3 defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL); fullInfo_.name = "fullscreen.5"; fullInfo_.orientation_ = Orientation::HORIZONTAL; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); @@ -276,7 +276,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest5, Function | MediumTest | Level3 defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL); fullInfo_.name = "fullscreen.5"; fullInfo_.orientation_ = Orientation::HORIZONTAL; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); diff --git a/wm/test/systemtest/window_split_immersive_test.cpp b/wm/test/systemtest/window_split_immersive_test.cpp index 61b305f8..7a899cb5 100644 --- a/wm/test/systemtest/window_split_immersive_test.cpp +++ b/wm/test/systemtest/window_split_immersive_test.cpp @@ -23,7 +23,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowSplitImmersiveTest : public testing::Test { public: @@ -35,8 +35,8 @@ public: void HideAndUnregister(const sptr& fullWindow, const sptr& priWindow, const sptr& top); std::vector> activeWindows_; - utils::TestWindowInfo fullInfo_; - utils::TestWindowInfo splitInfo_; + Utils::TestWindowInfo fullInfo_; + Utils::TestWindowInfo splitInfo_; private: static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time @@ -54,7 +54,7 @@ void WindowSplitImmersiveTest::SetUp() { fullInfo_ = { .name = "fullscreen.1", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -64,7 +64,7 @@ void WindowSplitImmersiveTest::SetUp() splitInfo_ = { .name = "primary.1", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -92,14 +92,14 @@ namespace { HWTEST_F(WindowSplitImmersiveTest, SplitImmersive01, Function | MediumTest | Level3) { // create fullscreen win and show - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); // enter split mode splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); diff --git a/wm/test/systemtest/window_split_test.cpp b/wm/test/systemtest/window_split_test.cpp index 56f569a3..18ce4183 100644 --- a/wm/test/systemtest/window_split_test.cpp +++ b/wm/test/systemtest/window_split_test.cpp @@ -21,7 +21,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowSplitTest : public testing::Test { public: static void SetUpTestCase(); @@ -29,8 +29,8 @@ public: virtual void SetUp() override; virtual void TearDown() override; std::vector> activeWindows_; - utils::TestWindowInfo fullInfo_; - utils::TestWindowInfo splitInfo_; + Utils::TestWindowInfo fullInfo_; + Utils::TestWindowInfo splitInfo_; private: static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time @@ -48,7 +48,7 @@ void WindowSplitTest::SetUp() { fullInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -58,7 +58,7 @@ void WindowSplitTest::SetUp() splitInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -89,12 +89,12 @@ HWTEST_F(WindowSplitTest, SplitWindow01, Function | MediumTest | Level3) splitInfo_.name = "primary.1"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -120,11 +120,11 @@ HWTEST_F(WindowSplitTest, SplitWindow02, Function | MediumTest | Level3) splitInfo_.name = "secondary.2"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& secWindow = utils::CreateTestWindow(splitInfo_); + const sptr& secWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(secWindow); ASSERT_EQ(WMError::WM_OK, secWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -150,21 +150,21 @@ HWTEST_F(WindowSplitTest, SplitScreen03, Function | MediumTest | Level3) splitInfo_.name = "primary.3"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - ASSERT_TRUE(utils::InitSplitRects()); + ASSERT_TRUE(Utils::InitSplitRects()); - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - utils::UpdateSplitRects(fullWindow); + Utils::UpdateSplitRects(fullWindow); - ASSERT_TRUE(utils::RectEqualTo(fullWindow, utils::splitRects_.secondaryRect)); - ASSERT_TRUE(utils::RectEqualTo(priWindow, utils::splitRects_.primaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(fullWindow, Utils::splitRects_.secondaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(priWindow, Utils::splitRects_.primaryRect)); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); @@ -183,21 +183,21 @@ HWTEST_F(WindowSplitTest, SplitScreen04, Function | MediumTest | Level3) splitInfo_.name = "secondary.4"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; - ASSERT_TRUE(utils::InitSplitRects()); + ASSERT_TRUE(Utils::InitSplitRects()); - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& secWindow = utils::CreateTestWindow(splitInfo_); + const sptr& secWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(secWindow); ASSERT_EQ(WMError::WM_OK, secWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - utils::UpdateSplitRects(fullWindow); + Utils::UpdateSplitRects(fullWindow); - ASSERT_TRUE(utils::RectEqualTo(fullWindow, utils::splitRects_.primaryRect)); - ASSERT_TRUE(utils::RectEqualTo(secWindow, utils::splitRects_.secondaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(fullWindow, Utils::splitRects_.primaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(secWindow, Utils::splitRects_.secondaryRect)); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); @@ -216,12 +216,12 @@ HWTEST_F(WindowSplitTest, SplitScreen05, Function | MediumTest | Level3) splitInfo_.name = "primary.5"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -229,13 +229,13 @@ HWTEST_F(WindowSplitTest, SplitScreen05, Function | MediumTest | Level3) ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode()); ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode()); - utils::TestWindowInfo dividerInfo; + Utils::TestWindowInfo dividerInfo; dividerInfo.name = "divider0"; dividerInfo.type = WindowType::WINDOW_TYPE_DOCK_SLICE; dividerInfo.mode = WindowMode::WINDOW_MODE_FLOATING; dividerInfo.focusable_ = false; - const sptr& divider = utils::CreateTestWindow(dividerInfo); + const sptr& divider = Utils::CreateTestWindow(dividerInfo); activeWindows_.push_back(divider); ASSERT_EQ(WMError::WM_OK, divider->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -271,26 +271,23 @@ HWTEST_F(WindowSplitTest, SplitScreen06, Function | MediumTest | Level3) splitInfo_.name = "primary.6"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode()); - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode()); - - utils::TestWindowInfo dividerInfo; + Utils::TestWindowInfo dividerInfo; dividerInfo.name = "divider0"; dividerInfo.type = WindowType::WINDOW_TYPE_DOCK_SLICE; dividerInfo.mode = WindowMode::WINDOW_MODE_FLOATING; dividerInfo.focusable_ = false; - const sptr& divider = utils::CreateTestWindow(dividerInfo); + const sptr& divider = Utils::CreateTestWindow(dividerInfo); activeWindows_.push_back(divider); ASSERT_EQ(WMError::WM_OK, divider->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -300,18 +297,22 @@ HWTEST_F(WindowSplitTest, SplitScreen06, Function | MediumTest | Level3) int32_t posX, posY; posX = posY = 0; std::shared_ptr pointerEvent = - utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_DOWN); + Utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_DOWN); divider->ConsumePointerEvent(pointerEvent); sleep(SPLIT_TEST_SLEEP_S); - posY += 10; - pointerEvent = utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_MOVE); + if (rect.width_ < rect.height_) { + posX += 10; + } else { + posY += 10; + } + pointerEvent = Utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_MOVE); divider->ConsumePointerEvent(pointerEvent); sleep(SPLIT_TEST_SLEEP_S); Rect moveRect = divider->GetRect(); ASSERT_TRUE(rect.posX_ != moveRect.posX_ || rect.posY_ != moveRect.posY_); - pointerEvent = utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_UP); + pointerEvent = Utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_UP); divider->ConsumePointerEvent(pointerEvent); sleep(SPLIT_TEST_SLEEP_S); Rect newRect = divider->GetRect(); diff --git a/wm/test/systemtest/window_touch_outside_test.cpp b/wm/test/systemtest/window_touch_outside_test.cpp index 0a4e197f..89727851 100644 --- a/wm/test/systemtest/window_touch_outside_test.cpp +++ b/wm/test/systemtest/window_touch_outside_test.cpp @@ -26,16 +26,16 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_CALLBACK_US = 10000; // 10000 us class WindowTouchOutsideTestListener : public ITouchOutsideListener { public: - void OnTouchOutside() override + void OnTouchOutside() const override { isTouchOutside_ = true; } - bool isTouchOutside_ { false }; + mutable bool isTouchOutside_ { false }; }; class WindowTouchOutsideTest : public testing::Test { @@ -47,9 +47,9 @@ public: static sptr windowlistener1_; static sptr windowlistener2_; - utils::TestWindowInfo firstWindowInfo_; - utils::TestWindowInfo secondWindowInfo_; - utils::TestWindowInfo thirdWindowInfo_; + Utils::TestWindowInfo firstWindowInfo_; + Utils::TestWindowInfo secondWindowInfo_; + Utils::TestWindowInfo thirdWindowInfo_; }; sptr WindowTouchOutsideTest::windowlistener1_ = @@ -106,13 +106,13 @@ void WindowTouchOutsideTest::TearDownTestCase() namespace { /** - * @tc.name: onTouchIutside + * @tc.name: onTouchInside * @tc.desc: can't not receive a inside touch event * @tc.type: FUNC */ -HWTEST_F(WindowTouchOutsideTest, onTouchIutside, Function | MediumTest | Level3) +HWTEST_F(WindowTouchOutsideTest, onTouchInside, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener1_); firstWindow->Show(); SingletonContainer::Get().ProcessPointDown(firstWindow->GetWindowId()); @@ -128,9 +128,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchIutside, Function | MediumTest | Level3) */ HWTEST_F(WindowTouchOutsideTest, onTouchOutside, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener1_); - const sptr &secondWindow = utils::CreateTestWindow(secondWindowInfo_); + const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); firstWindow->Show(); secondWindow->Show(); SingletonContainer::Get().ProcessPointDown(secondWindow->GetWindowId()); @@ -147,9 +147,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutside, Function | MediumTest | Level3) */ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener1_); - const sptr &secondWindow = utils::CreateTestWindow(secondWindowInfo_); + const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); secondWindow->Show(); SingletonContainer::Get().ProcessPointDown(secondWindow->GetWindowId()); usleep(WAIT_CALLBACK_US); @@ -165,13 +165,13 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, Function | MediumTest | */ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideForAllWindow, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener1_); - const sptr &secondWindow = utils::CreateTestWindow(secondWindowInfo_); + const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener2_); firstWindow->Show(); secondWindow->Show(); - const sptr &thirdWindow = utils::CreateTestWindow(thirdWindowInfo_); + const sptr &thirdWindow = Utils::CreateTestWindow(thirdWindowInfo_); thirdWindow->Show(); SingletonContainer::Get().ProcessPointDown(thirdWindow->GetWindowId()); usleep(WAIT_CALLBACK_US); diff --git a/wm/test/systemtest/window_visibility_info_test.cpp b/wm/test/systemtest/window_visibility_info_test.cpp index 085583c8..1286ba4b 100644 --- a/wm/test/systemtest/window_visibility_info_test.cpp +++ b/wm/test/systemtest/window_visibility_info_test.cpp @@ -35,7 +35,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowVisibilityInfoTest"}; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; constexpr int WAIT_ASYNC_MS_TIME_OUT = 2000; // 2000ms #define CHECK_DISPLAY_POWER_STATE_RETURN() \ @@ -110,9 +110,9 @@ public: } static void WaitForCallback(); - utils::TestWindowInfo fullScreenAppInfo_; - utils::TestWindowInfo floatAppInfo_; - utils::TestWindowInfo subAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo floatAppInfo_; + Utils::TestWindowInfo subAppInfo_; }; void WindowVisibilityInfoTest::SetUpTestCase() @@ -123,7 +123,7 @@ void WindowVisibilityInfoTest::SetUpTestCase() display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, static_cast(display->GetWidth()), static_cast(display->GetHeight())}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); WindowManager::GetInstance().RegisterVisibilityChangedListener(visibilityChangedListener_); DisplayManager::GetInstance().RegisterDisplayPowerEventListener(displayPowerEventListener_); } @@ -138,7 +138,7 @@ void WindowVisibilityInfoTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -147,7 +147,7 @@ void WindowVisibilityInfoTest::SetUp() }; floatAppInfo_ = { .name = "ParentWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -156,7 +156,7 @@ void WindowVisibilityInfoTest::SetUp() }; subAppInfo_ = { .name = "SubWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -189,12 +189,12 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest01, Function | Medium { floatAppInfo_.name = "window1"; floatAppInfo_.rect = {250, 150, 300, 500}; - sptr window1 = utils::CreateTestWindow(floatAppInfo_); + sptr window1 = Utils::CreateTestWindow(floatAppInfo_); subAppInfo_.name = "subWindow1"; subAppInfo_.rect = {400, 200, 100, 100}; subAppInfo_.parentName = window1->GetWindowName(); - sptr subWindow1 = utils::CreateTestWindow(subAppInfo_); + sptr subWindow1 = Utils::CreateTestWindow(subAppInfo_); ASSERT_EQ(WMError::WM_OK, window1->Show()); WaitForCallback(); @@ -251,10 +251,10 @@ end: HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest02, Function | MediumTest | Level1) { fullScreenAppInfo_.name = "window1"; - sptr window1 = utils::CreateTestWindow(fullScreenAppInfo_); + sptr window1 = Utils::CreateTestWindow(fullScreenAppInfo_); fullScreenAppInfo_.name = "window2"; - sptr window2 = utils::CreateTestWindow(fullScreenAppInfo_); + sptr window2 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_EQ(WMError::WM_OK, window1->Show()); WaitForCallback(); @@ -282,20 +282,20 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest03, Function | Medium { floatAppInfo_.name = "window1"; floatAppInfo_.rect = {0, 0, 300, 600}; - sptr window1 = utils::CreateTestWindow(floatAppInfo_); + sptr window1 = Utils::CreateTestWindow(floatAppInfo_); subAppInfo_.name = "subWindow1"; subAppInfo_.rect = {400, 200, 100, 100}; subAppInfo_.parentName = window1->GetWindowName(); - sptr subWindow1 = utils::CreateTestWindow(subAppInfo_); + sptr subWindow1 = Utils::CreateTestWindow(subAppInfo_); floatAppInfo_.name = "window2"; - sptr window2 = utils::CreateTestWindow(floatAppInfo_); + sptr window2 = Utils::CreateTestWindow(floatAppInfo_); subAppInfo_.name = "subWindow2"; subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; subAppInfo_.parentName = window2->GetWindowName(); - sptr subWindow2 = utils::CreateTestWindow(subAppInfo_); + sptr subWindow2 = Utils::CreateTestWindow(subAppInfo_); ASSERT_EQ(WMError::WM_OK, window2->Show()); WaitForCallback(); @@ -337,15 +337,15 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest04, Function | Medium { floatAppInfo_.name = "window1"; floatAppInfo_.rect = {0, 0, 300, 600}; - sptr window1 = utils::CreateTestWindow(floatAppInfo_); + sptr window1 = Utils::CreateTestWindow(floatAppInfo_); floatAppInfo_.name = "window2"; floatAppInfo_.rect = {0, 0, 300, 300}; - sptr window2 = utils::CreateTestWindow(floatAppInfo_); + sptr window2 = Utils::CreateTestWindow(floatAppInfo_); floatAppInfo_.name = "window3"; floatAppInfo_.rect = {0, 300, 300, 300}; - sptr window3 = utils::CreateTestWindow(floatAppInfo_); + sptr window3 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_EQ(WMError::WM_OK, window1->Show()); WaitForCallback(); diff --git a/wm/test/unittest/mock_window_adapter.h b/wm/test/unittest/mock_window_adapter.h index 4b7d529a..02feff5a 100644 --- a/wm/test/unittest/mock_window_adapter.h +++ b/wm/test/unittest/mock_window_adapter.h @@ -30,7 +30,6 @@ public: MOCK_METHOD0(ClearWindowAdapter, void()); MOCK_METHOD1(DestroyWindow, WMError(uint32_t windowId)); MOCK_METHOD2(SetWindowBackgroundBlur, WMError(uint32_t windowId, WindowBlurLevel level)); - MOCK_METHOD2(SetAlpha, WMError(uint32_t windowId, float alpha)); MOCK_METHOD2(UpdateProperty, WMError(sptr& windowProperty, PropertyChangeAction action)); }; } diff --git a/wm/test/unittest/window_effect_test.cpp b/wm/test/unittest/window_effect_test.cpp index 655a2105..5c38abfe 100644 --- a/wm/test/unittest/window_effect_test.cpp +++ b/wm/test/unittest/window_effect_test.cpp @@ -57,26 +57,10 @@ HWTEST_F(WindowEffectTest, WindowEffect01, Function | SmallTest | Level2) /** * @tc.name: WindowEffect02 - * @tc.desc: windowOption: set window alpha/ get window alpha - * @tc.type: FUNC - */ -HWTEST_F(WindowEffectTest, WindowEffect02, Function | SmallTest | Level2) -{ - sptr option = new WindowOption(); - option->SetAlpha(0.0f); - ASSERT_EQ(0.0f, option->GetAlpha()); - option->SetAlpha(0.5f); - ASSERT_EQ(0.5f, option->GetAlpha()); - option->SetAlpha(1.0f); - ASSERT_EQ(1.0f, option->GetAlpha()); -} - -/** - * @tc.name: WindowEffect03 * @tc.desc: WindowImp: Create window with no default option, get and check Property * @tc.type: FUNC */ -HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2) +HWTEST_F(WindowEffectTest, WindowEffect02, Function | SmallTest | Level2) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); @@ -92,20 +76,18 @@ HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2) } /** - * @tc.name: WindowEffect04 + * @tc.name: WindowEffect03 * @tc.desc: Create window with no default option, get and check Property * @tc.type: FUNC */ -HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2) +HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); - option->SetAlpha(0.1f); - sptr window = new WindowImpl(option); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create("")); - + window->SetAlpha(0.1f); ASSERT_EQ(0.1f, window->GetAlpha()); EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); @@ -113,11 +95,11 @@ HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2) } /** - * @tc.name: WindowEffect05 + * @tc.name: WindowEffect04 * @tc.desc: set window effect parameters throw window, and check parameters. * @tc.type: FUNC */ -HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2) +HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); @@ -135,32 +117,11 @@ HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2) } /** - * @tc.name: WindowEffect06 - * @tc.desc: set window effect parameters throw window, and check parameters. - * @tc.type: FUNC - */ -HWTEST_F(WindowEffectTest, WindowEffect06, Function | SmallTest | Level2) -{ - std::unique_ptr m = std::make_unique(); - sptr option = new WindowOption(); - sptr window = new WindowImpl(option); - - EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); - ASSERT_EQ(WMError::WM_OK, window->Create("")); - EXPECT_CALL(m->Mock(), SetAlpha(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); - ASSERT_EQ(WMError::WM_OK, window->SetAlpha(0.1f)); - ASSERT_EQ(0.1f, window->GetAlpha()); - - EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); - window->Destroy(); -} - -/** - * @tc.name: WindowEffect07 + * @tc.name: WindowEffect05 * @tc.desc: WindowImp: Create window with default option, get and check Property * @tc.type: FUNC */ -HWTEST_F(WindowEffectTest, WindowEffect07, Function | SmallTest | Level2) +HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); diff --git a/wmserver/BUILD.gn b/wmserver/BUILD.gn index c6cd4bee..7133c30e 100644 --- a/wmserver/BUILD.gn +++ b/wmserver/BUILD.gn @@ -44,6 +44,7 @@ ohos_shared_library("libwms") { "src/display_group_info.cpp", "src/drag_controller.cpp", "src/freeze_controller.cpp", + "src/inner_window.cpp", "src/input_window_monitor.cpp", "src/minimize_app.cpp", "src/remote_animation.cpp", @@ -67,7 +68,6 @@ ohos_shared_library("libwms") { "src/window_task_looper.cpp", "src/window_zorder_policy.cpp", "src/zidl/window_manager_stub.cpp", - "src/inner_window.cpp" ] configs = [ ":libwms_config" ] diff --git a/wmserver/include/inner_window.h b/wmserver/include/inner_window.h index 73fb4228..ec85ff94 100644 --- a/wmserver/include/inner_window.h +++ b/wmserver/include/inner_window.h @@ -16,83 +16,63 @@ #ifndef OHOS_ROSEN_INNER_WINDOW_H #define OHOS_ROSEN_INNER_WINDOW_H -#include -#include #include "window.h" -#include "window_manager_hilog.h" +#include "wm_common_inner.h" #include "wm_single_instance.h" namespace OHOS { namespace Rosen { -enum class InnerWindowState : uint32_t { - INNER_WINDOW_STATE_NLL, - INNER_WINDOW_STATE_CRATED, - INNER_WINDOW_STATE_DESTROYED -}; class IInnerWindow : virtual public RefBase { public: - virtual void Create() = 0; + virtual void Create(std::string name, DisplayId displyId, Rect rect, WindowMode mode) = 0; virtual void Destroy() = 0; - InnerWindowState GetState() { - return state_; - }; -protected: - InnerWindowState state_ = InnerWindowState::INNER_WINDOW_STATE_NLL; }; -class PlaceHolderWindow : public IInnerWindow, public IWindowLifeCycle, public ITouchOutsideListener, - public IInputEventListener { +class PlaceholderWindowListener : public IWindowLifeCycle, public ITouchOutsideListener, public IInputEventListener { public: - PlaceHolderWindow(std::string name, DisplayId displyId, const Rect& rect, WindowMode mode) : name_(name), - displayId_(displyId), rect_(rect), mode_(mode) {}; - ~PlaceHolderWindow(); - void Create(); - void Destroy(); - -private: + // touch outside listener virtual void OnTouchOutside(); + // input event listener virtual void OnKeyEvent(std::shared_ptr& keyEvent); virtual void OnPointerInputEvent(std::shared_ptr& pointerEvent); + // lifecycle listener + virtual void AfterUnfocused(); + // lifecycle do nothing virtual void AfterForeground() {}; virtual void AfterBackground() {}; virtual void AfterFocused() {}; virtual void AfterInactive() {}; - virtual void AfterUnfocused(); - void UnRegitsterWindowListener(); - void RegitsterWindowListener(); +}; + +class PlaceHolderWindow : public IInnerWindow { +WM_DECLARE_SINGLE_INSTANCE(PlaceHolderWindow); +public: + virtual void Create(std::string name, DisplayId displyId, Rect rect, WindowMode mode); + virtual void Destroy(); + +private: + void RegitsterWindowListener(); + void UnRegitsterWindowListener(); private: - std::string name_; - DisplayId displayId_; - Rect rect_; - WindowMode mode_; sptr window_; - std::string contentImgPath_ = "/etc/window/resources/bg_place_holder.png"; + sptr listener_; }; class DividerWindow : public IInnerWindow { +WM_DECLARE_SINGLE_INSTANCE_BASE(DividerWindow); public: - DividerWindow(std::string name, DisplayId displyId, const Rect& rect) : name_(name), - displayId_(displyId), rect_(rect) {}; + virtual void Create(std::string name, DisplayId displayId, const Rect rect, WindowMode mode); + virtual void Destroy(); + +protected: + DividerWindow() = default; ~DividerWindow(); - void Create(); - void Destroy(); private: - std::string name_; DisplayId displayId_; - Rect rect_; - int32_t dialogId_ = -1; - -}; - -class InnerWindowFactory : public RefBase { -WM_DECLARE_SINGLE_INSTANCE(InnerWindowFactory); -public: - WMError CreateInnerWindow(std::string name, DisplayId displyId, Rect rect, WindowType type, WindowMode mode); - WMError DestroyInnerWindow(DisplayId displyId, WindowType type); -private: - std::unordered_map> innerWindowMap_; + std::string params_; + int32_t dialogId_ = IVALID_DIALOG_WINDOW_ID; }; } // namespace Rosen } // namespace OHOS diff --git a/wmserver/include/minimize_app.h b/wmserver/include/minimize_app.h index 0d0c0f8e..af827c69 100644 --- a/wmserver/include/minimize_app.h +++ b/wmserver/include/minimize_app.h @@ -29,6 +29,7 @@ enum class MinimizeReason : uint32_t { MINIMIZE_BUTTON, MINIMIZE_ALL, LAYOUT_TILE, + LAYOUT_CASCADE, MAX_APP_COUNT, SPLIT_REPLACE, SPLIT_QUIT, diff --git a/wmserver/include/starting_window.h b/wmserver/include/starting_window.h index fff19014..fa921cb0 100644 --- a/wmserver/include/starting_window.h +++ b/wmserver/include/starting_window.h @@ -30,7 +30,8 @@ public: StartingWindow() = delete; ~StartingWindow() = default; - static sptr CreateWindowNode(sptr info, uint32_t winId); + static sptr CreateWindowNode(sptr info, + uint32_t winId, WindowLayoutMode layoutMode); static void HandleClientWindowCreate(sptr& node, sptr& window, uint32_t& windowId, const std::shared_ptr& surfaceNode, sptr& property, int32_t pid, int32_t uid); @@ -39,7 +40,6 @@ public: static void UpdateRSTree(sptr& node); static void ReleaseStartWinSurfaceNode(sptr& node); private: - static SurfaceDraw surfaceDraw_; static WMError CreateLeashAndStartingSurfaceNode(sptr& node); static std::recursive_mutex mutex_; }; diff --git a/wmserver/include/window_controller.h b/wmserver/include/window_controller.h index 66971809..e63af51a 100644 --- a/wmserver/include/window_controller.h +++ b/wmserver/include/window_controller.h @@ -62,7 +62,7 @@ public: void CancelStartingWindow(sptr abilityToken); void MinimizeWindowsByLauncher(std::vector& windowIds, bool isAnimated, sptr& finishCallback); - Orientation GetFullScreenWindowRequestedOrientation(DisplayId displayId); + Orientation GetWindowPreferredOrientation(DisplayId displayId); private: uint32_t GenWindowId(); void FlushWindowInfo(uint32_t windowId); @@ -83,6 +83,7 @@ private: WMError UpdateTouchHotAreas(const sptr& node, const std::vector& rects); void NotifyTouchOutside(const sptr& node); uint32_t GetEmbedNodeId(const std::vector>& windowNodes, const sptr& node); + void NotifyWindowPropertyChanged(const sptr& node); sptr windowRoot_; sptr inputWindowMonitor_; std::atomic windowId_ { INVALID_WINDOW_ID }; diff --git a/wmserver/include/window_inner_manager.h b/wmserver/include/window_inner_manager.h index 30221d04..7340c6d9 100644 --- a/wmserver/include/window_inner_manager.h +++ b/wmserver/include/window_inner_manager.h @@ -20,57 +20,35 @@ #include "event_handler.h" #include "event_runner.h" -#include -#include "draw/canvas.h" -#include "nocopyable.h" -#include "pixel_map.h" - +#include "inner_window.h" #include "wm_common.h" #include "wm_single_instance.h" -#include "window.h" -#include "inner_window.h" +enum class InnerWMRunningState { + STATE_NOT_START, + STATE_RUNNING, +}; namespace OHOS { namespace Rosen { -class TouchOutsideListener : public ITouchOutsideListener { - virtual void OnTouchOutside(); -}; -class InputListener : public IInputEventListener { - virtual void OnKeyEvent(std::shared_ptr& keyEvent); - virtual void OnPointerInputEvent(std::shared_ptr& pointerEvent); -}; -class LifeCycle : public IWindowLifeCycle { - virtual void AfterForeground() {}; - virtual void AfterBackground() {}; - virtual void AfterFocused() {}; - virtual void AfterInactive() {}; - virtual void AfterUnfocused(); -}; class WindowInnerManager : public RefBase { -friend class TouchOutsideListener; -friend class InputListener; -friend class LifeCycle; WM_DECLARE_SINGLE_INSTANCE_BASE(WindowInnerManager); using EventRunner = OHOS::AppExecFwk::EventRunner; using EventHandler = OHOS::AppExecFwk::EventHandler; public: - void Start(); + void Start(bool enableRecentholder); void Stop(); - void CreteInnerWindow(std::string name, DisplayId displyId, Rect rect, - WindowType type, WindowMode mode); - void DestroyInnerWindow(DisplayId displyId, WindowType type); -public: - enum class InnerWMRunningState { - STATE_NOT_START, - STATE_RUNNING, - }; + void CreateInnerWindow(std::string name, DisplayId displayId, Rect rect, WindowType type, WindowMode mode); + void DestroyInnerWindow(DisplayId displayId, WindowType type); + +protected: + WindowInnerManager(); ~WindowInnerManager(); private: - WindowInnerManager(); bool Init(); private: + bool isRecentHolderEnable_ = false; std::shared_ptr eventHandler_; std::shared_ptr eventLoop_; InnerWMRunningState state_; diff --git a/wmserver/include/window_layout_policy.h b/wmserver/include/window_layout_policy.h index c9f178a3..5421d22b 100644 --- a/wmserver/include/window_layout_policy.h +++ b/wmserver/include/window_layout_policy.h @@ -61,7 +61,6 @@ public: void ProcessDisplayCreate(DisplayId displayId, const std::map& displayRectMap); void ProcessDisplayDestroy(DisplayId displayId, const std::map& displayRectMap); void ProcessDisplaySizeChangeOrRotation(DisplayId displayId, const std::map& displayRectMap); - void SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig); void SetSplitRatioConfig(const SplitRatioConfig& splitRatioConfig); protected: @@ -91,16 +90,15 @@ protected: void UpdateFloatingWindowSizeForStretchableWindow(const sptr& node, const Rect& displayRect, Rect& winRect) const; - void UpdateFloatingWindowSizeByCustomizedLimits(const sptr& node, + void UpdateFloatingWindowSizeBySizeLimits(const sptr& node, const Rect& displayRect, Rect& winRect) const; void UpdateFloatingWindowSizeBySystemLimits(const sptr& node, const Rect& displayRect, Rect& winRect) const; void LimitWindowPositionWhenInitRectOrMove(const sptr& node, Rect& winRect) const; void LimitWindowPositionWhenDrag(const sptr& node, Rect& winRect) const; - void FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr& node, Rect& winRect, - const FloatingWindowLimitsConfig& limitConfig); - FloatingWindowLimitsConfig GetCustomizedLimitsConfig(const Rect& displayRect, float virtualPixelRatio); - FloatingWindowLimitsConfig GetSystemLimitsConfig(const Rect& displayRect, float virtualPixelRatio); + void FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr& node, Rect& winRect); + void UpdateWindowSizeLimits(const sptr& node); + WindowSizeLimits GetSystemSizeLimits(const Rect& displayRect, float virtualPixelRatio); const std::set avoidTypes_ { WindowType::WINDOW_TYPE_STATUS_BAR, @@ -122,7 +120,6 @@ protected: Rect displayGroupRect_; Rect displayGroupLimitRect_; bool isMultiDisplay_ = false; - FloatingWindowLimitsConfig floatingWindowLimitsConfig_; SplitRatioConfig splitRatioConfig_; }; } diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index 0366f24c..536c9812 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -42,7 +42,7 @@ class DisplayChangeListener : public IDisplayChangeListener { public: virtual void OnDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap, DisplayStateChangeType type) override; - virtual void OnGetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) override; + virtual void OnGetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) override; }; class WindowManagerServiceHandler : public AAFwk::WindowManagerServiceHandlerStub { @@ -77,7 +77,6 @@ public: WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override; WMError RequestFocus(uint32_t windowId) override; WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override; - WMError SetAlpha(uint32_t windowId, float alpha) override; AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType) override; void ProcessPointDown(uint32_t windowId, bool isStartDrag) override; void ProcessPointUp(uint32_t windowId) override; @@ -103,7 +102,7 @@ public: void CancelStartingWindow(sptr abilityToken); void MinimizeWindowsByLauncher(std::vector windowIds, bool isAnimated, sptr& finishCallback) override; - void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation); + void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation); protected: WindowManagerService(); virtual ~WindowManagerService() = default; @@ -119,7 +118,6 @@ private: const std::map>& displayInfoMap, DisplayStateChangeType type); WMError GetFocusWindowInfo(sptr& abilityToken); void ConfigureWindowManagerService(); - void ConfigFloatWindowLimits(); static inline SingletonDelegator delegator; std::map accessTokenIdMaps_; diff --git a/wmserver/include/window_node.h b/wmserver/include/window_node.h index b955e0da..8fb948f1 100644 --- a/wmserver/include/window_node.h +++ b/wmserver/include/window_node.h @@ -54,7 +54,6 @@ public: void SetSystemBarProperty(WindowType type, const SystemBarProperty& property); void SetWindowMode(WindowMode mode); void SetWindowBackgroundBlur(WindowBlurLevel level); - void SetAlpha(float alpha); void SetBrightness(float brightness); void SetFocusable(bool focusable); void SetTouchable(bool touchable); @@ -72,6 +71,7 @@ public: void SetDragType(DragType dragType); void SetOriginRect(const Rect& rect); void SetTouchHotAreas(const std::vector& rects); + void SetWindowSizeLimits(const WindowSizeLimits& sizeLimits); const sptr& GetWindowToken() const; uint32_t GetWindowId() const; @@ -85,7 +85,6 @@ public: WindowType GetWindowType() const; WindowMode GetWindowMode() const; WindowBlurLevel GetWindowBackgroundBlur() const; - float GetAlpha() const; float GetBrightness() const; bool IsTurnScreenOn() const; bool IsKeepScreenOn() const; @@ -105,7 +104,9 @@ public: void ResetWindowSizeChangeReason(); void GetTouchHotAreas(std::vector& rects) const; uint32_t GetAccessTokenId() const; + WindowSizeLimits GetWindowSizeLimits() const; + bool EnableDefaultAnimation(bool propertyEnabled, bool animationPlayed); sptr parent_; std::vector> children_; std::shared_ptr surfaceNode_; diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index 6803edeb..c98da05e 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -67,7 +67,7 @@ public: bool IsForbidDockSliceMove(DisplayId displayId) const; bool IsDockSliceInExitSplitModeArea(DisplayId displayId) const; void ExitSplitMode(DisplayId displayId); - Orientation GetFullScreenWindowRequestedOrientation(); + Orientation GetWindowPreferredOrientation(); bool isVerticalDisplay(DisplayId displayId) const; WMError RaiseZOrderForAppWindow(sptr& node, sptr& parentNode); @@ -76,6 +76,7 @@ public: void MinimizeAllAppWindows(DisplayId displayId); void MinimizeOldestAppWindow(); WMError ToggleShownStateForAllAppWindows(std::function restoreFunc, bool restore); + void BackUpAllAppWindows(); void RestoreAllAppWindows(std::function restoreFunc); bool IsAppWindowsEmpty() const; void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason); @@ -108,6 +109,7 @@ public: void UpdateAvoidAreaListener(sptr& windowNode, bool haveAvoidAreaListener); void BeforeProcessWindowAvoidAreaChangeWhenDisplayChange() const; void ProcessWindowAvoidAreaChangeWhenDisplayChange() const; + WindowLayoutMode GetCurrentLayoutMode() const; private: void TraverseWindowNode(sptr& root, std::vector>& windowNodes) const; @@ -149,6 +151,7 @@ private: const std::vector& curShowingDisplays); void FillWindowInfo(sptr& windowInfo, const sptr& node) const; bool CheckWindowNodeWhetherInWindowTree(const sptr& node) const; + void UpdateModeSupportInfoWhenKeyguardChange(const sptr& node, bool up); float displayBrightness_ = UNDEFINED_BRIGHTNESS; uint32_t brightnessWindow_ = INVALID_WINDOW_ID; @@ -160,6 +163,7 @@ private: std::vector backupWindowIds_; std::map backupWindowMode_; std::map backupDividerWindowRect_; + std::map> backupDisplaySplitWindowMode_; sptr zorderPolicy_ = new WindowZorderPolicy(); std::unordered_map> layoutPolicies_; WindowLayoutMode layoutMode_ = WindowLayoutMode::CASCADE; diff --git a/wmserver/include/window_pair.h b/wmserver/include/window_pair.h index 237cdc4a..15c0c6a9 100644 --- a/wmserver/include/window_pair.h +++ b/wmserver/include/window_pair.h @@ -17,6 +17,7 @@ #define OHOS_ROSEN_WINDOW_PAIR_H #include +#include "class_var_definition.h" #include "window_inner_manager.h" #include "window_node.h" #include "window_layout_policy.h" @@ -52,9 +53,8 @@ public: * Constructor used to create an empty WindowPair instance. * * @param displayId the display of window pair - * @param appNode the window root of app window */ - WindowPair(const DisplayId& displayId, DisplayGroupWindowTree& displayGroupWindowTree); + explicit WindowPair(const DisplayId& displayId); /** * Deconstructor used to deconstruct. @@ -171,13 +171,6 @@ public: */ bool IsDockSliceInExitSplitModeArea(const std::vector& exitSplitPoints); - /** - * Set all app windows are restoring. - * - * @param ratio Indicates whether all app windows are restoring. - */ - void SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring); - void SetInitalDividerRect(const Rect& rect); private: @@ -220,22 +213,6 @@ private: */ void DumpPairInfo(); - /** - * Find pairable window from window trees. - * - * @param node the node waiting to be paired - * @return window node - */ - sptr FindPairableWindow(sptr& node); - - /** - * Get pairable node from trees or send split broadcast. - * - * @param node the node waiting to be paired - * @return pairable node - */ - sptr GetPairableWindow(sptr& node); - /** * Send broadcast message of split event. * @@ -246,15 +223,12 @@ private: private: float ratio_ = DEFAULT_SPLIT_RATIO; DisplayId displayId_; - sptr appWindowNode_; sptr primary_; sptr secondary_; sptr divider_; - // sptr placeholder_; WindowPairStatus status_ = {WindowPairStatus::STATUS_EMPTY}; - DisplayGroupWindowTree& displayGroupWindowTree_; - bool isAllAppWindowsRestoring_ { false }; Rect initalDividerRect_ {0, 0, 0, 0}; + DEFINE_VAR_DEFAULT_FUNC_SET(bool, AllSplitAppWindowsRestoring, isAllSplitAppWindowsRestoring, false) }; } // namespace Rosen } // namespace OHOS diff --git a/wmserver/include/window_root.h b/wmserver/include/window_root.h index 660802fd..8e7128e9 100644 --- a/wmserver/include/window_root.h +++ b/wmserver/include/window_root.h @@ -93,10 +93,10 @@ public: uint32_t GetWindowIdByObject(const sptr& remoteObject); sptr GetWindowForDumpAceHelpInfo() const; void DestroyLeakStartingWindow(); - void SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig); void SetSplitRatios(const std::vector& splitRatioNumbers); void SetExitSplitRatios(const std::vector& exitSplitRatios); void MinimizeTargetWindows(std::vector& windowIds); + WindowLayoutMode GetCurrentLayoutMode(DisplayId displayId); private: void OnRemoteDied(const sptr& remoteObject); WMError DestroyWindowInner(sptr& node); @@ -134,7 +134,6 @@ private: this, std::placeholders::_1)); Callback callback_; uint32_t maxAppWindowNumber_ = 100; - FloatingWindowLimitsConfig floatingWindowLimitsConfig_; SplitRatioConfig splitRatioConfig_ = {0.1, 0.9, {}}; }; } diff --git a/wmserver/include/window_zorder_policy.h b/wmserver/include/window_zorder_policy.h index 4f52082f..7abb1020 100644 --- a/wmserver/include/window_zorder_policy.h +++ b/wmserver/include/window_zorder_policy.h @@ -45,7 +45,7 @@ private: { WindowType::WINDOW_TYPE_APP_COMPONENT, 2 }, { WindowType::WINDOW_TYPE_APP_LAUNCHING, 101 }, { WindowType::WINDOW_TYPE_DOCK_SLICE, 0 }, - { WindowType::WINDOW_TYPE_PLACE_HOLDER, 0 }, + { WindowType::WINDOW_TYPE_PLACEHOLDER, 0 }, { WindowType::WINDOW_TYPE_LAUNCHER_RECENT, 102 }, { WindowType::WINDOW_TYPE_LAUNCHER_DOCK, 103 }, { WindowType::WINDOW_TYPE_INCOMING_CALL, 104 }, diff --git a/wmserver/include/zidl/window_manager_interface.h b/wmserver/include/zidl/window_manager_interface.h index 6a2576b6..1280b14a 100644 --- a/wmserver/include/zidl/window_manager_interface.h +++ b/wmserver/include/zidl/window_manager_interface.h @@ -69,7 +69,6 @@ public: virtual WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) = 0; virtual WMError RequestFocus(uint32_t windowId) = 0; virtual WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) = 0; - virtual WMError SetAlpha(uint32_t windowId, float alpha) = 0; virtual AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) = 0; virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) = 0; virtual void ProcessPointDown(uint32_t windowId, bool isStartDrag) = 0; diff --git a/wmserver/include/zidl/window_manager_proxy.h b/wmserver/include/zidl/window_manager_proxy.h index 4d58628b..2ee5d352 100644 --- a/wmserver/include/zidl/window_manager_proxy.h +++ b/wmserver/include/zidl/window_manager_proxy.h @@ -37,7 +37,6 @@ public: WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override; WMError RequestFocus(uint32_t windowId) override; WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override; - WMError SetAlpha(uint32_t windowId, float alpha) override; AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) override; WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override; void ProcessPointDown(uint32_t windowId, bool isStartDrag) override; diff --git a/wmserver/src/display_group_controller.cpp b/wmserver/src/display_group_controller.cpp index 1db53d21..133ab5a7 100644 --- a/wmserver/src/display_group_controller.cpp +++ b/wmserver/src/display_group_controller.cpp @@ -49,7 +49,7 @@ void DisplayGroupController::InitNewDisplay(DisplayId displayId) displayGroupWindowTree_.insert(std::make_pair(displayId, std::move(displayWindowTree))); // window pair for display - auto windowPair = new WindowPair(displayId, displayGroupWindowTree_); + auto windowPair = new WindowPair(displayId); windowPairMap_.insert(std::make_pair(displayId, windowPair)); } diff --git a/wmserver/src/inner_window.cpp b/wmserver/src/inner_window.cpp index 6d333879..e5d1a0e2 100644 --- a/wmserver/src/inner_window.cpp +++ b/wmserver/src/inner_window.cpp @@ -25,112 +25,62 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "InnerWindow"}; const std::string IMAGE_PLACE_HOLDER_PNG_PATH = "/etc/window/resources/bg_place_holder.png"; } -WM_IMPLEMENT_SINGLE_INSTANCE(InnerWindowFactory) -WMError InnerWindowFactory::CreateInnerWindow(std::string name, DisplayId displyId, Rect rect, - WindowType type, WindowMode mode) +WM_IMPLEMENT_SINGLE_INSTANCE(PlaceHolderWindow) +WM_IMPLEMENT_SINGLE_INSTANCE(DividerWindow) + +void PlaceholderWindowListener::OnTouchOutside() { - WLOGFI("createInnerWindow begin type: %{public}u", type); - if ((type != WindowType::WINDOW_TYPE_DOCK_SLICE) && (type != WindowType::WINDOW_TYPE_PLACE_HOLDER)) { - WLOGFE("create inner window failed, current type: %{public}u not surpport.", type); - return WMError::WM_ERROR_INVALID_TYPE; - } - if (innerWindowMap_.find(type) != std::end(innerWindowMap_)) { - if (innerWindowMap_[type] != nullptr && innerWindowMap_[type]->GetState() == - InnerWindowState::INNER_WINDOW_STATE_CRATED) { - WLOGFW("create inner window failed, current inner window type %{public}u has created.", type); - return WMError::WM_ERROR_INVALID_TYPE; - } - innerWindowMap_.erase(type); - } - switch (type) { - case WindowType::WINDOW_TYPE_DOCK_SLICE : { - innerWindowMap_[type] = std::make_unique(name, displyId, rect); - innerWindowMap_[type]->Create(); - break; - } - case WindowType::WINDOW_TYPE_PLACE_HOLDER : { - innerWindowMap_[type] = std::make_unique(name, displyId, rect, mode); - innerWindowMap_[type]->Create(); - break; - } - default : - break; - } - WLOGFI("createInnerWindow end"); - return WMError::WM_OK; + WLOGFD("place holder touch outside"); + PlaceHolderWindow::GetInstance().Destroy(); } -WMError InnerWindowFactory::DestroyInnerWindow(DisplayId displyId, WindowType type) +void PlaceholderWindowListener::OnKeyEvent(std::shared_ptr& keyEvent) { - WLOGFI("destroy inner window type: %{public}u begin.", type); - if (innerWindowMap_.find(type) == std::end(innerWindowMap_)) { - WLOGFW("current inner window has created"); - return WMError::WM_ERROR_NULLPTR; - } - if (innerWindowMap_[type] != nullptr) { - innerWindowMap_[type]->Destroy(); - } - innerWindowMap_.erase(type); - WLOGFI("destroy inner window type: %{public}u end.", type); - return WMError::WM_OK; + WLOGFD("place holder get key event"); + PlaceHolderWindow::GetInstance().Destroy(); } -PlaceHolderWindow::~PlaceHolderWindow() +void PlaceholderWindowListener::OnPointerInputEvent(std::shared_ptr& pointerEvent) { - Destroy(); + WLOGFD("place holder get point event"); + PlaceHolderWindow::GetInstance().Destroy(); } -void PlaceHolderWindow::OnTouchOutside() +void PlaceholderWindowListener::AfterUnfocused() { - Destroy(); + WLOGFD("place holder after unfocused"); + PlaceHolderWindow::GetInstance().Destroy(); } -void PlaceHolderWindow::OnKeyEvent(std::shared_ptr& keyEvent) +void PlaceHolderWindow::Create(std::string name, DisplayId displyId, Rect rect, WindowMode mode) { - Destroy(); -} - -void PlaceHolderWindow::OnPointerInputEvent(std::shared_ptr& pointerEvent) -{ - Destroy(); -} - -void PlaceHolderWindow::AfterUnfocused() -{ - Destroy(); -} - -void PlaceHolderWindow::Create() -{ - WLOGFI("create inner display id: %{public}" PRIu64"", displayId_); + WLOGFD("create inner display id: %{public}" PRIu64"", displyId); if (window_ != nullptr) { WLOGFW("window has created."); - window_->Show(); return; } - WLOGFD("create palce holder Window start"); sptr option = new (std::nothrow) WindowOption(); if (option == nullptr) { WLOGFE("window option is nullptr."); return; } - option->SetWindowType(WindowType::WINDOW_TYPE_PLACE_HOLDER); - option->SetWindowMode(mode_); option->SetFocusable(false); - option->SetWindowRect(rect_); - window_ = Window::Create(name_, option); + option->SetWindowMode(mode); + option->SetWindowRect(rect); + option->SetWindowType(WindowType::WINDOW_TYPE_PLACEHOLDER); + window_ = Window::Create(name, option); if (window_ == nullptr) { WLOGFE("window is nullptr."); return; } + window_->AddWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE); RegitsterWindowListener(); - if (!OHOS::Rosen::SurfaceDraw::DrawImage(window_->GetSurfaceNode(), rect_.width_, rect_.height_, + if (!OHOS::Rosen::SurfaceDraw::DrawImage(window_->GetSurfaceNode(), rect.width_, rect.height_, IMAGE_PLACE_HOLDER_PNG_PATH)) { WLOGE("draw surface failed"); return; } window_->Show(); - state_ = InnerWindowState::INNER_WINDOW_STATE_CRATED; WLOGFD("create palce holder Window end"); } @@ -140,30 +90,35 @@ void PlaceHolderWindow::RegitsterWindowListener() WLOGFE("Window is nullptr, regitster window listener failed."); return; } - window_->RegisterTouchOutsideListener(this); - window_->RegisterInputEventListener(this); - window_->RegisterLifeCycleListener(this); + if (listener_ == nullptr) { + listener_ = new (std::nothrow) PlaceholderWindowListener(); + } + window_->RegisterTouchOutsideListener(listener_); + window_->RegisterInputEventListener(listener_); + window_->RegisterLifeCycleListener(listener_); } void PlaceHolderWindow::UnRegitsterWindowListener() { - if (window_ == nullptr) { - WLOGFE("Window is nullptr, unregitster window listener failed."); + if (window_ == nullptr || listener_ == nullptr) { + WLOGFE("Window or listener is nullptr, unregitster window listener failed."); return; } - window_->UnregisterTouchOutsideListener(this); - window_->UnregisterInputEventListener(this); - window_->UnregisterLifeCycleListener(this); + window_->UnregisterTouchOutsideListener(listener_); + window_->UnregisterInputEventListener(listener_); + window_->UnregisterLifeCycleListener(listener_); } void PlaceHolderWindow::Destroy() { - UnRegitsterWindowListener(); + WLOGFI("destroy place holder window begin."); if (window_ != nullptr) { + WLOGFI("destroy place holder window not nullptr."); + UnRegitsterWindowListener(); window_->Destroy(); } window_ = nullptr; - state_ = InnerWindowState::INNER_WINDOW_STATE_DESTROYED; + WLOGFI("destroy place holder window end."); } DividerWindow::~DividerWindow() @@ -171,31 +126,26 @@ DividerWindow::~DividerWindow() Destroy(); } -void DividerWindow::Create() +void DividerWindow::Create(std::string name, DisplayId displayId, const Rect rect, WindowMode mode) { - WLOGFI("create inner display id: %{public}" PRIu64"", displayId_); + displayId_ = displayId; + WLOGFD("create inner display id: %{public}" PRIu64"", displayId_); auto dialogCallback = [this](int32_t id, const std::string& event, const std::string& params) { - if (params == "EVENT_CANCEL_CODE") { - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); - } + WLOGFD("divider dialog window get param: %{public}s", params.c_str()); }; - std::string params; - Ace::UIServiceMgrClient::GetInstance()->ShowDialog(name_, params, WindowType::WINDOW_TYPE_DOCK_SLICE, - rect_.posX_, rect_.posY_, rect_.width_, rect_.height_, dialogCallback, &dialogId_); - state_ = InnerWindowState::INNER_WINDOW_STATE_CRATED; - WLOGFI("create inner window id: %{public}d success", dialogId_); + Ace::UIServiceMgrClient::GetInstance()->ShowDialog(name, params_, WindowType::WINDOW_TYPE_DOCK_SLICE, + rect.posX_, rect.posY_, rect.width_, rect.height_, dialogCallback, &dialogId_); + WLOGFD("create inner window id: %{public}d success", dialogId_); } void DividerWindow::Destroy() { - if (dialogId_ == -1) { - state_ = InnerWindowState::INNER_WINDOW_STATE_DESTROYED; + if (dialogId_ == IVALID_DIALOG_WINDOW_ID) { return; } - WLOGFI("destroy inner window id:: %{public}d.", dialogId_); + WLOGFD("destroy inner window id:: %{public}d.", dialogId_); Ace::UIServiceMgrClient::GetInstance()->CancelDialog(dialogId_); - dialogId_ = -1; - state_ = InnerWindowState::INNER_WINDOW_STATE_DESTROYED; + dialogId_ = IVALID_DIALOG_WINDOW_ID; } } // Rosen } // OHOS \ No newline at end of file diff --git a/wmserver/src/starting_window.cpp b/wmserver/src/starting_window.cpp index c183d372..df7c7d53 100644 --- a/wmserver/src/starting_window.cpp +++ b/wmserver/src/starting_window.cpp @@ -28,16 +28,30 @@ namespace { const char DISABLE_WINDOW_ANIMATION_PATH[] = "/etc/disable_window_animation"; } -SurfaceDraw StartingWindow::surfaceDraw_; -static bool g_hasInit = false; std::recursive_mutex StartingWindow::mutex_; -sptr StartingWindow::CreateWindowNode(sptr info, uint32_t winId) +sptr StartingWindow::CreateWindowNode(sptr info, + uint32_t winId, WindowLayoutMode layoutMode) { sptr property = new(std::nothrow) WindowProperty(); - if (property == nullptr) { + if (property == nullptr || info == nullptr) { return nullptr; } + + uint32_t modeSupportInfo = 0; + for (auto mode : info->GetWindowSupportModes()) { + modeSupportInfo |= mode; + } + + // if mode isn't be supported or don't support floating mode in tile mode, create starting window failed + if ((!WindowHelper::IsWindowModeSupported(modeSupportInfo, info->GetWindowMode())) || + ((!WindowHelper::IsWindowModeSupported(modeSupportInfo, WindowMode::WINDOW_MODE_FLOATING)) && + (layoutMode == WindowLayoutMode::TILE)) || + (WindowHelper::IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), modeSupportInfo))) { + WLOGFI("window mode is not be supported or not support floating mode in tile, cancel starting window"); + return nullptr; + } + property->SetRequestRect(info->GetWindowRect()); property->SetWindowMode(info->GetWindowMode()); property->SetDisplayId(info->GetDisplayId()); @@ -56,7 +70,6 @@ sptr StartingWindow::CreateWindowNode(sptr inf if (CreateLeashAndStartingSurfaceNode(node) != WMError::WM_OK) { return nullptr; } - return node; } @@ -89,10 +102,6 @@ void StartingWindow::DrawStartingWindow(sptr& node, if (!isColdStart) { return; } - if (!g_hasInit) { - surfaceDraw_.Init(); - g_hasInit = true; - } if (node->startingWinSurfaceNode_ == nullptr) { WLOGFE("no starting Window SurfaceNode!"); return; @@ -102,10 +111,10 @@ void StartingWindow::DrawStartingWindow(sptr& node, node->leashWinSurfaceNode_->SetBounds(rect.posX_, rect.posY_, -1, -1); } if (pixelMap == nullptr) { - surfaceDraw_.DrawBackgroundColor(node->startingWinSurfaceNode_, rect, bkgColor); + SurfaceDraw::DrawColor(node->startingWinSurfaceNode_, rect.width_, rect.height_, bkgColor); return; } - surfaceDraw_.DrawSkImage(node->startingWinSurfaceNode_, rect, pixelMap, bkgColor); + SurfaceDraw::DrawImageRect(node->startingWinSurfaceNode_, rect, pixelMap, bkgColor); } void StartingWindow::HandleClientWindowCreate(sptr& node, sptr& window, diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 93b36835..fa65c722 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -52,12 +52,13 @@ void WindowController::StartingWindow(sptr info, sptr(TraceTaskId::STARTING_WINDOW), "wms:async:ShowStartingWindow"); auto node = windowRoot_->FindWindowNodeWithToken(info->GetAbilityToken()); + auto layoutMode = windowRoot_->GetCurrentLayoutMode(info->GetDisplayId()); if (node == nullptr) { if (!isColdStart) { WLOGFE("no windowNode exists but is hot start!"); return; } - node = StartingWindow::CreateWindowNode(info, GenWindowId()); + node = StartingWindow::CreateWindowNode(info, GenWindowId(), layoutMode); if (node == nullptr) { return; } @@ -397,21 +398,6 @@ WMError WindowController::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurL return WMError::WM_OK; } -WMError WindowController::SetAlpha(uint32_t windowId, float dstAlpha) -{ - auto node = windowRoot_->GetWindowNode(windowId); - if (node == nullptr) { - WLOGFE("could not find window"); - return WMError::WM_ERROR_NULLPTR; - } - - WLOGFI("WindowEffect WindowController SetAlpha alpha: %{public}f", dstAlpha); - node->SetAlpha(dstAlpha); - - FlushWindowInfo(windowId); - return WMError::WM_OK; -} - void WindowController::NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap, DisplayStateChangeType type) { @@ -779,18 +765,22 @@ WMError WindowController::UpdateProperty(sptr& property, Propert } WLOGFI("window: [%{public}s, %{public}u] update property for action: %{public}u", node->GetWindowName().c_str(), node->GetWindowId(), static_cast(action)); + WMError ret = WMError::WM_OK; switch (action) { case PropertyChangeAction::ACTION_UPDATE_RECT: { node->SetDecoStatus(property->GetDecoStatus()); node->SetOriginRect(property->GetOriginRect()); node->SetDragType(property->GetDragType()); - return ResizeRect(windowId, property->GetRequestRect(), property->GetWindowSizeChangeReason()); + ret = ResizeRect(windowId, property->GetRequestRect(), property->GetWindowSizeChangeReason()); + break; } case PropertyChangeAction::ACTION_UPDATE_MODE: { - return SetWindowMode(windowId, property->GetWindowMode()); + ret = SetWindowMode(windowId, property->GetWindowMode()); + break; } case PropertyChangeAction::ACTION_UPDATE_FLAGS: { - return SetWindowFlags(windowId, property->GetWindowFlags()); + ret = SetWindowFlags(windowId, property->GetWindowFlags()); + break; } case PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS: { auto& props = property->GetSystemBarProperty(); @@ -847,10 +837,24 @@ WMError WindowController::UpdateProperty(sptr& property, Propert property->GetTouchHotAreas(rects); return UpdateTouchHotAreas(node, rects); } + case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY: default: break; } - return WMError::WM_OK; + if (ret == WMError::WM_OK) { + NotifyWindowPropertyChanged(node); + } + return ret; +} + +void WindowController::NotifyWindowPropertyChanged(const sptr& node) +{ + auto windowNodeContainer = windowRoot_->GetOrCreateWindowNodeContainer(node->GetDisplayId()); + if (windowNodeContainer == nullptr) { + WLOGFE("windowNodeContainer is null"); + return; + } + windowNodeContainer->NotifyAccessibilityWindowInfo(node, WindowUpdateType::WINDOW_UPDATE_PROPERTY); } WMError WindowController::GetModeChangeHotZones(DisplayId displayId, @@ -964,11 +968,11 @@ void WindowController::MinimizeWindowsByLauncher(std::vector& windowId } } -Orientation WindowController::GetFullScreenWindowRequestedOrientation(DisplayId displayId) +Orientation WindowController::GetWindowPreferredOrientation(DisplayId displayId) { sptr windowNodeContainer = windowRoot_->GetOrCreateWindowNodeContainer(displayId); if (windowNodeContainer != nullptr) { - return windowNodeContainer->GetFullScreenWindowRequestedOrientation(); + return windowNodeContainer->GetWindowPreferredOrientation(); } return Orientation::UNSPECIFIED; } diff --git a/wmserver/src/window_inner_manager.cpp b/wmserver/src/window_inner_manager.cpp index 597c65c2..a3aada57 100644 --- a/wmserver/src/window_inner_manager.cpp +++ b/wmserver/src/window_inner_manager.cpp @@ -15,14 +15,9 @@ #include "window_inner_manager.h" -#include "surface_draw.h" #include "ui_service_mgr_client.h" #include "window_manager_hilog.h" -#include "image/bitmap.h" -#include "image_source.h" -#include "image_type.h" -#include "image_utils.h" -#include "pixel_map.h" +#include "window.h" namespace OHOS { namespace Rosen { @@ -55,8 +50,9 @@ bool WindowInnerManager::Init() return true; } -void WindowInnerManager::Start() +void WindowInnerManager::Start(bool enableRecentholder) { + isRecentHolderEnable_ = enableRecentholder; if (state_ == InnerWMRunningState::STATE_RUNNING) { WLOGFI("window inner manager service has already started."); } @@ -82,19 +78,47 @@ void WindowInnerManager::Stop() state_ = InnerWMRunningState::STATE_NOT_START; } -void WindowInnerManager::CreteInnerWindow(std::string name, DisplayId displyId, Rect rect, +void WindowInnerManager::CreateInnerWindow(std::string name, DisplayId displayId, Rect rect, WindowType type, WindowMode mode) { - eventHandler_->PostTask([name, displyId, rect, type, mode]() { - InnerWindowFactory::GetInstance().CreateInnerWindow(name, displyId, rect, type, mode); + eventHandler_->PostTask([this, name, displayId, rect, mode, type]() { + switch (type) { + case WindowType::WINDOW_TYPE_PLACEHOLDER: { + if (isRecentHolderEnable_) { + PlaceHolderWindow::GetInstance().Create(name, displayId, rect, mode); + } + break; + } + case WindowType::WINDOW_TYPE_DOCK_SLICE: { + DividerWindow::GetInstance().Create(name, displayId, rect, mode); + break; + } + default: + break; + } }); + return; } -void WindowInnerManager::DestroyInnerWindow(DisplayId displyId, WindowType type) +void WindowInnerManager::DestroyInnerWindow(DisplayId displayId, WindowType type) { - eventHandler_->PostTask([displyId, type]() { - InnerWindowFactory::GetInstance().DestroyInnerWindow(displyId, type); + eventHandler_->PostTask([this, type]() { + switch (type) { + case WindowType::WINDOW_TYPE_PLACEHOLDER: { + if (isRecentHolderEnable_) { + PlaceHolderWindow::GetInstance().Destroy(); + } + break; + } + case WindowType::WINDOW_TYPE_DOCK_SLICE: { + DividerWindow::GetInstance().Destroy(); + break; + } + default: + break; + } }); + return; } } // Rosen } // OHOS \ No newline at end of file diff --git a/wmserver/src/window_layout_policy.cpp b/wmserver/src/window_layout_policy.cpp index 60e76d18..7e11e7cf 100644 --- a/wmserver/src/window_layout_policy.cpp +++ b/wmserver/src/window_layout_policy.cpp @@ -455,16 +455,20 @@ void WindowLayoutPolicy::CalcAndSetNodeHotZone(const Rect& winRect, const sptrSetTouchHotAreas(hotAreas); } -void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr& node, Rect& winRect, - const FloatingWindowLimitsConfig& limitConfig) +void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr& node, Rect& winRect) { - if (limitConfig.maxWidth_ == limitConfig.minWidth_ && - limitConfig.maxHeight_ == limitConfig.minHeight_) { + const auto& sizeLimits = node->GetWindowSizeLimits(); + if (sizeLimits.maxWidth_ == sizeLimits.minWidth_ && + sizeLimits.maxHeight_ == sizeLimits.minHeight_) { WLOGFI("window rect can not be changed"); return; } + if (winRect.height_ == 0) { + WLOGFE("the height of window is zero"); + return; + } float curRatio = static_cast(winRect.width_) / static_cast(winRect.height_); - if (limitConfig.minRatio_ <= curRatio && curRatio <= limitConfig.maxRatio_) { + if (sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_) { WLOGFI("window ratio is satisfied with limit ratio, curRatio: %{public}f", curRatio); return; } @@ -490,10 +494,10 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr< limitMaxPosX = dockWinRect.posX_ - static_cast(windowTitleBarH); } - float newRatio = curRatio < limitConfig.minRatio_ ? limitConfig.minRatio_ : limitConfig.maxRatio_; + float newRatio = curRatio < sizeLimits.minRatio_ ? sizeLimits.minRatio_ : sizeLimits.maxRatio_; if ((winRect.posX_ + static_cast(winRect.width_) == limitMinPosX) || (winRect.posX_ == limitMaxPosX)) { // height can not be changed - if (limitConfig.maxHeight_ == limitConfig.minHeight_) { + if (sizeLimits.maxHeight_ == sizeLimits.minHeight_) { return; } winRect.height_ = static_cast(static_cast(winRect.width_) / newRatio); @@ -501,7 +505,7 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr< if ((winRect.posY_ == limitMinPosY) || (winRect.posX_ == limitMaxPosY)) { // width can not be changed - if (limitConfig.maxWidth_ == limitConfig.minWidth_) { + if (sizeLimits.maxWidth_ == sizeLimits.minWidth_) { return; } winRect.width_ = static_cast(static_cast(winRect.height_) * newRatio); @@ -510,79 +514,76 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr< winRect.posX_, winRect.posY_, winRect.width_, winRect.height_); } -FloatingWindowLimitsConfig WindowLayoutPolicy::GetSystemLimitsConfig(const Rect& displayRect, float virtualPixelRatio) +WindowSizeLimits WindowLayoutPolicy::GetSystemSizeLimits(const Rect& displayRect, float virtualPixelRatio) { - FloatingWindowLimitsConfig limitConfig; - limitConfig.maxWidth_ = static_cast(MAX_FLOATING_SIZE * virtualPixelRatio); - limitConfig.maxHeight_ = static_cast(MAX_FLOATING_SIZE * virtualPixelRatio); - limitConfig.minWidth_ = static_cast(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio); - limitConfig.minHeight_ = static_cast(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio); + WindowSizeLimits systemLimits; + systemLimits.maxWidth_ = static_cast(MAX_FLOATING_SIZE * virtualPixelRatio); + systemLimits.maxHeight_ = static_cast(MAX_FLOATING_SIZE * virtualPixelRatio); + systemLimits.minWidth_ = static_cast(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio); + systemLimits.minHeight_ = static_cast(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio); if (displayRect.width_ > displayRect.height_) { - std::swap(limitConfig.minWidth_, limitConfig.minHeight_); + std::swap(systemLimits.minWidth_, systemLimits.minHeight_); } WLOGFI("maxWidth: %{public}u, maxHeight: %{public}u, minWidth: %{public}u, minHeight: %{public}u " - "maxRatio: %{public}f, minRatio: %{public}f", limitConfig.maxWidth_, limitConfig.maxHeight_, - limitConfig.minWidth_, limitConfig.minHeight_, limitConfig.maxRatio_, limitConfig.minRatio_); - return limitConfig; + "maxRatio: %{public}f, minRatio: %{public}f", systemLimits.maxWidth_, systemLimits.maxHeight_, + systemLimits.minWidth_, systemLimits.minHeight_, systemLimits.maxRatio_, systemLimits.minRatio_); + return systemLimits; } -FloatingWindowLimitsConfig WindowLayoutPolicy::GetCustomizedLimitsConfig(const Rect& displayRect, - float virtualPixelRatio) +void WindowLayoutPolicy::UpdateWindowSizeLimits(const sptr& node) { - const auto& systemLimits = GetSystemLimitsConfig(displayRect, virtualPixelRatio); - FloatingWindowLimitsConfig newLimitConfig = systemLimits; + const auto& displayRect = displayGroupInfo_->GetDisplayRect(node->GetDisplayId()); + const auto& virtualPixelRatio = GetVirtualPixelRatio(node->GetDisplayId()); + const auto& systemLimits = GetSystemSizeLimits(displayRect, virtualPixelRatio); + const auto& customizedLimits = node->GetWindowSizeLimits(); + WindowSizeLimits newLimits = systemLimits; + // configured limits of floating window - uint32_t configuredMaxWidth = static_cast(floatingWindowLimitsConfig_.maxWidth_ * virtualPixelRatio); - uint32_t configuredMaxHeight = static_cast(floatingWindowLimitsConfig_.maxHeight_ * virtualPixelRatio); - uint32_t configuredMinWidth = static_cast(floatingWindowLimitsConfig_.minWidth_ * virtualPixelRatio); - uint32_t configuredMinHeight = static_cast(floatingWindowLimitsConfig_.minHeight_ * virtualPixelRatio); - float configuredMaxRatio = floatingWindowLimitsConfig_.maxRatio_; - float configuredMinRatio = floatingWindowLimitsConfig_.minRatio_; + uint32_t configuredMaxWidth = static_cast(customizedLimits.maxWidth_ * virtualPixelRatio); + uint32_t configuredMaxHeight = static_cast(customizedLimits.maxHeight_ * virtualPixelRatio); + uint32_t configuredMinWidth = static_cast(customizedLimits.minWidth_ * virtualPixelRatio); + uint32_t configuredMinHeight = static_cast(customizedLimits.minHeight_ * virtualPixelRatio); + float configuerdMaxRatio = customizedLimits.maxRatio_; + float configuerdMinRatio = customizedLimits.minRatio_; // calculate new limit size if (systemLimits.minWidth_ <= configuredMaxWidth && configuredMaxWidth <= systemLimits.maxWidth_) { - newLimitConfig.maxWidth_ = configuredMaxWidth; + newLimits.maxWidth_ = configuredMaxWidth; } if (systemLimits.minHeight_ <= configuredMaxHeight && configuredMaxHeight <= systemLimits.maxHeight_) { - newLimitConfig.maxHeight_ = configuredMaxHeight; + newLimits.maxHeight_ = configuredMaxHeight; } - if (systemLimits.minWidth_ <= configuredMinWidth && configuredMinWidth <= newLimitConfig.maxWidth_) { - newLimitConfig.minWidth_ = configuredMinWidth; + if (systemLimits.minWidth_ <= configuredMinWidth && configuredMinWidth <= newLimits.maxWidth_) { + newLimits.minWidth_ = configuredMinWidth; } - if (systemLimits.minHeight_ <= configuredMinHeight && configuredMinHeight <= newLimitConfig.maxHeight_) { - newLimitConfig.minHeight_ = configuredMinHeight; + if (systemLimits.minHeight_ <= configuredMinHeight && configuredMinHeight <= newLimits.maxHeight_) { + newLimits.minHeight_ = configuredMinHeight; } // calculate new limit ratio - newLimitConfig.maxRatio_ = static_cast(newLimitConfig.maxWidth_) / - static_cast(newLimitConfig.minHeight_); - newLimitConfig.minRatio_ = static_cast(newLimitConfig.minWidth_) / - static_cast(newLimitConfig.maxHeight_); - if (newLimitConfig.minRatio_ <= configuredMaxRatio && configuredMaxRatio <= newLimitConfig.maxRatio_) { - newLimitConfig.maxRatio_ = configuredMaxRatio; + newLimits.maxRatio_ = static_cast(newLimits.maxWidth_) / static_cast(newLimits.minHeight_); + newLimits.minRatio_ = static_cast(newLimits.minWidth_) / static_cast(newLimits.maxHeight_); + if (newLimits.minRatio_ <= configuerdMaxRatio && configuerdMaxRatio <= newLimits.maxRatio_) { + newLimits.maxRatio_ = configuerdMaxRatio; } - if (newLimitConfig.minRatio_ <= configuredMinRatio && configuredMinRatio <= newLimitConfig.maxRatio_) { - newLimitConfig.minRatio_ = configuredMinRatio; + if (newLimits.minRatio_ <= configuerdMinRatio && configuerdMinRatio <= newLimits.maxRatio_) { + newLimits.minRatio_ = configuerdMinRatio; } // recalculate limit size by new ratio - uint32_t newMaxWidth = static_cast(static_cast(newLimitConfig.maxHeight_) * - newLimitConfig.maxRatio_); - newLimitConfig.maxWidth_ = std::min(newMaxWidth, newLimitConfig.maxWidth_); - uint32_t newMinWidth = static_cast(static_cast(newLimitConfig.minHeight_) * - newLimitConfig.minRatio_); - newLimitConfig.minWidth_ = std::max(newMinWidth, newLimitConfig.minWidth_); - uint32_t newMaxHeight = static_cast(static_cast(newLimitConfig.maxWidth_) / - newLimitConfig.minRatio_); - newLimitConfig.maxHeight_ = std::min(newMaxHeight, newLimitConfig.maxHeight_); - uint32_t newMinHeight = static_cast(static_cast(newLimitConfig.minWidth_) / - newLimitConfig.maxRatio_); - newLimitConfig.minHeight_ = std::max(newMinHeight, newLimitConfig.minHeight_); + uint32_t newMaxWidth = static_cast(static_cast(newLimits.maxHeight_) * newLimits.maxRatio_); + newLimits.maxWidth_ = std::min(newMaxWidth, newLimits.maxWidth_); + uint32_t newMinWidth = static_cast(static_cast(newLimits.minHeight_) * newLimits.minRatio_); + newLimits.minWidth_ = std::max(newMinWidth, newLimits.minWidth_); + uint32_t newMaxHeight = static_cast(static_cast(newLimits.maxWidth_) / newLimits.minRatio_); + newLimits.maxHeight_ = std::min(newMaxHeight, newLimits.maxHeight_); + uint32_t newMinHeight = static_cast(static_cast(newLimits.minWidth_) / newLimits.maxRatio_); + newLimits.minHeight_ = std::max(newMinHeight, newLimits.minHeight_); WLOGFI("maxWidth: %{public}u, maxHeight: %{public}u, minWidth: %{public}u, minHeight: %{public}u, " - "maxRatio: %{public}f, minRatio: %{public}f", newLimitConfig.maxWidth_, newLimitConfig.maxHeight_, - newLimitConfig.minWidth_, newLimitConfig.minHeight_, newLimitConfig.maxRatio_, newLimitConfig.minRatio_); - return newLimitConfig; + "maxRatio: %{public}f, minRatio: %{public}f", newLimits.maxWidth_, newLimits.maxHeight_, + newLimits.minWidth_, newLimits.minHeight_, newLimits.maxRatio_, newLimits.minRatio_); + node->SetWindowSizeLimits(newLimits); } void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr& node, @@ -604,12 +605,12 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr } } // limit minimum size of window - const auto& systemLimits = const_cast(this)-> - GetSystemLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId())); - float scale = std::min(static_cast(winRect.width_) / systemLimits.minWidth_, - static_cast(winRect.height_) / systemLimits.minHeight_); + + const auto& sizeLimits = node->GetWindowSizeLimits(); + float scale = std::min(static_cast(winRect.width_) / sizeLimits.minWidth_, + static_cast(winRect.height_) / sizeLimits.minHeight_); if (scale == 0) { - WLOGE("invalid systemLimits"); + WLOGE("invalid sizeLimits"); return; } if (scale < 1.0f) { @@ -618,45 +619,47 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr } } -void WindowLayoutPolicy::UpdateFloatingWindowSizeByCustomizedLimits(const sptr& node, +void WindowLayoutPolicy::UpdateFloatingWindowSizeBySizeLimits(const sptr& node, const Rect& displayRect, Rect& winRect) const { // get new limit config with the settings of system and app - const auto& customizedLimits = const_cast(this)-> - GetCustomizedLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId())); + const auto& sizeLimits = node->GetWindowSizeLimits(); - // limit minimum and maximum size of floating (not system type) window - winRect.width_ = std::max(customizedLimits.minWidth_, winRect.width_); - winRect.height_ = std::max(customizedLimits.minHeight_, winRect.height_); - winRect.width_ = std::min(customizedLimits.maxWidth_, winRect.width_); - winRect.height_ = std::min(customizedLimits.maxHeight_, winRect.height_); + // limit minimum size of floating (not system type) window + if (!WindowHelper::IsSystemWindow(node->GetWindowType()) || + node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) { + winRect.width_ = std::max(sizeLimits.minWidth_, winRect.width_); + winRect.height_ = std::max(sizeLimits.minHeight_, winRect.height_); + } + winRect.width_ = std::min(sizeLimits.maxWidth_, winRect.width_); + winRect.height_ = std::min(sizeLimits.maxHeight_, winRect.height_); WLOGFD("After limit by size, winRect: %{public}d %{public}d %{public}u %{public}u", winRect.posX_, winRect.posY_, winRect.width_, winRect.height_); // width and height can not be changed - if (customizedLimits.maxWidth_ == customizedLimits.minWidth_ && - customizedLimits.maxHeight_ == customizedLimits.minHeight_) { - winRect.width_ = customizedLimits.maxWidth_; - winRect.height_ = customizedLimits.maxHeight_; + if (sizeLimits.maxWidth_ == sizeLimits.minWidth_ && + sizeLimits.maxHeight_ == sizeLimits.minHeight_) { + winRect.width_ = sizeLimits.maxWidth_; + winRect.height_ = sizeLimits.maxHeight_; WLOGFD("window rect can not be changed"); return; } float curRatio = static_cast(winRect.width_) / static_cast(winRect.height_); - if ((customizedLimits.minWidth_ <= winRect.width_ && winRect.width_ <= customizedLimits.maxWidth_) && - (customizedLimits.minHeight_ <= winRect.height_ && winRect.height_ <= customizedLimits.maxHeight_) && - (customizedLimits.minRatio_ <= curRatio && curRatio <= customizedLimits.maxRatio_)) { - WLOGFD("window size and ratio is satisfied with limit ratio, curSize: [%{public}d, %{public}d], " + // there is no need to fix size by ratio if this is not main floating window + if (!WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()) || + (sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_)) { + WLOGFD("window is system window or ratio is satisfied with limits, curSize: [%{public}d, %{public}d], " "curRatio: %{public}f", winRect.width_, winRect.height_, curRatio); return; } - float newRatio = curRatio < customizedLimits.minRatio_ ? customizedLimits.minRatio_ : customizedLimits.maxRatio_; - if (customizedLimits.maxWidth_ == customizedLimits.minWidth_) { + float newRatio = curRatio < sizeLimits.minRatio_ ? sizeLimits.minRatio_ : sizeLimits.maxRatio_; + if (sizeLimits.maxWidth_ == sizeLimits.minWidth_) { winRect.height_ = static_cast(static_cast(winRect.width_) / newRatio); return; } - if (customizedLimits.maxHeight_ == customizedLimits.minHeight_) { + if (sizeLimits.maxHeight_ == sizeLimits.minHeight_) { winRect.width_ = static_cast(static_cast(winRect.height_) * newRatio); return; } @@ -673,25 +676,6 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeByCustomizedLimits(const sptr& node, - const Rect& displayRect, Rect& winRect) const -{ - const auto& systemLimits = const_cast(this)-> - GetSystemLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId())); - - // limit minimum size of floating (not system type) window - if (!WindowHelper::IsSystemWindow(node->GetWindowType()) || - node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) { - winRect.width_ = std::max(systemLimits.minWidth_, winRect.width_); - winRect.height_ = std::max(systemLimits.minHeight_, winRect.height_); - } - // limit maximum size of all floating window - winRect.width_ = std::min(systemLimits.maxWidth_, winRect.width_); - winRect.height_ = std::min(systemLimits.maxHeight_, winRect.height_); - WLOGFI("After limit by system config, winRect: %{public}d %{public}d %{public}u %{public}u", - winRect.posX_, winRect.posY_, winRect.width_, winRect.height_); -} - void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr& node, const Rect& displayRect, Rect& winRect) const @@ -700,12 +684,7 @@ void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr& node, return; } Rect oriWinRect = winRect; - if (floatingWindowLimitsConfig_.isFloatingWindowLimitsConfigured_ && - (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()))) { - UpdateFloatingWindowSizeByCustomizedLimits(node, displayRect, winRect); - } else { - UpdateFloatingWindowSizeBySystemLimits(node, displayRect, winRect); - } + UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect); if (node->GetStretchable() && WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) { @@ -736,12 +715,8 @@ void WindowLayoutPolicy::LimitMainFloatingWindowPosition(const sptr& // if drag or move window, limit size and position if (reason == WindowSizeChangeReason::DRAG) { LimitWindowPositionWhenDrag(node, winRect); - if (floatingWindowLimitsConfig_.isFloatingWindowLimitsConfigured_ && - (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()))) { - const auto& limitConfig = const_cast(this)-> GetCustomizedLimitsConfig( - displayGroupInfo_->GetDisplayRect(node->GetDisplayId()), GetVirtualPixelRatio(node->GetDisplayId())); - const_cast(this)-> - FixWindowSizeByRatioIfDragBeyondLimitRegion(node, winRect, limitConfig); + if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) { + const_cast(this)->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, winRect); } } else { // Limit window position, such as init window rect when show @@ -989,11 +964,6 @@ void WindowLayoutPolicy::SetSplitRatioConfig(const SplitRatioConfig& splitRatioC splitRatioConfig_ = splitRatioConfig; } -void WindowLayoutPolicy::SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig) -{ - floatingWindowLimitsConfig_ = floatingWindowLimitsConfig; -} - Rect WindowLayoutPolicy::GetInitalDividerRect(DisplayId displayId) const { return INVALID_EMPTY_RECT; diff --git a/wmserver/src/window_layout_policy_cascade.cpp b/wmserver/src/window_layout_policy_cascade.cpp index 5b5bc0a1..e0a68fc0 100644 --- a/wmserver/src/window_layout_policy_cascade.cpp +++ b/wmserver/src/window_layout_policy_cascade.cpp @@ -14,6 +14,8 @@ */ #include "window_layout_policy_cascade.h" + +#include "minimize_app.h" #include "window_helper.h" #include "window_inner_manager.h" #include "window_manager_hilog.h" @@ -179,6 +181,10 @@ void WindowLayoutPolicyCascade::AddWindowNode(const sptr& node) WLOGFE("window property is nullptr."); return; } + + // update window size limits when add window + UpdateWindowSizeLimits(node); + if (WindowHelper::IsEmptyRect(property->GetRequestRect())) { SetCascadeRect(node); } @@ -466,6 +472,12 @@ void WindowLayoutPolicyCascade::Reorder() WLOGFI("get node failed or not app window."); continue; } + // if window don't support floating mode, or default rect of cascade is not satisfied with limits + if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) || + !WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowSizeLimits())) { + MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_CASCADE); + continue; + } if (isFirstReorderedWindow) { isFirstReorderedWindow = false; } else { @@ -473,13 +485,12 @@ void WindowLayoutPolicyCascade::Reorder() } node->SetRequestRect(rect); node->SetDecoStatus(true); - if (node->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING && - WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) { - node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - if (node->GetWindowToken()) { - node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING); - } + if (node->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING) { + node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + if (node->GetWindowToken()) { + node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING); } + } WLOGFI("Cascade reorder Id: %{public}d, rect:[%{public}d, %{public}d, %{public}d, %{public}d]", node->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_); } diff --git a/wmserver/src/window_layout_policy_tile.cpp b/wmserver/src/window_layout_policy_tile.cpp index 87423252..438099bf 100644 --- a/wmserver/src/window_layout_policy_tile.cpp +++ b/wmserver/src/window_layout_policy_tile.cpp @@ -118,6 +118,10 @@ void WindowLayoutPolicyTile::InitTileWindowRects(DisplayId displayId) void WindowLayoutPolicyTile::AddWindowNode(const sptr& node) { WM_FUNCTION_TRACE(); + + // update window size limits when add window + UpdateWindowSizeLimits(node); + if (WindowHelper::IsMainWindow(node->GetWindowType())) { DisplayId displayId = node->GetDisplayId(); ForegroundNodeQueuePushBack(node, displayId); @@ -206,6 +210,12 @@ void WindowLayoutPolicyTile::ForegroundNodeQueuePushBack(const sptr& if (iter != foregroundNodes.end()) { return; } + + if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) { + WLOGFD("window don't support tile mode, winId: %{public}d", node->GetWindowId()); + MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_TILE); + return; + } WLOGFI("add win in tile, displayId: %{public}" PRIu64", winId: %{public}d", displayId, node->GetWindowId()); while (foregroundNodes.size() >= maxTileWinNumMap_[displayId]) { auto removeNode = foregroundNodes.front(); @@ -247,7 +257,8 @@ void WindowLayoutPolicyTile::AssignNodePropertyForTileWindows(DisplayId displayI auto rectIt = presetRect.begin(); for (auto node : foregroundNodesMap_[displayId]) { auto& rect = (*rectIt); - if (WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) { + if (WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) && + WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowSizeLimits())) { node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); if (node->GetWindowToken()) { node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -257,6 +268,8 @@ void WindowLayoutPolicyTile::AssignNodePropertyForTileWindows(DisplayId displayI WLOGFI("set rect for qwin id: %{public}d [%{public}d %{public}d %{public}d %{public}d]", node->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_); rectIt++; + } else { + MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_TILE); } } } diff --git a/wmserver/src/window_manager_config.cpp b/wmserver/src/window_manager_config.cpp index f958df33..f217047d 100644 --- a/wmserver/src/window_manager_config.cpp +++ b/wmserver/src/window_manager_config.cpp @@ -73,14 +73,12 @@ bool WindowManagerConfig::LoadConfigXml() continue; } if (!xmlStrcmp(nodeName, reinterpret_cast("maxAppWindowNumber")) || - !xmlStrcmp(nodeName, reinterpret_cast("modeChangeHotZones")) || - !xmlStrcmp(nodeName, reinterpret_cast("floatingWindowLimitSize"))) { + !xmlStrcmp(nodeName, reinterpret_cast("modeChangeHotZones"))) { ReadIntNumbersConfigInfo(curNodePtr); continue; } - if (!xmlStrcmp(nodeName, reinterpret_cast("floatingWindowLimitRatio")) || - !xmlStrcmp(nodeName, reinterpret_cast("splitRatios")) || + if (!xmlStrcmp(nodeName, reinterpret_cast("splitRatios")) || !xmlStrcmp(nodeName, reinterpret_cast("exitSplitRatios"))) { ReadFloatNumbersConfigInfo(curNodePtr); continue; diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 73838370..f884bbfe 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -67,7 +67,7 @@ void WindowManagerService::OnStart() if (!Init()) { return; } - WindowInnerManager::GetInstance().Start(); + WindowInnerManager::GetInstance().Start(system::GetParameter("persist.window.holder.enable", "0") == "1"); sptr listener = new DisplayChangeListener(); DisplayManagerServiceInner::GetInstance().RegisterDisplayChangeListener(listener); RegisterSnapshotHandler(); @@ -237,33 +237,6 @@ int WindowManagerService::Dump(int fd, const std::vector& args) }).get(); } -void WindowManagerService::ConfigFloatWindowLimits() -{ - const auto& intNumbersConfig = WindowManagerConfig::GetIntNumbersConfig(); - const auto& floatNumbersConfig = WindowManagerConfig::GetFloatNumbersConfig(); - - FloatingWindowLimitsConfig floatingWindowLimitsConfig; - if (intNumbersConfig.count("floatingWindowLimitSize") != 0) { - auto numbers = intNumbersConfig.at("floatingWindowLimitSize"); - if (numbers.size() == 4) { // 4, limitSize - floatingWindowLimitsConfig.maxWidth_ = static_cast(numbers[0]); // 0 max width - floatingWindowLimitsConfig.maxHeight_ = static_cast(numbers[1]); // 1 max height - floatingWindowLimitsConfig.minWidth_ = static_cast(numbers[2]); // 2 min width - floatingWindowLimitsConfig.minHeight_ = static_cast(numbers[3]); // 3 min height - floatingWindowLimitsConfig.isFloatingWindowLimitsConfigured_ = true; - } - } - if (floatNumbersConfig.count("floatingWindowLimitRatio") != 0) { - auto numbers = floatNumbersConfig.at("floatingWindowLimitRatio"); - if (numbers.size() == 2) { // 2, limitRatio - floatingWindowLimitsConfig.maxRatio_ = static_cast(numbers[0]); // 0 max ratio - floatingWindowLimitsConfig.minRatio_ = static_cast(numbers[1]); // 1 min ratio - floatingWindowLimitsConfig.isFloatingWindowLimitsConfigured_ = true; - } - } - windowRoot_->SetFloatingWindowLimitsConfig(floatingWindowLimitsConfig); -} - void WindowManagerService::ConfigureWindowManagerService() { const auto& enableConfig = WindowManagerConfig::GetEnableConfig(); @@ -301,8 +274,6 @@ void WindowManagerService::ConfigureWindowManagerService() } } - ConfigFloatWindowLimits(); - if (floatNumbersConfig.count("splitRatios") != 0) { windowRoot_->SetSplitRatios(floatNumbersConfig.at("splitRatios")); } @@ -455,13 +426,6 @@ WMError WindowManagerService::SetWindowBackgroundBlur(uint32_t windowId, WindowB }).get(); } -WMError WindowManagerService::SetAlpha(uint32_t windowId, float alpha) -{ - return wmsTaskLooper_->ScheduleTask([this, windowId, alpha]() { - return windowController_->SetAlpha(windowId, alpha); - }).get(); -} - AvoidArea WindowManagerService::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType) { return wmsTaskLooper_->ScheduleTask([this, windowId, avoidAreaType]() { @@ -554,9 +518,9 @@ void DisplayChangeListener::OnDisplayStateChange(DisplayId defaultDisplayId, spt WindowManagerService::GetInstance().NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type); } -void DisplayChangeListener::OnGetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) +void DisplayChangeListener::OnGetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) { - WindowManagerService::GetInstance().GetFullScreenWindowRequestedOrientation(displayId, orientation); + WindowManagerService::GetInstance().GetWindowPreferredOrientation(displayId, orientation); } void WindowManagerService::ProcessPointDown(uint32_t windowId, bool isStartDrag) @@ -613,6 +577,12 @@ WMError WindowManagerService::UpdateProperty(sptr& windowPropert WLOGFE("property is invalid"); return WMError::WM_ERROR_NULLPTR; } + if (action == PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY) { + wmsTaskLooper_->PostTask([this, windowProperty, action]() mutable { + windowController_->UpdateProperty(windowProperty, action); + }); + return WMError::WM_OK; + } return wmsTaskLooper_->ScheduleTask([this, &windowProperty, action]() { WM_SCOPED_TRACE("wms:UpdateProperty"); WMError res = windowController_->UpdateProperty(windowProperty, action); @@ -659,10 +629,10 @@ void WindowManagerService::MinimizeWindowsByLauncher(std::vector windo }).get(); } -void WindowManagerService::GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) +void WindowManagerService::GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) { wmsTaskLooper_->ScheduleTask([this, displayId, &orientation]() mutable { - orientation = windowController_->GetFullScreenWindowRequestedOrientation(displayId); + orientation = windowController_->GetWindowPreferredOrientation(displayId); }).wait(); } diff --git a/wmserver/src/window_node.cpp b/wmserver/src/window_node.cpp index fbbb02e2..ebe6e0d9 100644 --- a/wmserver/src/window_node.cpp +++ b/wmserver/src/window_node.cpp @@ -100,13 +100,6 @@ void WindowNode::SetWindowBackgroundBlur(WindowBlurLevel level) surfaceNode_->SetBackgroundFilter(RSFilter::CreateBlurFilter(blurRadiusX, blurRadiusY)); } -void WindowNode::SetAlpha(float alpha) -{ - property_->SetAlpha(alpha); - WLOGFI("WindowEffect WinodwNode SetAlpha alpha:%{public}f", alpha); - surfaceNode_->SetAlpha(alpha); -} - void WindowNode::SetBrightness(float brightness) { property_->SetBrightness(brightness); @@ -203,6 +196,16 @@ void WindowNode::SetTouchHotAreas(const std::vector& rects) touchHotAreas_ = rects; } +void WindowNode::SetWindowSizeLimits(const WindowSizeLimits& sizeLimits) +{ + property_->SetSizeLimits(sizeLimits); +} + +WindowSizeLimits WindowNode::GetWindowSizeLimits() const +{ + return property_->GetSizeLimits(); +} + DragType WindowNode::GetDragType() const { return property_->GetDragType(); @@ -273,9 +276,9 @@ WindowBlurLevel WindowNode::GetWindowBackgroundBlur() const return property_->GetWindowBackgroundBlur(); } -float WindowNode::GetAlpha() const +bool WindowNode::EnableDefaultAnimation(bool propertyEnabled, bool animationPlayed) { - return property_->GetAlpha(); + return (propertyEnabled && (!animationPlayed) && (!property_->GetCustomAnimation()) && (!isAppCrash_)); } float WindowNode::GetBrightness() const diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index a2e77c39..9d596156 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -387,6 +387,10 @@ void WindowNodeContainer::UpdateWindowTree(sptr& node) bool WindowNodeContainer::UpdateRSTree(sptr& node, DisplayId displayId, bool isAdd, bool animationPlayed) { WM_FUNCTION_TRACE(); + if (node->GetWindowProperty()->GetCustomAnimation()) { + WLOGFI("not need to update RsTree since SystemWindowAnimation is playing"); + return false; + } if (node->GetWindowType() == WindowType::WINDOW_TYPE_APP_COMPONENT) { WLOGFI("WINDOW_TYPE_APP_COMPONENT not need to update RsTree"); return true; @@ -413,7 +417,7 @@ bool WindowNodeContainer::UpdateRSTree(sptr& node, DisplayId display } }; - if (IsWindowAnimationEnabled && !animationPlayed && !node->isAppCrash_) { + if (node->EnableDefaultAnimation(IsWindowAnimationEnabled, animationPlayed)) { WLOGFI("add or remove window with animation"); // default transition duration: 350ms static const RSAnimationTimingProtocol timingProtocol(350); @@ -460,7 +464,7 @@ const std::vector& WindowNodeContainer::Destroy() sptr WindowNodeContainer::FindRoot(WindowType type) const { if (WindowHelper::IsAppWindow(type) || type == WindowType::WINDOW_TYPE_DOCK_SLICE || - type == WindowType::WINDOW_TYPE_APP_COMPONENT) { + type == WindowType::WINDOW_TYPE_APP_COMPONENT || type == WindowType::WINDOW_TYPE_PLACEHOLDER) { return appWindowNode_; } if (WindowHelper::IsBelowSystemWindow(type)) { @@ -992,7 +996,7 @@ void WindowNodeContainer::FillWindowInfo(sptr& windowInfo, const spt windowInfo->mode_ = node->GetWindowMode(); windowInfo->type_ = node->GetWindowType(); auto property = node->GetWindowProperty(); - if (!property) { + if (property != nullptr) { windowInfo->isDecorEnable_ = property->GetDecorEnable(); } } @@ -1018,6 +1022,9 @@ void WindowNodeContainer::NotifyAccessibilityWindowInfo(const sptr& case WindowUpdateType::WINDOW_UPDATE_REMOVED: isNeedNotify = true; break; + case WindowUpdateType::WINDOW_UPDATE_PROPERTY: + isNeedNotify = true; + break; default: break; } @@ -1387,44 +1394,29 @@ WMError WindowNodeContainer::ToggleShownStateForAllAppWindows( std::function restoreFunc, bool restore) { WLOGFI("ToggleShownStateForAllAppWindows"); + sptr recentWindowNode = nullptr; for (auto node : aboveAppWindowNode_->children_) { if (node->GetWindowType() == WindowType::WINDOW_TYPE_LAUNCHER_RECENT) { - return WMError::WM_DO_NOTHING; + recentWindowNode = node; + if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { + return WMError::WM_OK; + } } } // to do, backup reentry: 1.ToggleShownStateForAllAppWindows fast; 2.this display should reset backupWindowIds_. if (!restore && appWindowNode_->children_.empty() && !backupWindowIds_.empty()) { backupWindowIds_.clear(); backupWindowMode_.clear(); + backupDisplaySplitWindowMode_.clear(); backupDividerWindowRect_.clear(); } if (!restore && !appWindowNode_->children_.empty() && backupWindowIds_.empty()) { WLOGFI("backup"); - std::set displayIdSet; - backupWindowMode_.clear(); - for (auto& appNode : appWindowNode_->children_) { - // exclude exceptional window - if (!WindowHelper::IsMainWindow(appNode->GetWindowType())) { - WLOGFE("is not main window, windowId:%{public}u", appNode->GetWindowId()); - continue; - } - // minimize window - WLOGFD("minimize window, windowId:%{public}u", appNode->GetWindowId()); - backupWindowIds_.emplace_back(appNode->GetWindowId()); - backupWindowMode_[appNode->GetWindowId()] = appNode->GetWindowMode(); - displayIdSet.insert(appNode->GetDisplayId()); - if (appNode->GetWindowToken()) { - appNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN); - } - } - backupDividerWindowRect_.clear(); - for (auto displayId : displayIdSet) { - auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId); - if (windowPair == nullptr || windowPair->GetDividerWindow() == nullptr) { - continue; - } - backupDividerWindowRect_[displayId] = windowPair->GetDividerWindow()->GetWindowRect(); + if (recentWindowNode != nullptr && recentWindowNode->GetWindowToken() != nullptr) { + WLOGFI("hide recent"); + recentWindowNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN); } + BackUpAllAppWindows(); } else if (restore && !backupWindowIds_.empty()) { WLOGFI("restore"); RestoreAllAppWindows(restoreFunc); @@ -1434,6 +1426,40 @@ WMError WindowNodeContainer::ToggleShownStateForAllAppWindows( return WMError::WM_OK; } +void WindowNodeContainer::BackUpAllAppWindows() +{ + std::set displayIdSet; + backupWindowMode_.clear(); + backupDisplaySplitWindowMode_.clear(); + for (auto& appNode : appWindowNode_->children_) { + // exclude exceptional window + if (!WindowHelper::IsMainWindow(appNode->GetWindowType())) { + WLOGFE("is not main window, windowId:%{public}u", appNode->GetWindowId()); + continue; + } + // minimize window + WLOGFD("minimize window, windowId:%{public}u", appNode->GetWindowId()); + backupWindowIds_.emplace_back(appNode->GetWindowId()); + auto windowMode = appNode->GetWindowMode(); + backupWindowMode_[appNode->GetWindowId()] = windowMode; + if (WindowHelper::IsSplitWindowMode(windowMode)) { + backupDisplaySplitWindowMode_[appNode->GetWindowId()].insert(windowMode); + } + displayIdSet.insert(appNode->GetDisplayId()); + if (appNode->GetWindowToken()) { + appNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN); + } + } + backupDividerWindowRect_.clear(); + for (auto displayId : displayIdSet) { + auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId); + if (windowPair == nullptr || windowPair->GetDividerWindow() == nullptr) { + continue; + } + backupDividerWindowRect_[displayId] = windowPair->GetDividerWindow()->GetWindowRect(); + } +} + void WindowNodeContainer::RestoreAllAppWindows(std::function restoreFunc) { std::vector backupWindowIds(backupWindowIds_); @@ -1442,7 +1468,10 @@ void WindowNodeContainer::RestoreAllAppWindows(std::functionGetWindowPairByDisplayId(displayId); if (windowPair != nullptr) { - windowPair->SetAllAppWindowsRestoring(true); + if (backupDisplaySplitWindowMode_[displayId].count(WindowMode::WINDOW_MODE_SPLIT_PRIMARY) > 0 && + backupDisplaySplitWindowMode_[displayId].count(WindowMode::WINDOW_MODE_SPLIT_SECONDARY) > 0) { + windowPair->SetAllSplitAppWindowsRestoring(true); + } windowPairs.emplace_back(windowPair); } } @@ -1454,7 +1483,7 @@ void WindowNodeContainer::RestoreAllAppWindows(std::functionSetAllAppWindowsRestoring(false); + windowPair->SetAllSplitAppWindowsRestoring(false); } layoutPolicy_->SetSplitDividerWindowRects(backupDividerWindowRect_); backupWindowIds_.clear(); @@ -1533,6 +1562,25 @@ WMError WindowNodeContainer::SwitchLayoutPolicy(WindowLayoutMode dstMode, Displa return WMError::WM_OK; } +void WindowNodeContainer::UpdateModeSupportInfoWhenKeyguardChange(const sptr& node, bool up) +{ + if (!WindowHelper::IsWindowModeSupported(node->GetWindowProperty()->GetRequestModeSupportInfo(), + WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) { + WLOGFD("window doesn't support split mode, winId: %{public}d", node->GetWindowId()); + return; + } + uint32_t modeSupportInfo; + if (up) { + modeSupportInfo = node->GetModeSupportInfo() & (~WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + } else { + modeSupportInfo = node->GetModeSupportInfo() | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY; + } + node->SetModeSupportInfo(modeSupportInfo); + if (node->GetWindowToken() != nullptr) { + node->GetWindowToken()->UpdateWindowModeSupportInfo(modeSupportInfo); + } +} + void WindowNodeContainer::RaiseInputMethodWindowPriorityIfNeeded(const sptr& node) const { if (node->GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT || !isScreenLocked_) { @@ -1575,6 +1623,8 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up) } } + UpdateModeSupportInfoWhenKeyguardChange(needReZOrderNode, up); + parentNode->children_.insert(position, needReZOrderNode); if (up && WindowHelper::IsSplitWindowMode(needReZOrderNode->GetWindowMode())) { needReZOrderNode->GetWindowProperty()->ResumeLastWindowMode(); @@ -1588,8 +1638,7 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up) } windowPair->UpdateIfSplitRelated(needReZOrderNode); } - WLOGFI("ShowWhenLocked window %{public}u re-zorder when keyguard change %{public}u", - needReZOrderNode->GetWindowId(), up); + WLOGFI("window %{public}u re-zorder when keyguard change %{public}u", needReZOrderNode->GetWindowId(), up); } } @@ -1817,7 +1866,7 @@ sptr WindowNodeContainer::GetDisplayInfo(DisplayId displayId) return displayGroupInfo_->GetDisplayInfo(displayId); } -Orientation WindowNodeContainer::GetFullScreenWindowRequestedOrientation() +Orientation WindowNodeContainer::GetWindowPreferredOrientation() { std::vector> windowNodes; TraverseContainer(windowNodes); @@ -1825,6 +1874,9 @@ Orientation WindowNodeContainer::GetFullScreenWindowRequestedOrientation() if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { return node->GetRequestedOrientation(); } + if (node->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) { + return Orientation::UNSPECIFIED; + } } return Orientation::UNSPECIFIED; } @@ -1835,5 +1887,10 @@ void WindowNodeContainer::UpdateCameraFloatWindowStatus(const sptr& WindowManagerAgentController::GetInstance().UpdateCameraFloatWindowStatus(node->GetAccessTokenId(), isShowing); } } + +WindowLayoutMode WindowNodeContainer::GetCurrentLayoutMode() const +{ + return layoutMode_; +} } // namespace Rosen } // namespace OHOS diff --git a/wmserver/src/window_pair.cpp b/wmserver/src/window_pair.cpp index 87e27926..7120f4e1 100644 --- a/wmserver/src/window_pair.cpp +++ b/wmserver/src/window_pair.cpp @@ -31,8 +31,8 @@ namespace { const std::string SPLIT_SCREEN_EVENT_NAME = "common.event.SPLIT_SCREEN"; } -WindowPair::WindowPair(const DisplayId& displayId, DisplayGroupWindowTree& displayGroupWindowTree) - : displayId_(displayId), displayGroupWindowTree_(displayGroupWindowTree) { +WindowPair::WindowPair(const DisplayId& displayId) : displayId_(displayId) +{ } WindowPair::~WindowPair() @@ -183,10 +183,6 @@ void WindowPair::ExitSplitMode() hideWindow = secondary_; fullScreenWindow = primary_; } - if (WindowHelper::IsWindowModeSupported(fullScreenWindow->GetModeSupportInfo(), - WindowMode::WINDOW_MODE_FULLSCREEN)) { - fullScreenWindow->GetWindowProperty()->SetLastWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - } MinimizeApp::AddNeedMinimizeApp(hideWindow, MinimizeReason::SPLIT_QUIT); MinimizeApp::ExecuteMinimizeTargetReason(MinimizeReason::SPLIT_QUIT); WLOGFI("Exit Split Mode, Minimize Window %{public}u", hideWindow->GetWindowId()); @@ -209,7 +205,6 @@ void WindowPair::Clear() primary_ = nullptr; secondary_ = nullptr; if (divider_ != nullptr) { - // WindowInnerManager::GetInstance().DestroyWindow(); WindowInnerManager::GetInstance().DestroyInnerWindow(displayId_, WindowType::WINDOW_TYPE_DOCK_SLICE); divider_ = nullptr; } @@ -272,52 +267,6 @@ std::vector> WindowPair::GetPairedWindows() return orderedPair; } -sptr WindowPair::FindPairableWindow(sptr& node) -{ - if (node == nullptr) { - return nullptr; - } - if (!node->IsSplitMode()) { - return nullptr; - } - auto& appNodeVec = *(displayGroupWindowTree_[displayId_][WindowRootNodeType::APP_WINDOW_NODE]); - WindowMode dstMode = (node->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY ? - WindowMode::WINDOW_MODE_SPLIT_SECONDARY : WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - for (auto iter = appNodeVec.rbegin(); iter != appNodeVec.rend(); iter++) { - auto pairNode = *iter; - if (pairNode == nullptr) { - continue; - } - if (pairNode->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && - WindowHelper::IsWindowModeSupported(pairNode->GetModeSupportInfo(), dstMode)) { - pairNode->SetWindowMode(dstMode); - if (pairNode->GetWindowToken() != nullptr) { - pairNode->GetWindowToken()->UpdateWindowMode(pairNode->GetWindowMode()); - } - WLOGFI("Find full screen pair window: %{public}u", static_cast(pairNode->GetWindowId())); - return pairNode; - } - } - return nullptr; -} - -sptr WindowPair::GetPairableWindow(sptr& node) -{ - if (node == nullptr) { - return nullptr; - } - // get pairable window from window tree or send broadcast msg to start pair window - sptr pairableNode = FindPairableWindow(node); - if (pairableNode == nullptr) { - WLOGFI("Can not find pairable window from current tree."); - SendBroadcastMsg(node); - return nullptr; - } - WLOGFI("Find pairable window id: %{public}u", pairableNode->GetWindowId()); - return pairableNode; -} - - void WindowPair::UpdateIfSplitRelated(sptr& node) { if (node == nullptr) { @@ -328,29 +277,22 @@ void WindowPair::UpdateIfSplitRelated(sptr& node) WLOGI("Window id: %{public}u is not split related and paired.", node->GetWindowId()); return; } - if ((node->GetWindowType() == WindowType::WINDOW_TYPE_PLACE_HOLDER) && + if ((node->GetWindowType() == WindowType::WINDOW_TYPE_PLACEHOLDER) && ((primary_ != nullptr && primary_->GetWindowMode() == node->GetWindowMode()) || (secondary_ != nullptr && secondary_->GetWindowMode() == node->GetWindowMode()))) { - // WindowInnerManager::GetInstance().DestroyPlaceHolderWindow(); - WindowInnerManager::GetInstance().DestroyInnerWindow(displayId_, WindowType::WINDOW_TYPE_PLACE_HOLDER); + WindowInnerManager::GetInstance().DestroyInnerWindow(displayId_, WindowType::WINDOW_TYPE_PLACEHOLDER); return; } WLOGI("Current status: %{public}u, window id: %{public}u mode: %{public}u", status_, node->GetWindowId(), node->GetWindowMode()); if (status_ == WindowPairStatus::STATUS_EMPTY) { Insert(node); - if (!isAllAppWindowsRestoring_) { - // find pairable window from trees or send broadcast - // sptr pairableNode = GetPairableWindow(node); - // // insert pairable node - // Insert(pairableNode); + if (!isAllSplitAppWindowsRestoring_) { WindowMode holderMode = node->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY ? WindowMode::WINDOW_MODE_SPLIT_SECONDARY : WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - WindowInnerManager::GetInstance().CreteInnerWindow("place_holder", displayId_, - {0, 0, 512, 512}, - WindowType::WINDOW_TYPE_PLACE_HOLDER, holderMode); - // WindowInnerManager::GetInstance().CreatePlaceHolderWindow(holderMode, displayId_); - // SendBroadcastMsg(node); + WindowInnerManager::GetInstance().CreateInnerWindow("place_holder", displayId_, DEFAULT_PLACE_HOLDER_RECT, + WindowType::WINDOW_TYPE_PLACEHOLDER, holderMode); + SendBroadcastMsg(node); } } else { if (Find(node) == nullptr) { @@ -382,9 +324,7 @@ void WindowPair::UpdateWindowPairStatus() prevStatus == WindowPairStatus::STATUS_SINGLE_SECONDARY || prevStatus == WindowPairStatus::STATUS_EMPTY) && status_ == WindowPairStatus::STATUS_PAIRING) { // create divider - // WindowInnerManager::GetInstance().CreateWindow("dialog_divider_ui", WindowType::WINDOW_TYPE_DOCK_SLICE, - // initalDividerRect_); - WindowInnerManager::GetInstance().CreteInnerWindow("divider", displayId_, initalDividerRect_, + WindowInnerManager::GetInstance().CreateInnerWindow("dialog_divider_ui", displayId_, initalDividerRect_, WindowType::WINDOW_TYPE_DOCK_SLICE, WindowMode::WINDOW_MODE_FLOATING); } else if ((prevStatus == WindowPairStatus::STATUS_PAIRED_DONE || prevStatus == WindowPairStatus::STATUS_PAIRING) && (status_ != WindowPairStatus::STATUS_PAIRED_DONE && status_ != WindowPairStatus::STATUS_PAIRING)) { @@ -402,16 +342,14 @@ void WindowPair::SwitchPosition() WLOGFI("Switch the pair pos, pri: %{public}u pri-mode: %{public}u, sec: %{public}u sec-mode: %{public}u,", primary_->GetWindowId(), primary_->GetWindowMode(), secondary_->GetWindowId(), secondary_->GetWindowMode()); if (primary_->GetWindowMode() == secondary_->GetWindowMode() && - primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY && - WindowHelper::IsWindowModeSupported(primary_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_SPLIT_SECONDARY)) { + primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY) { primary_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); if (primary_->GetWindowToken() != nullptr) { primary_->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); } std::swap(primary_, secondary_); } else if (primary_->GetWindowMode() == secondary_->GetWindowMode() && - primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY && - WindowHelper::IsWindowModeSupported(secondary_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) { + primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) { secondary_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); if (secondary_->GetWindowToken() != nullptr) { secondary_->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); @@ -504,11 +442,6 @@ void WindowPair::HandleRemoveWindow(sptr& node) } } -void WindowPair::SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring) -{ - isAllAppWindowsRestoring_ = isAllAppWindowsRestoring; -} - void WindowPair::SetInitalDividerRect(const Rect& rect) { initalDividerRect_ = rect; diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index 59b64bac..d13e9626 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -117,7 +117,6 @@ sptr WindowRoot::CreateWindowNodeContainer(sptrGetLayoutPolicy()->SetFloatingWindowLimitsConfig(floatingWindowLimitsConfig_); container->GetLayoutPolicy()->SetSplitRatioConfig(splitRatioConfig_); return container; } @@ -395,12 +394,7 @@ WMError WindowRoot::ToggleShownStateForAllAppWindows() WindowManagerService::GetInstance().HandleAddWindow(property); return true; }; - WMError tmpRes = WMError::WM_OK; - if (isAllAppWindowsEmpty) { - tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, true); - } else { - tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, false); - } + WMError tmpRes = tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, isAllAppWindowsEmpty); res = (res == WMError::WM_OK) ? tmpRes : res; }); return res; @@ -486,7 +480,7 @@ WMError WindowRoot::AddWindowNode(uint32_t parentId, sptr& node, boo return res; } // limit number of main window - int mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + uint32_t mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); if (mainWindowNumber >= maxAppWindowNumber_ && node->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) { container->MinimizeOldestAppWindow(); } @@ -1315,9 +1309,14 @@ WMError WindowRoot::GetModeChangeHotZones(DisplayId displayId, return WMError::WM_OK; } -void WindowRoot::SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig) +WindowLayoutMode WindowRoot::GetCurrentLayoutMode(DisplayId displayId) { - floatingWindowLimitsConfig_ = floatingWindowLimitsConfig; + auto container = GetOrCreateWindowNodeContainer(displayId); + if (container == nullptr) { + WLOGFE("GetCurrentLayoutMode failed, window container could not be found"); + return WindowLayoutMode::BASE; + } + return container->GetCurrentLayoutMode(); } } // namespace Rosen } // namespace OHOS diff --git a/wmserver/src/zidl/window_manager_proxy.cpp b/wmserver/src/zidl/window_manager_proxy.cpp index db85b1e8..93449f2f 100644 --- a/wmserver/src/zidl/window_manager_proxy.cpp +++ b/wmserver/src/zidl/window_manager_proxy.cpp @@ -187,32 +187,6 @@ WMError WindowManagerProxy::SetWindowBackgroundBlur(uint32_t windowId, WindowBlu return static_cast(ret); } -WMError WindowManagerProxy::SetAlpha(uint32_t windowId, float alpha) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return WMError::WM_ERROR_IPC_FAILED; - } - if (!data.WriteUint32(windowId)) { - WLOGFE("Write windowId failed"); - return WMError::WM_ERROR_IPC_FAILED; - } - if (!data.WriteFloat(alpha)) { - WLOGFE("Write alpha failed"); - return WMError::WM_ERROR_IPC_FAILED; - } - if (Remote()->SendRequest(static_cast(WindowManagerMessage::TRANS_ID_SET_ALPHA), - data, reply, option) != ERR_NONE) { - return WMError::WM_ERROR_IPC_FAILED; - } - - int32_t ret = reply.ReadInt32(); - return static_cast(ret); -} - AvoidArea WindowManagerProxy::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) { MessageParcel data; diff --git a/wmserver/src/zidl/window_manager_stub.cpp b/wmserver/src/zidl/window_manager_stub.cpp index 2ae7c7cf..24cb813b 100644 --- a/wmserver/src/zidl/window_manager_stub.cpp +++ b/wmserver/src/zidl/window_manager_stub.cpp @@ -81,13 +81,6 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M reply.WriteInt32(static_cast(errCode)); break; } - case WindowManagerMessage::TRANS_ID_SET_ALPHA: { - uint32_t windowId = data.ReadUint32(); - float alpha = data.ReadFloat(); - WMError errCode = SetAlpha(windowId, alpha); - reply.WriteInt32(static_cast(errCode)); - break; - } case WindowManagerMessage::TRANS_ID_GET_AVOID_AREA: { uint32_t windowId = data.ReadUint32(); AvoidAreaType avoidAreaType = static_cast(data.ReadUint32());