2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 auto_rotation_support.cpp
18 * @author Jihoon Chung (jihoon.chung@samsung.com)
20 * @brief source file to support auto rotation of web application
23 #include "auto_rotation_support.h"
25 #include <Elementary.h>
27 #include <dpl/log/log.h>
28 #include <widget_data_types.h>
31 const char* const WM_ROTATION_CHANGED_CALLBACK = "wm,rotation,changed";
34 void AutoRotationSupport::setOrientation(Evas_Object* window, Evas_Object* ewkView, SplashScreenSupport* splashScreen)
36 LogDebug("setOrientation");
37 int winAngle = elm_win_rotation_get(window);
39 if (splashScreen && splashScreen->isShowing())
41 splashScreen->resizeSplashScreen();
44 if (winAngle == OrientationAngle::Window::Portrait::PRIMARY) {
45 ewk_view_orientation_send(
47 OrientationAngle::W3C::Portrait::PRIMARY);
48 } else if (winAngle == OrientationAngle::Window::Portrait::SECONDARY) {
49 ewk_view_orientation_send(
51 OrientationAngle::W3C::Portrait::SECONDARY);
52 } else if (winAngle == OrientationAngle::Window::Landscape::PRIMARY) {
53 ewk_view_orientation_send(
55 OrientationAngle::W3C::Landscape::PRIMARY);
56 } else if (winAngle == OrientationAngle::Window::Landscape::SECONDARY) {
57 ewk_view_orientation_send(
59 OrientationAngle::W3C::Landscape::SECONDARY);
61 LogDebug("unknown angle is returned");
65 bool AutoRotationSupport::setAutoRotation(Evas_Object* window, Evas_Smart_Cb callback, const void *data)
69 if (elm_win_wm_rotation_supported_get(window)) {
70 const int rots[4] = {OrientationAngle::Window::Portrait::PRIMARY,
71 OrientationAngle::Window::Portrait::SECONDARY,
72 OrientationAngle::Window::Landscape::PRIMARY,
73 OrientationAngle::Window::Landscape::SECONDARY};
74 elm_win_wm_rotation_available_rotations_set(window, rots, 4);
75 evas_object_smart_callback_add(window,
76 WM_ROTATION_CHANGED_CALLBACK,
84 void AutoRotationSupport::unsetAutoRotation(Evas_Object* window, Evas_Smart_Cb callback)
87 evas_object_smart_callback_del(window,
88 WM_ROTATION_CHANGED_CALLBACK,