/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
// pre-initialized application
internal->SetCommandLineOptions(argc, argv);
- if(argc && (*argc > 0))
- {
- internal->GetWindow().SetClass((*argv)[0], "");
- }
internal->SetStyleSheet(stylesheet);
internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
{
Dali::TextAbstraction::FontClientPreInitialize();
- gPreInitializedApplication = new Application(argc, argv, "", Dali::Application::OPAQUE, PositionSize(), Framework::NORMAL, WindowType::NORMAL, false);
- gPreInitializedApplication->CreateWindow(); // Only create window
+ gPreInitializedApplication = new Application(argc, argv, "", Dali::Application::OPAQUE, PositionSize(), Framework::NORMAL, WindowType::NORMAL, false);
gPreInitializedApplication->mLaunchpadState = Launchpad::PRE_INITIALIZED;
+ gPreInitializedApplication->CreateWindow(); // Only create window
}
}
mAppControlSignal(),
mLanguageChangedSignal(),
mRegionChangedSignal(),
- mEventLoop(nullptr),
mFramework(nullptr),
mCommandLineOptions(nullptr),
mAdaptorBuilder(nullptr),
mAdaptor(nullptr),
+ mEnvironmentOptions(nullptr),
mMainWindow(),
mMainWindowMode(windowMode),
mMainWindowName(),
mStylesheet(stylesheet),
- mEnvironmentOptions(),
mWindowPositionSize(positionSize),
mLaunchpadState(Launchpad::NONE),
mDefaultWindowType(type),
mUseUiThread(useUiThread),
mSlotDelegate(this)
{
- // Get mName from environment options
- mMainWindowName = mEnvironmentOptions.GetWindowName();
- if(mMainWindowName.empty() && argc && (*argc > 0))
+ // Set mName from command-line args
+ if(argc && (*argc > 0))
{
- // Set mName from command-line args if environment option not set
mMainWindowName = (*argv)[0];
}
mUseUiThread = true;
}
+ WindowSystem::Initialize();
+
mCommandLineOptions = new CommandLineOptions(argc, argv);
mFramework = new Framework(*this, *this, argc, argv, applicationType, mUseUiThread);
mUseRemoteSurface = (applicationType == Framework::WATCH);
delete mAdaptorBuilder;
delete mCommandLineOptions;
delete mFramework;
+
+ WindowSystem::Shutdown();
}
void Application::StoreWindowPositionSize(PositionSize positionSize)
mWindowPositionSize = positionSize;
}
-void Application::ChangePreInitializedWindowSize()
+void Application::ChangePreInitializedWindowInfo()
{
+ // Set window name
+ auto windowClassName = mEnvironmentOptions->GetWindowClassName();
+ auto windowName = mEnvironmentOptions->GetWindowName();
+ if(!windowName.empty())
+ {
+ mMainWindowName = windowName;
+ }
+ mMainWindow.SetClass(mMainWindowName, windowClassName);
+
// 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);
+ // Set window position / size
if(mWindowPositionSize != PositionSize(0, 0, 0, 0))
{
Dali::DevelWindow::SetPositionSize(mMainWindow, mWindowPositionSize);
mWindowPositionSize.height = mCommandLineOptions->stageHeight;
mMainWindow.SetSize(Dali::Window::WindowSize(mWindowPositionSize.width, mWindowPositionSize.height));
}
- else if(mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight())
+ else if(mEnvironmentOptions->GetWindowWidth() && mEnvironmentOptions->GetWindowHeight())
{
// Environment options override full screen functionality if command line arguments not provided
- mWindowPositionSize.width = mEnvironmentOptions.GetWindowWidth();
- mWindowPositionSize.height = mEnvironmentOptions.GetWindowHeight();
+ mWindowPositionSize.width = mEnvironmentOptions->GetWindowWidth();
+ mWindowPositionSize.height = mEnvironmentOptions->GetWindowHeight();
mMainWindow.SetSize(Dali::Window::WindowSize(mWindowPositionSize.width, mWindowPositionSize.height));
}
else if(screenWidth != mWindowPositionSize.width || screenHeight != mWindowPositionSize.height)
void Application::CreateWindow()
{
- if(mWindowPositionSize.width == 0 && mWindowPositionSize.height == 0)
+ Internal::Adaptor::Window* window;
+
+ if(mLaunchpadState != Launchpad::PRE_INITIALIZED)
{
- if(mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0)
+ if(mWindowPositionSize.width == 0 && mWindowPositionSize.height == 0)
{
- // Command line options override environment options and full screen
- mWindowPositionSize.width = mCommandLineOptions->stageWidth;
- mWindowPositionSize.height = mCommandLineOptions->stageHeight;
+ if(mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0)
+ {
+ // Command line options override environment options and full screen
+ mWindowPositionSize.width = mCommandLineOptions->stageWidth;
+ mWindowPositionSize.height = mCommandLineOptions->stageHeight;
+ }
+ else if(mEnvironmentOptions->GetWindowWidth() && mEnvironmentOptions->GetWindowHeight())
+ {
+ // Environment options override full screen functionality if command line arguments not provided
+ mWindowPositionSize.width = mEnvironmentOptions->GetWindowWidth();
+ mWindowPositionSize.height = mEnvironmentOptions->GetWindowHeight();
+ }
}
- else if(mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight())
+
+ auto windowClassName = mEnvironmentOptions->GetWindowClassName();
+ auto windowName = mEnvironmentOptions->GetWindowName();
+ if(!windowName.empty())
{
- // Environment options override full screen functionality if command line arguments not provided
- mWindowPositionSize.width = mEnvironmentOptions.GetWindowWidth();
- mWindowPositionSize.height = mEnvironmentOptions.GetWindowHeight();
+ mMainWindowName = windowName;
}
- }
- const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName();
+ window = Internal::Adaptor::Window::New(mWindowPositionSize, mMainWindowName, windowClassName, mDefaultWindowType, mMainWindowMode == Dali::Application::TRANSPARENT);
+ }
+ else
+ {
+ // The position, size and the window name of the pre-initialized application will be updated in ChangePreInitializedWindowInfo()
+ // when the real application is launched.
+ window = Internal::Adaptor::Window::New(mWindowPositionSize, "", "", mDefaultWindowType, mMainWindowMode == Dali::Application::TRANSPARENT);
+ }
- Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(mWindowPositionSize, mMainWindowName, windowClassName, mDefaultWindowType, mMainWindowMode == Dali::Application::TRANSPARENT);
- mMainWindow = Dali::Window(window);
+ mMainWindow = Dali::Window(window);
// Quit the application when the window is closed
GetImplementation(mMainWindow).DeleteRequestSignal().Connect(mSlotDelegate, &Application::Quit);
Integration::SceneHolder sceneHolder = Integration::SceneHolder(&Dali::GetImplementation(mMainWindow));
- mAdaptor = Adaptor::New(graphicsFactory, sceneHolder, &mEnvironmentOptions);
+ mAdaptor = Adaptor::New(graphicsFactory, sceneHolder, mEnvironmentOptions.get());
Adaptor::GetImplementation(*mAdaptor).SetUseRemoteSurface(mUseRemoteSurface);
}
void Application::CreateAdaptorBuilder()
{
- mAdaptorBuilder = new AdaptorBuilder(mEnvironmentOptions);
+ mAdaptorBuilder = new AdaptorBuilder(*mEnvironmentOptions);
}
void Application::MainLoop()
void Application::OnInit()
{
+ mEnvironmentOptions = std::unique_ptr<EnvironmentOptions>(new EnvironmentOptions());
+
mFramework->AddAbortCallback(MakeCallback(this, &Application::QuitFromMainLoop));
CreateAdaptorBuilder();
if(mLaunchpadState == Launchpad::PRE_INITIALIZED)
{
- ChangePreInitializedWindowSize();
+ ChangePreInitializedWindowInfo();
}
// Run the adaptor
mCommandLineOptions = new CommandLineOptions(argc, argv);
mFramework->SetCommandLineOptions(argc, argv);
+
+ if(argc && (*argc > 0))
+ {
+ // Set mName from command-line args
+ mMainWindowName = (*argv)[0];
+ }
}
void Application::SetDefaultWindowType(WindowType type)
#define DALI_INTERNAL_APPLICATION_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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 Launchpad
class CommandLineOptions;
-class EventLoop;
typedef Dali::Rect<int> PositionSize;
void QuitFromMainLoop();
/**
- * Changes size of preInitialized window
+ * Changes information of preInitialized window
*/
- void ChangePreInitializedWindowSize();
+ void ChangePreInitializedWindowInfo();
private:
AppSignalType mInitSignal;
LowMemorySignalType mTaskLowMemorySignal;
DeviceOrientationChangedSignalType mTaskDeviceOrientationChangedSignal;
- EventLoop* mEventLoop;
Framework* mFramework;
CommandLineOptions* mCommandLineOptions;
Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder; ///< The adaptor builder
Dali::Adaptor* mAdaptor;
+ std::unique_ptr<EnvironmentOptions> mEnvironmentOptions;
// The Main Window is that window created by the Application during initial startup
// (previously this was the only window)
Dali::Application::WINDOW_MODE mMainWindowMode; ///< Window mode of the main window
std::string mMainWindowName; ///< Name of the main window as obtained from environment options
- std::string mStylesheet;
- EnvironmentOptions mEnvironmentOptions;
- PositionSize mWindowPositionSize;
- Launchpad::State mLaunchpadState;
- bool mUseRemoteSurface;
- WindowType mDefaultWindowType; ///< Default window's type. It is used when Application is created.
- bool mUseUiThread;
+ std::string mStylesheet;
+ PositionSize mWindowPositionSize;
+ Launchpad::State mLaunchpadState;
+ WindowType mDefaultWindowType; ///< Default window's type. It is used when Application is created.
+ bool mUseRemoteSurface;
+ bool mUseUiThread;
SlotDelegate<Application> mSlotDelegate;
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/adaptor/common/thread-controller-interface.h>
#include <dali/internal/offscreen/common/offscreen-window-impl.h>
+#include <dali/internal/window-system/common/window-system.h>
namespace Dali
{
OffscreenApplication::OffscreenApplication(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode)
{
+ Dali::Internal::Adaptor::WindowSystem::Initialize();
+
// Generate a default window
IntrusivePtr<Internal::OffscreenWindow> impl = Internal::OffscreenWindow::New(width, height, surface, isTranslucent);
mDefaultWindow = Dali::OffscreenWindow(impl.Get());
impl->Initialize(true);
}
+OffscreenApplication::~OffscreenApplication()
+{
+ Dali::Internal::Adaptor::WindowSystem::Shutdown();
+}
+
void OffscreenApplication::Start()
{
// Start the adaptor
#define DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
/**
* Destructor
*/
- virtual ~OffscreenApplication() = default;
+ virtual ~OffscreenApplication();
/**
* @copydoc Dali::OffscreenApplication::Start()
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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 Shutdown()
+{
+}
+
void GetScreenSize( int32_t& width, int32_t& height )
{
NSRect r = [[NSScreen mainScreen] frame];
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
#include <dali/internal/input/common/key-impl.h>
#include <dali/internal/window-system/common/window-impl.h>
#include <dali/internal/window-system/common/window-render-surface.h>
-#include <dali/internal/window-system/common/window-system.h>
// EXTERNAL_HEADERS
#include <Ecore_Input.h>
if(mOwnSurface)
{
ecore_wl_window_free(mEcoreWindow);
-
- WindowSystem::Shutdown();
}
}
else
{
// we own the surface about to created
- WindowSystem::Initialize();
-
mOwnSurface = true;
CreateWindow(positionSize);
}
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
if(mOwnSurface)
{
ecore_wl2_window_free(mEcoreWindow);
-
- WindowSystem::Shutdown();
}
}
else
{
// we own the surface about to created
- WindowSystem::Initialize();
-
mOwnSurface = true;
CreateWindow(positionSize);
}
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
#include <dali/internal/graphics/gles/egl-implementation.h>
#include <dali/internal/system/common/trigger-event.h>
#include <dali/internal/window-system/common/display-connection.h>
-#include <dali/internal/window-system/common/window-system.h>
namespace Dali
{
mTbmQueue(NULL),
mThreadSynchronization(NULL)
{
- Dali::Internal::Adaptor::WindowSystem::Initialize();
-
if(surface.Empty())
{
mSurfaceSize = surfaceSize;
DALI_LOG_INFO(gNativeSurfaceLogFilter, Debug::General, "Own tbm surface queue destroy\n");
}
-
- Dali::Internal::Adaptor::WindowSystem::Shutdown();
}
void NativeRenderSurfaceEcoreWl::SetRenderNotification(TriggerEventInterface* renderNotification)
// INTERNAL HEADERS
#include <dali/internal/window-system/common/window-impl.h>
#include <dali/internal/window-system/common/window-render-surface.h>
-#include <dali/internal/window-system/common/window-system.h>
#include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
// EXTERNAL_HEADERS
if(mOwnSurface)
{
ecore_x_window_free(mEcoreWindow);
-
- WindowSystem::Shutdown();
}
}
// if the surface is empty, create a new one.
if(surfaceId == 0)
{
- WindowSystem::Initialize();
-
// we own the surface about to created
mOwnSurface = true;
CreateWindow(positionSize, isTransparent);
if(mOwnSurface)
{
XDestroyWindow(WindowSystem::GetImplementation().GetXDisplay(), mWindow);
-
- /**** @todo Should not be destroyed here! ****/
- WindowSystem::Shutdown();
}
}
// if the surface is empty, create a new one.
if(surfaceId == 0)
{
- /**** @todo Should be created from somewhere else! ****/
- WindowSystem::Initialize();
-
// we own the surface about to created
mOwnSurface = true;
CreateWindow(positionSize, isTransparent);
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
{
// pre-initialized application
internal->SetCommandLineOptions(argc, argv);
- if(argc && (*argc > 0))
- {
- internal->GetWindow().SetClass((*argv)[0], "");
- }
}
else
{
{
// pre-initialized application
internal->SetCommandLineOptions(argc, argv);
- if(argc && (*argc > 0))
- {
- internal->GetWindow().SetClass((*argv)[0], "");
- }
internal->SetStyleSheet(stylesheet);
}
else
{
// pre-initialized application
internal->SetCommandLineOptions(argc, argv);
- if(argc && (*argc > 0))
- {
- internal->GetWindow().SetClass((*argv)[0], "");
- }
internal->SetStyleSheet(stylesheet);
internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
{
// pre-initialized application
internal->SetCommandLineOptions(argc, argv);
- if(argc && (*argc > 0))
- {
- internal->GetWindow().SetClass((*argv)[0], "");
- }
internal->SetStyleSheet(stylesheet);
internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));
{
// pre-initialized application
internal->SetCommandLineOptions(argc, argv);
- if(argc && (*argc > 0))
- {
- internal->GetWindow().SetClass((*argv)[0], "");
- }
internal->SetStyleSheet(stylesheet);
internal->GetWindow().SetTransparency((windowMode == Application::OPAQUE ? false : true));