2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file client_submode_support.cpp
18 * @author Jihoon Chung (jihoon.chung@samsung.com)
22 #include "client_submode_support.h"
27 #include <Elementary.h>
30 #include <dpl/assert.h>
31 #include <dpl/log/secure_log.h>
32 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
34 #include <application_data.h>
36 namespace ClientModule {
38 const unsigned int EMPTY = 0;
39 const unsigned int INLINE_MODE = 1;
40 const unsigned int TRANSIENT_WINDOW = 1 << 1;
43 //Implementation class
44 class SubmodeSupportImplementation
48 WrtDB::TizenAppId m_appId;
51 void setMode(const int mode)
56 bool getMode(const int mode)
61 static Eina_Bool destoryCallback(void* data, int /*type*/, void* event)
64 Ecore_X_Window callerId = reinterpret_cast<Ecore_X_Window>(data);
67 Ecore_X_Event_Window_Hide* ev =
68 static_cast<Ecore_X_Event_Window_Hide*>(event);
70 if(ev->win == callerId) {
73 return ECORE_CALLBACK_CANCEL;
77 SubmodeSupportImplementation() :
83 void initialize(WrtDB::TizenAppId appId)
88 WrtDB::WidgetDAOReadOnly dao(m_appId);
89 WrtDB::WidgetAppControlList widgetApplicationControlList;
90 dao.getAppControlList(widgetApplicationControlList);
91 FOREACH(it, widgetApplicationControlList) {
92 if (it->disposition ==
93 WrtDB::WidgetAppControl::Disposition::INLINE)
100 m_initialized = true;
103 void deinitialize(void)
106 m_initialized = false;
109 bool isInlineMode(void)
111 return getMode(INLINE_MODE);
114 bool isNeedTerminateOnSuspend(void)
116 if (isInlineMode()) {
117 return !getMode(TRANSIENT_WINDOW);
122 bool transientWindow(Ecore_X_Window calleeId)
125 if (!m_initialized) {
126 _E("not initialized");
130 bundle* b = ApplicationDataSingleton::Instance().getBundle();
132 _W("Service data is empty");
135 const char* callerIdPtr = bundle_get_val(b, "__APP_SVC_K_WIN_ID__");
137 Ecore_X_Window callerId = atoi(callerIdPtr);
138 _D("Caller x handle = %u", callerId);
139 ecore_x_icccm_transient_for_set(calleeId, callerId);
140 ecore_x_window_client_manage(callerId);
141 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY,
143 reinterpret_cast<void*>(callerId));
144 setMode(TRANSIENT_WINDOW);
146 _W("Service data is empty");
154 SubmodeSupport::SubmodeSupport() :
155 m_impl(new SubmodeSupportImplementation())
159 SubmodeSupport::~SubmodeSupport()
163 void SubmodeSupport::initialize(WrtDB::TizenAppId appId)
165 m_impl->initialize(appId);
168 void SubmodeSupport::deinitialize(void)
170 m_impl->deinitialize();
173 bool SubmodeSupport::isInlineMode(void)
175 return m_impl->isInlineMode();
178 bool SubmodeSupport::isNeedTerminateOnSuspend(void)
180 return m_impl->isNeedTerminateOnSuspend();
183 bool SubmodeSupport::transientWindow(Ecore_X_Window calleeId)
185 return m_impl->transientWindow(calleeId);
187 } // namespace ClientModule