#include "atom/app/runtime.h"
#include "atom/app/ui_runtime.h"
+#include "atom/app/watch_runtime.h"
+#include "atom/browser/native_window_efl.h"
#include "base/logging.h"
+#include "efl/window_factory.h"
+#include "tizen/common/application_data.h"
namespace runtime {
else if (app_data->app_type() == common::ApplicationData::IME) {
return std::unique_ptr<Runtime>(new ImeRuntime(app_data));
}
-#endif // IME_FEATURE_SUPPORT
-#ifdef WATCH_FACE_FEATURE_SUPPORT
- else if (app_data->app_type() == common::ApplicationData::WATCH) {
- return std::unique_ptr<Runtime>(new WatchRuntime(app_data));
- }
-#endif // WATCH_FACE_FEATURE_SUPPORT
- else { */
+#endif // IME_FEATURE_SUPPORT */
+ auto app_data = common::ApplicationDataManager::GetCurrentAppData();
+ efl::WindowFactory::SetDelegate(&atom::NativeWindowEfl::GetHostWindowDelegate);
+ if (app_data->app_type() == common::ApplicationData::WATCH)
+ return std::unique_ptr<Runtime>(new WatchRuntime(params));
+ else
return std::unique_ptr<Runtime>(new UiRuntime(params));
- //}
}
} // namespace runtime
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <app.h>
+#include <string>
+#include <vector>
+#include <watch_app_efl.h>
+
+#include "atom/app/atom_main_delegate.h"
+#include "atom/app/watch_runtime.h"
+#include "atom/browser/atom_browser_client.h"
+#include "atom/browser/atom_browser_main_parts.h"
+#include "atom/browser/browser.h"
+#include "atom/common/atom_command_line.h"
+#include "base/logging.h"
+#include "content/public/app/content_main.h"
+#include "gin/v8_initializer.h"
+#include "tizen/common/app_control.h"
+#include "tizen/common/app_db.h"
+#include "tizen/common/application_data.h"
+#include "tizen/common/command_line.h"
+#include "tizen/common/constants.h"
+
+namespace runtime {
+
+WatchRuntime::WatchRuntime(content::ContentMainParams *params)
+ : _params(params) {
+ // This line's position is essential as this creates the Browser
+ // object which is needed later on by watch_runtime in its watch_loop callbacks
+ atom::AtomBrowserMainParts::SetNodeEnvironment();
+}
+
+WatchRuntime::~WatchRuntime() {
+}
+
+void WatchRuntime::SetParam(content::ContentMainParams *params) {
+ if (_params)
+ LOG(ERROR) << "Use SetParam only when params is null";
+ else
+ _params = params;
+}
+
+bool WatchRuntime::OnCreate() {
+ auto appdata = common::ApplicationDataManager::GetCurrentAppData();
+ if (appdata->splash_screen_info()) {
+ atom::Browser* browser_model = atom::Browser::Get();
+ browser_model->SetSplashScreen();
+ }
+
+ return true;
+}
+
+void WatchRuntime::OnTerminate() {
+ LOG(ERROR) << "OnTerminate()";
+ atom::Browser *browser_model = atom::Browser::Get();
+}
+
+void WatchRuntime::OnPause() {
+ LOG(ERROR) << "OnPause()";
+ atom::Browser *browser_model = atom::Browser::Get();
+ browser_model->Hide();
+}
+
+void WatchRuntime::OnResume() {
+ LOG(ERROR) << "OnResume()";
+ atom::Browser *browser_model = atom::Browser::Get();
+ browser_model->Show();
+}
+
+void WatchRuntime::OnAppControl(app_control_h app_control) {
+ LOG(ERROR) << "OnAppControl()";
+ std::unique_ptr<common::AppControl>
+ appcontrol(new common::AppControl(app_control));
+ common::AppDB* appdb = common::AppDB::GetInstance();
+ appdb->Set(kAppDBRuntimeSection, kAppDBRuntimeBundle,
+ appcontrol->encoded_bundle());
+ atom::Browser *browser_model = atom::Browser::Get();
+ if (browser_model->launched()) {
+ browser_model->AppControl(std::move(appcontrol));
+ } else {
+ browser_model->Initialize();
+ browser_model->Launch(std::move(appcontrol));
+ }
+}
+
+void WatchRuntime::OnLanguageChanged(const std::string& language) {
+ LOG(ERROR) << "OnLanguageChanged()";
+}
+
+void WatchRuntime::OnLowMemory() {
+ LOG(ERROR) << "OnLowMemory()";
+}
+
+int WatchRuntime::Exec() {
+ watch_app_lifecycle_callback_s ops = {NULL, NULL, NULL, NULL, NULL};
+
+ // onCreate
+ ops.create = [](int width, int height, void *data) -> bool {
+ LOG(ERROR) << "Create Tizen App.";
+ WatchRuntime *runtime = (WatchRuntime*)data;
+ runtime->OnCreate();
+ content::ContentMain(*runtime->_params);
+ return true;
+ };
+
+ // onTerminate
+ ops.terminate = [](void* data) -> void {
+ LOG(ERROR) << "Terminate Tizen App.";
+ WatchRuntime *runtime = (WatchRuntime*)data;
+ runtime->OnTerminate();
+ };
+
+ // onPause
+ ops.pause = [](void* data) -> void {
+ LOG(ERROR) << "Pause Tizen App.";
+ WatchRuntime *runtime = (WatchRuntime*)data;
+ runtime->OnPause();
+ };
+
+ // onResume
+ ops.resume = [](void* data) -> void {
+ LOG(ERROR) << "Resume Tizen App.";
+ WatchRuntime *runtime = (WatchRuntime*)data;
+ runtime->OnResume();
+ };
+
+ // onAppControl
+ ops.app_control = [](app_control_h app_control, void* data) -> void {
+ LOG(ERROR) << "app_control Tizen App.";
+ WatchRuntime *runtime = (WatchRuntime*)data;
+ runtime->OnAppControl(app_control);
+ };
+
+ return watch_app_main(_params->argc, const_cast<char**>(_params->argv), &ops, this);
+}
+} //namespace
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WATCH_RUNTIME_H_
+#define WATCH_RUNTIME_H_
+
+#include <app.h>
+#include <string>
+#include <watch_app.h>
+#include "atom/app/runtime.h"
+#include "content/public/app/content_main.h"
+
+namespace runtime {
+
+class WatchRuntime : public Runtime {
+ public:
+ WatchRuntime(content::ContentMainParams *params);
+ virtual ~WatchRuntime();
+
+ virtual int Exec();
+ virtual void SetParam(content::ContentMainParams *params);
+
+ protected:
+ virtual bool OnCreate();
+ virtual void OnTerminate();
+ virtual void OnPause();
+ virtual void OnResume();
+ virtual void OnAppControl(app_control_h app_control);
+ virtual void OnLanguageChanged(const std::string& language);
+ virtual void OnLowMemory();
+
+ private:
+ content::ContentMainParams *_params;
+};
+
+} // namespace runtime
+
+#endif // XWALK_RUNTIME_BROWSER_WATCH_RUNTIME_H_
#include "atom/browser/native_window_efl.h"
#include <Elementary.h>
+#include <map>
+#include <watch_app_efl.h>
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "content/public/browser/web_contents.h"
#include "efl/window_factory.h"
+#include "tizen/common/application_data.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image.h"
namespace {
+std::map<const content::WebContents*, Evas_Object*> window_map_;
const int kDefaultWindowWidthDip = 800;
const int kDefaultWindowHeightDip = 600;
#endif
}
+Evas_Object* NativeWindowEfl::GetHostWindowDelegate(const content::WebContents* web_contents) {
+ LOG(ERROR) << "NativeWindowEfl::GetHostWindowDelegate";
+ if (window_map_.find(web_contents) != window_map_.end())
+ return window_map_[web_contents];
+
+ Evas_Object* win = NULL;
+ auto app_data = common::ApplicationDataManager::GetCurrentAppData();
+ if (app_data->app_type() == common::ApplicationData::WATCH) {
+ elm_config_accel_preference_set("opengl");
+ watch_app_get_elm_win(&win);
+ elm_win_alpha_set(win, EINA_TRUE);
+ evas_object_render_op_set(win, EVAS_RENDER_COPY);
+ }
+ else {
+ win = elm_win_util_standard_add("", "");
+ elm_win_autodel_set(win, EINA_TRUE);
+ }
+
+ window_map_[web_contents] = win;
+ return win;
+}
+
NativeWindowEfl::NativeWindowEfl(
brightray::InspectableWebContents* inspectable_web_contents,
const mate::Dictionary& options,
#define ATOM_BROWSER_NATIVE_WINDOW_EFL_H_
#include "atom/browser/native_window.h"
+#include "content/public/browser/web_contents_delegate.h"
#include <Evas.h>
const mate::Dictionary& options,
NativeWindow* parent);
+ static Evas_Object* GetHostWindowDelegate(const content::WebContents*);
+
void Close() override;
void CloseImmediately() override;
void Focus(bool focus) override;
}],
],
}, # capi-media-player
+ {
+ 'target_name': 'capi-appfw-watch-application',
+ 'type': 'none',
+ 'conditions': [
+ ['is_tizen==1', {
+ 'direct_dependent_settings': {
+ 'cflags': [
+ '<!@(<(pkg-config) --cflags capi-appfw-watch-application)',
+ ],
+ },
+ 'link_settings': {
+ 'ldflags': [
+ '<!@(<(pkg-config) --libs-only-L --libs-only-other capi-appfw-watch-application)',
+ ],
+ 'libraries': [
+ '<!@(<(pkg-config) --libs-only-l capi-appfw-watch-application)',
+ ],
+ },
+ }],
+ ],
+ }, # capi-appfw-watch-application
+ {
+ 'target_name': 'appcore-watch',
+ 'type': 'none',
+ 'conditions': [
+ ['is_tizen==1', {
+ 'direct_dependent_settings': {
+ 'cflags': [
+ '<!@(<(pkg-config) --cflags appcore-watch)',
+ ],
+ },
+ 'link_settings': {
+ 'ldflags': [
+ '<!@(<(pkg-config) --libs-only-L --libs-only-other appcore-watch)',
+ ],
+ 'libraries': [
+ '<!@(<(pkg-config) --libs-only-l appcore-watch)',
+ ],
+ },
+ }],
+ ],
+ }, # appcore-watch
],
}
%ifarch aarch64
BuildRequires: python-accel-aarch64-cross-aarch64
%endif
+BuildRequires: pkgconfig(appcore-watch)
BuildRequires: pkgconfig(appsvc)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(capi-appfw-package-manager)
+BuildRequires: pkgconfig(capi-appfw-watch-application)
BuildRequires: pkgconfig(capi-system-system-settings)
BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(chromium-efl)
'atom/app/runtime.h',
'atom/app/ui_runtime.cc',
'atom/app/ui_runtime.h',
+ 'atom/app/watch_runtime.cc',
+ 'atom/app/watch_runtime.h',
'atom/browser/api/atom_api_menu_efl.cc',
'atom/browser/api/atom_api_menu_efl.h',
'atom/browser/api/atom_api_web_contents_efl.cc',
'cflags': [ '-fPIC' ],
'cflags_cc': [ '-fPIC' ],
'dependencies': [
+ '<(DEPTH)/efl/build/system.gyp:appcore-watch',
'<(DEPTH)/efl/build/system.gyp:capi-appfw-application',
+ '<(DEPTH)/efl/build/system.gyp:capi-appfw-watch-application',
'<(DEPTH)/efl/build/system.gyp:efl-extension',
'<(DEPTH)/efl/build/system.gyp:elementary',
'<(DEPTH)/efl/build/system.gyp:evas',