Supports IME window for Tizen keyboard application.
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / tizen-wayland / tizen-wearable / watch-application-impl.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/adaptor/common/adaptor-impl.h>
23 #include <dali/internal/system/common/environment-variables.h>
24
25 namespace Dali
26 {
27 namespace Internal
28 {
29 namespace Adaptor
30 {
31 namespace
32 {
33 unsigned int GetEnvWatchRenderRefreshRate()
34 {
35   const char* envVariable = std::getenv(DALI_WATCH_REFRESH_RATE);
36
37   return envVariable ? std::atoi(envVariable) : 2u; // Default 30 fps
38 }
39
40 } // unnamed namespace
41
42 WatchApplicationPtr WatchApplication::New(
43   int*                                argc,
44   char**                              argv[],
45   const std::string&                  stylesheet,
46   Dali::WatchApplication::WINDOW_MODE windowMode)
47 {
48   WatchApplicationPtr watch(new WatchApplication(argc, argv, stylesheet, windowMode));
49   return watch;
50 }
51
52 WatchApplication::WatchApplication(int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode)
53 : Application(argc, argv, stylesheet, windowMode, PositionSize(), Framework::WATCH, WindowType::NORMAL),
54   mState(UNINITIALIZED)
55 {
56 }
57
58 WatchApplication::~WatchApplication()
59 {
60 }
61
62 void WatchApplication::OnInit()
63 {
64   Application::OnInit();
65
66   Dali::Adaptor::Get().SetRenderRefreshRate(GetEnvWatchRenderRefreshRate());
67
68   mState = INITIALIZED;
69 }
70
71 void WatchApplication::OnTerminate()
72 {
73   Application::OnTerminate();
74
75   mState = TERMINATED;
76 }
77
78 void WatchApplication::OnResume()
79 {
80   Application::OnResume();
81
82   mState = RESUMED;
83 }
84
85 void WatchApplication::OnPause()
86 {
87   Application::OnPause();
88
89   mState = PAUSED;
90 }
91
92 void WatchApplication::OnTimeTick(WatchTime& time)
93 {
94   Dali::WatchApplication watch(this);
95   mTickSignal.Emit(watch, time);
96
97   if(mState == PAUSED)
98   {
99     // This is a pre-resume scenario. All rendering engine of tizen SHOULD forcely update once at this time.
100     Internal::Adaptor::Adaptor::GetImplementation(GetAdaptor()).RequestUpdateOnce();
101   }
102
103   // A watch application will queue messages to update the UI in the signal emitted above
104   // Process these immediately to avoid a blinking issue where the old time is briefly visible
105   CoreEventInterface& eventInterface = Internal::Adaptor::Adaptor::GetImplementation(GetAdaptor());
106   eventInterface.ProcessCoreEvents();
107 }
108
109 void WatchApplication::OnAmbientTick(WatchTime& time)
110 {
111   Dali::WatchApplication watch(this);
112   mAmbientTickSignal.Emit(watch, time);
113
114   // A watch application will queue messages to update the UI in the signal emitted above
115   // Process these immediately to avoid a blinking issue where the old time is briefly visible
116   CoreEventInterface& eventInterface = Internal::Adaptor::Adaptor::GetImplementation(GetAdaptor());
117   eventInterface.ProcessCoreEvents();
118 }
119
120 void WatchApplication::OnAmbientChanged(bool ambient)
121 {
122   Dali::WatchApplication watch(this);
123   mAmbientChangeSignal.Emit(watch, ambient);
124 }
125
126 } // namespace Adaptor
127
128 } // namespace Internal
129
130 } // namespace Dali