From: Heeyong Song Date: Thu, 17 Nov 2022 06:15:46 +0000 (+0900) Subject: Add a method to update the screen size X-Git-Tag: dali_2.2.6~5^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=de66ef5b56bea3c4ad4d9b67faf1b8f0d4190d20 Add a method to update the screen size The real screen size may be different from the value of the preinitialized state. In case of ecore-wl2 backend, ecore_wl2_display_screen_size_get() may take some time. So save the screen size when it is called first and updade it when needed. Change-Id: Ief60c4f8ebcd5ba8b6dc7a0c74d8f22ed57bd757 --- diff --git a/dali/internal/adaptor/common/application-impl.cpp b/dali/internal/adaptor/common/application-impl.cpp index 1032b3a..c44318e 100644 --- a/dali/internal/adaptor/common/application-impl.cpp +++ b/dali/internal/adaptor/common/application-impl.cpp @@ -156,6 +156,9 @@ void Application::StoreWindowPositionSize(PositionSize positionSize) void Application::ChangePreInitializedWindowSize() { + // The real screen size may be different from the value of the preinitialized state. Update it. + Dali::Internal::Adaptor::WindowSystem::UpdateScreenSize(); + int screenWidth, screenHeight; Dali::Internal::Adaptor::WindowSystem::GetScreenSize(screenWidth, screenHeight); diff --git a/dali/internal/window-system/android/window-system-android.cpp b/dali/internal/window-system/android/window-system-android.cpp index 749e140..1f6b120 100644 --- a/dali/internal/window-system/android/window-system-android.cpp +++ b/dali/internal/window-system/android/window-system-android.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ void Shutdown() { } -void GetScreenSize(int& width, int& height) +void GetScreenSize(int32_t& width, int32_t& height) { ANativeWindow* window = Dali::Integration::AndroidFramework::Get().GetApplicationWindow(); width = ANativeWindow_getWidth(window); @@ -47,6 +47,10 @@ void GetScreenSize(int& width, int& height) DALI_LOG_WARNING("Native window width %d, height %d", width, height); } +void UpdateScreenSize() +{ +} + bool SetKeyboardRepeatInfo(float rate, float delay) { return false; diff --git a/dali/internal/window-system/common/window-system.h b/dali/internal/window-system/common/window-system.h index ee92762..d669791 100644 --- a/dali/internal/window-system/common/window-system.h +++ b/dali/internal/window-system/common/window-system.h @@ -18,7 +18,9 @@ * */ +// EXTERNAL_HEADERS #include +#include namespace Dali { @@ -41,7 +43,13 @@ void Shutdown(); /** * @brief Get the screen size */ -void GetScreenSize(int& width, int& height); +void GetScreenSize(int32_t& width, int32_t& height); + +/** + * @brief Update the screen size + * @note The screen size may be updated while application is running. So update the stored size. + */ +void UpdateScreenSize(); /** * @copydoc Dali::Keyboard::SetRepeatInfo() @@ -136,7 +144,7 @@ public: * @param[out] width The width of the screen * @param[out] height The height of the screen */ - virtual void GetScreenSize(int& width, int& height) = 0; + virtual void GetScreenSize(int32_t& width, int32_t& height) = 0; }; } // namespace Adaptor diff --git a/dali/internal/window-system/macos/window-system-mac.mm b/dali/internal/window-system/macos/window-system-mac.mm index 9d2ee83..70aa68c 100644 --- a/dali/internal/window-system/macos/window-system-mac.mm +++ b/dali/internal/window-system/macos/window-system-mac.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,11 +27,15 @@ void Initialize() { } -void GetScreenSize( int& width, int& height ) +void GetScreenSize( int32_t& width, int32_t& height ) { NSRect r = [[NSScreen mainScreen] frame]; - width = static_cast(r.size.width); - height = static_cast(r.size.height); + width = static_cast(r.size.width); + height = static_cast(r.size.height); +} + +void UpdateScreenSize() +{ } bool SetKeyboardRepeatInfo( float rate, float delay ) diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl/window-system-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl/window-system-ecore-wl.cpp index 626ee7e..4f57a10 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl/window-system-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl/window-system-ecore-wl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,11 +39,15 @@ void Shutdown() ecore_wl_shutdown(); } -void GetScreenSize(int& width, int& height) +void GetScreenSize(int32_t& width, int32_t& height) { ecore_wl_screen_size_get(&width, &height); } +void UpdateScreenSize() +{ +} + bool SetKeyboardRepeatInfo(float rate, float delay) { return ecore_wl_keyboard_repeat_info_set(static_cast(rate), static_cast(delay)); diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp index d2ebb00..3c086b6 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp @@ -718,8 +718,6 @@ WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surf mWindowRotationAngle(0), mScreenRotationAngle(0), mSupportedPreProtation(0), - mScreenWidth(0), - mScreenHeight(0), mNotificationChangeState(0), mScreenOffModeChangeState(0), mBrightnessChangeState(0), @@ -1692,24 +1690,26 @@ bool WindowBaseEcoreWl2::IsEglWindowRotationSupported() PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize) { PositionSize newPositionSize; + int32_t screenWidth, screenHeight; + WindowSystem::GetScreenSize(screenWidth, screenHeight); if(mWindowRotationAngle == 90) { newPositionSize.x = positionSize.y; - newPositionSize.y = mScreenHeight - (positionSize.x + positionSize.width); + newPositionSize.y = screenHeight - (positionSize.x + positionSize.width); newPositionSize.width = positionSize.height; newPositionSize.height = positionSize.width; } else if(mWindowRotationAngle == 180) { - newPositionSize.x = mScreenWidth - (positionSize.x + positionSize.width); - newPositionSize.y = mScreenHeight - (positionSize.y + positionSize.height); + newPositionSize.x = screenWidth - (positionSize.x + positionSize.width); + newPositionSize.y = screenHeight - (positionSize.y + positionSize.height); newPositionSize.width = positionSize.width; newPositionSize.height = positionSize.height; } else if(mWindowRotationAngle == 270) { - newPositionSize.x = mScreenWidth - (positionSize.y + positionSize.height); + newPositionSize.x = screenWidth - (positionSize.y + positionSize.height); newPositionSize.y = positionSize.x; newPositionSize.width = positionSize.height; newPositionSize.height = positionSize.width; @@ -1728,25 +1728,27 @@ PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize po PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize) { PositionSize newPositionSize; + int32_t screenWidth, screenHeight; + WindowSystem::GetScreenSize(screenWidth, screenHeight); if(mWindowRotationAngle == 90) { - newPositionSize.x = mScreenHeight - (positionSize.y + positionSize.height); + newPositionSize.x = screenHeight - (positionSize.y + positionSize.height); newPositionSize.y = positionSize.x; newPositionSize.width = positionSize.height; newPositionSize.height = positionSize.width; } else if(mWindowRotationAngle == 180) { - newPositionSize.x = mScreenWidth - (positionSize.x + positionSize.width); - newPositionSize.y = mScreenHeight - (positionSize.y + positionSize.height); + newPositionSize.x = screenWidth - (positionSize.x + positionSize.width); + newPositionSize.y = screenHeight - (positionSize.y + positionSize.height); newPositionSize.width = positionSize.width; newPositionSize.height = positionSize.height; } else if(mWindowRotationAngle == 270) { newPositionSize.x = positionSize.y; - newPositionSize.y = mScreenWidth - (positionSize.x + positionSize.width); + newPositionSize.y = screenWidth - (positionSize.x + positionSize.width); newPositionSize.width = positionSize.height; newPositionSize.height = positionSize.width; } @@ -2636,9 +2638,6 @@ void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize) // Set default type ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL); - - // Get Screen width, height - ecore_wl2_display_screen_size_get(display, &mScreenWidth, &mScreenHeight); } void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent) diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h index 6b66478..d5789ed 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h @@ -618,8 +618,6 @@ private: int mWindowRotationAngle; int mScreenRotationAngle; int mSupportedPreProtation; - int mScreenWidth; - int mScreenHeight; uint32_t mNotificationChangeState; uint32_t mScreenOffModeChangeState; diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp index b10af4c..514c38b 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,12 @@ namespace Adaptor { namespace WindowSystem { +namespace +{ +static int32_t gScreenWidth = 0; +static int32_t gScreenHeight = 0; +} // unnamed namespace + void Initialize() { ecore_wl2_init(); @@ -40,14 +46,28 @@ void Shutdown() ecore_wl2_shutdown(); } -void GetScreenSize(int& width, int& height) +void GetScreenSize(int32_t& width, int32_t& height) +{ + if(gScreenWidth == 0 || gScreenHeight == 0) + { + Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL); + if(display) + { + ecore_wl2_display_screen_size_get(display, &gScreenWidth, &gScreenHeight); + DALI_ASSERT_ALWAYS((gScreenWidth > 0) && "screen width is 0"); + DALI_ASSERT_ALWAYS((gScreenHeight > 0) && "screen height is 0"); + } + } + width = gScreenWidth; + height = gScreenHeight; +} + +void UpdateScreenSize() { Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL); if(display) { - ecore_wl2_display_screen_size_get(display, &width, &height); - DALI_ASSERT_ALWAYS((width > 0) && "screen width is 0"); - DALI_ASSERT_ALWAYS((height > 0) && "screen height is 0"); + ecore_wl2_display_screen_size_get(display, &gScreenWidth, &gScreenHeight); } } diff --git a/dali/internal/window-system/ubuntu-x11/window-system-ecore-x.cpp b/dali/internal/window-system/ubuntu-x11/window-system-ecore-x.cpp index aa91438..71f840e 100644 --- a/dali/internal/window-system/ubuntu-x11/window-system-ecore-x.cpp +++ b/dali/internal/window-system/ubuntu-x11/window-system-ecore-x.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,11 +40,15 @@ void Shutdown() ecore_x_shutdown(); } -void GetScreenSize(int& width, int& height) +void GetScreenSize(int32_t& width, int32_t& height) { ecore_x_screen_size_get(ecore_x_default_screen_get(), &width, &height); } +void UpdateScreenSize() +{ +} + bool SetKeyboardRepeatInfo(float rate, float delay) { return false; diff --git a/dali/internal/window-system/windows/window-system-win.cpp b/dali/internal/window-system/windows/window-system-win.cpp index 1536d0d..7740edd 100644 --- a/dali/internal/window-system/windows/window-system-win.cpp +++ b/dali/internal/window-system/windows/window-system-win.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,12 +33,16 @@ void Initialize() { } -void GetScreenSize(int& width, int& height) +void GetScreenSize(int32_t& width, int32_t& height) { width = GetSystemMetrics(SM_CXSCREEN); height = GetSystemMetrics(SM_CYSCREEN); } +void UpdateScreenSize() +{ +} + bool SetKeyboardRepeatInfo(float rate, float delay) { return false; diff --git a/dali/internal/window-system/x11/window-system-x.cpp b/dali/internal/window-system/x11/window-system-x.cpp index 13c5618..d439812 100644 --- a/dali/internal/window-system/x11/window-system-x.cpp +++ b/dali/internal/window-system/x11/window-system-x.cpp @@ -1044,6 +1044,10 @@ void GetScreenSize(int& width, int& height) } } +void UpdateScreenSize() +{ +} + bool SetKeyboardRepeatInfo(float rate, float delay) { return false;