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
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);
/*
- * 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.
{
}
-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);
DALI_LOG_WARNING("Native window width %d, height %d", width, height);
}
+void UpdateScreenSize()
+{
+}
+
bool SetKeyboardRepeatInfo(float rate, float delay)
{
return false;
*
*/
+// EXTERNAL_HEADERS
#include <dali/public-api/object/any.h>
+#include <cstdint>
namespace Dali
{
/**
* @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()
* @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
/*
- * 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.
{
}
-void GetScreenSize( int& width, int& height )
+void GetScreenSize( int32_t& width, int32_t& height )
{
NSRect r = [[NSScreen mainScreen] frame];
- width = static_cast<int>(r.size.width);
- height = static_cast<int>(r.size.height);
+ width = static_cast<int32_t>(r.size.width);
+ height = static_cast<int32_t>(r.size.height);
+}
+
+void UpdateScreenSize()
+{
}
bool SetKeyboardRepeatInfo( float rate, float delay )
/*
- * 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.
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<double>(rate), static_cast<double>(delay));
mWindowRotationAngle(0),
mScreenRotationAngle(0),
mSupportedPreProtation(0),
- mScreenWidth(0),
- mScreenHeight(0),
mNotificationChangeState(0),
mScreenOffModeChangeState(0),
mBrightnessChangeState(0),
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;
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;
}
// 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)
int mWindowRotationAngle;
int mScreenRotationAngle;
int mSupportedPreProtation;
- int mScreenWidth;
- int mScreenHeight;
uint32_t mNotificationChangeState;
uint32_t mScreenOffModeChangeState;
/*
- * 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.
{
namespace WindowSystem
{
+namespace
+{
+static int32_t gScreenWidth = 0;
+static int32_t gScreenHeight = 0;
+} // unnamed namespace
+
void Initialize()
{
ecore_wl2_init();
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);
}
}
/*
- * 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.
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;
/*
- * 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.
{
}
-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;
}
}
+void UpdateScreenSize()
+{
+}
+
bool SetKeyboardRepeatInfo(float rate, float delay)
{
return false;