1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #if !defined(EWK_BRINGUP) // FIXME: m67 bringup
9 // FIXME: appfw/app_service.h is no more in Tizen 2.3, figure out what to
11 #include <appcore-agent/service_app.h>
20 #include "base/callback.h"
21 #include "base/containers/id_map.h"
22 #include "base/synchronization/waitable_event.h"
23 #include "browser/input_picker/input_picker.h"
24 #include "browser/selectpicker/popup_picker.h"
25 #include "content/browser/date_time_chooser_efl.h"
26 #include "content/browser/renderer_host/event_with_latency_info.h"
27 #include "content/browser/selection/selection_controller_efl.h"
28 #include "content/public/browser/context_menu_params.h"
29 #include "content/public/browser/navigation_controller.h"
30 #include "content/public/browser/quota_permission_context.h"
31 #include "content/public/browser/web_contents_delegate.h"
32 #include "content/public/browser/web_contents_efl_delegate.h"
33 #include "content/public/common/input_event_ack_state.h"
34 #include "content_browser_client_efl.h"
35 #include "context_menu_controller_efl.h"
36 #include "eweb_context.h"
37 #include "eweb_view_callbacks.h"
38 #include "file_chooser_controller_efl.h"
39 #include "permission_popup_manager.h"
40 #include "popup_controller_efl.h"
41 #include "private/ewk_auth_challenge_private.h"
42 #include "private/ewk_back_forward_list_private.h"
43 #include "private/ewk_history_private.h"
44 #include "private/ewk_hit_test_private.h"
45 #include "private/ewk_settings_private.h"
46 #include "private/ewk_web_application_icon_data_private.h"
47 #include "public/ewk_hit_test_internal.h"
48 #include "public/ewk_touch_internal.h"
49 #include "public/ewk_view_product.h"
50 #include "scroll_detector.h"
51 #include "third_party/blink/public/common/context_menu_data/menu_item_info.h"
52 #include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
53 #include "ui/aura/window_tree_host.h"
54 #include "ui/gfx/geometry/point.h"
55 #include "ui/gfx/geometry/size.h"
56 #include "web_contents_delegate_efl.h"
61 class WindowParentingClient;
66 class RenderFrameHost;
68 class RenderWidgetHostViewAura;
69 class WebContentsDelegateEfl;
70 class WebContentsViewAura;
71 class ContextMenuControllerEfl;
72 class PopupControllerEfl;
74 class GinNativeBridgeDispatcherHost;
78 class _Ewk_Policy_Decision;
81 class WebViewEvasEventHandler;
82 class _Ewk_Quota_Permission_Request;
84 template <typename CallbackPtr, typename CallbackParameter>
85 class WebViewCallback {
87 WebViewCallback() { Set(nullptr, nullptr); }
89 void Set(CallbackPtr cb, void* data) {
94 bool IsCallbackSet() const { return callback_; }
96 Eina_Bool Run(Evas_Object* webview,
97 CallbackParameter param,
98 Eina_Bool* callback_result) {
99 CHECK(callback_result);
100 if (IsCallbackSet()) {
101 *callback_result = callback_(webview, param, user_data_);
107 void Run(Evas_Object* webview, CallbackParameter param) {
109 callback_(webview, param, user_data_);
113 CallbackPtr callback_;
117 class WebApplicationIconUrlGetCallback {
119 WebApplicationIconUrlGetCallback(Ewk_Web_App_Icon_URL_Get_Callback func,
121 : func_(func), user_data_(user_data) {}
122 void Run(const std::string& url) {
124 (func_)(url.c_str(), user_data_);
129 Ewk_Web_App_Icon_URL_Get_Callback func_;
133 class WebApplicationIconUrlsGetCallback {
135 WebApplicationIconUrlsGetCallback(Ewk_Web_App_Icon_URLs_Get_Callback func,
137 : func_(func), user_data_(user_data) {}
138 void Run(const std::map<std::string, std::string>& urls) {
140 Eina_List* list = NULL;
141 for (std::map<std::string, std::string>::const_iterator it = urls.begin();
142 it != urls.end(); ++it) {
143 _Ewk_Web_App_Icon_Data* data =
144 ewkWebAppIconDataCreate(it->first, it->second);
145 list = eina_list_append(list, data);
147 (func_)(list, user_data_);
152 Ewk_Web_App_Icon_URLs_Get_Callback func_;
156 class WebApplicationCapableGetCallback {
158 WebApplicationCapableGetCallback(Ewk_Web_App_Capable_Get_Callback func,
160 : func_(func), user_data_(user_data) {}
161 void Run(bool capable) {
163 (func_)(capable ? EINA_TRUE : EINA_FALSE, user_data_);
168 Ewk_Web_App_Capable_Get_Callback func_;
172 class WebViewAsyncRequestHitTestDataCallback;
173 class JavaScriptDialogManagerEfl;
174 class PermissionPopupManager;
178 static EWebView* FromEvasObject(Evas_Object* eo);
180 EWebView(Ewk_Context*, Evas_Object* smart_object);
183 // initialize data members and activate event handlers.
184 // call this once after created and before use
187 bool CreateNewWindow(
188 content::WebContentsEflDelegate::WebContentsCreateCallback);
189 static Evas_Object* GetHostWindowDelegate(const content::WebContents*);
191 content::WebContentsViewAura* wcva() const;
192 content::RenderWidgetHostViewAura* rwhva() const;
193 Ewk_Context* context() const { return context_.get(); }
194 Evas_Object* evas_object() const { return evas_object_; }
195 Evas_Object* native_view() const { return native_view_; }
196 Evas_Object* GetElmWindow() const;
197 Evas* GetEvas() const { return evas_object_evas_get(evas_object_); }
198 PermissionPopupManager* GetPermissionPopupManager() const {
199 return permission_popup_manager_.get();
202 content::WebContents& web_contents() const { return *web_contents_.get(); }
204 template <EWebViewCallbacks::CallbackType callbackType>
205 EWebViewCallbacks::CallBack<callbackType> SmartCallback() const {
206 return EWebViewCallbacks::CallBack<callbackType>(evas_object_);
209 void set_magnifier(bool status);
212 void SetURL(const GURL& url);
213 const GURL& GetURL() const;
214 const GURL& GetOriginalURL() const;
216 void ReloadBypassingCache();
217 Eina_Bool CanGoBack();
218 Eina_Bool CanGoForward();
219 Eina_Bool HasFocus() const;
220 void SetFocus(Eina_Bool focus);
222 Eina_Bool GoForward();
226 double GetTextZoomFactor() const;
227 void SetTextZoomFactor(double text_zoom_factor);
228 double GetPageZoomFactor() const;
229 void SetPageZoomFactor(double page_zoom_factor);
230 void ExecuteEditCommand(const char* command, const char* value);
231 void SetOrientation(int orientation);
232 int GetOrientation();
233 bool TouchEventsEnabled() const;
234 void SetTouchEventsEnabled(bool enabled);
235 bool MouseEventsEnabled() const;
236 void SetMouseEventsEnabled(bool enabled);
237 void HandleTouchEvents(Ewk_Touch_Event_Type type,
238 const Eina_List* points,
239 const Evas_Modifier* modifiers);
242 bool ExecuteJavaScript(const char* script,
243 Ewk_View_Script_Execute_Callback callback,
245 bool SetUserAgent(const char* userAgent);
246 bool SetUserAgentAppName(const char* application_name);
247 bool SetPrivateBrowsing(bool incognito);
248 bool GetPrivateBrowsing() const;
249 const char* GetUserAgent() const;
250 const char* GetUserAgentAppName() const;
251 const char* CacheSelectedText();
252 Ewk_Settings* GetSettings() { return settings_.get(); }
253 _Ewk_Frame* GetMainFrame();
254 void UpdateWebKitPreferences();
255 void LoadHTMLString(const char* html,
256 const char* base_uri,
257 const char* unreachable_uri);
258 void LoadPlainTextString(const char* plain_text);
259 void LoadData(const char* data,
261 const char* mime_type,
262 const char* encoding,
263 const char* base_uri,
264 const char* unreachable_uri = NULL);
266 void InvokeLoadError(const GURL& url, int error_code, bool is_cancellation);
268 void SetViewAuthCallback(Ewk_View_Authentication_Callback callback,
270 void InvokeAuthCallback(LoginDelegateEfl* login_delegate,
272 const std::string& realm);
273 void Find(const char* text, Ewk_Find_Options);
274 void InvokeAuthCallbackOnUI(_Ewk_Auth_Challenge* auth_challenge);
275 void SetContentSecurityPolicy(const char* policy, Ewk_CSP_Header_Type type);
276 void ShowPopupMenu(const std::vector<blink::MenuItemInfo>& items,
279 Eina_Bool HidePopupMenu();
280 void UpdateFormNavigation(int formElementCount,
281 int currentNodeIndex,
284 void FormNavigate(bool direction);
285 bool IsSelectPickerShown() const;
286 void CloseSelectPicker();
287 bool FormIsNavigating() const { return formIsNavigating_; }
288 void SetFormIsNavigating(bool formIsNavigating);
289 Eina_Bool PopupMenuUpdate(Eina_List* items, int selectedIndex);
290 Eina_Bool DidSelectPopupMenuItem(int selectedIndex);
291 Eina_Bool DidMultipleSelectPopupMenuItem(std::vector<int>& selectedIndices);
292 Eina_Bool PopupMenuClose();
293 void HandleLongPressGesture(const content::ContextMenuParams&);
294 void ShowContextMenu(const content::ContextMenuParams&);
295 void CancelContextMenu(int request_id);
296 void SetScale(double scale_factor);
297 bool GetScrollPosition(int* x, int* y) const;
298 void SetScroll(int x, int y);
299 void UrlRequestSet(const char* url,
300 content::NavigationController::LoadURLType loadtype,
304 content::SelectionControllerEfl* GetSelectionController() const;
305 content::PopupControllerEfl* GetPopupController() const {
306 return popup_controller_.get();
308 ScrollDetector* GetScrollDetector() const { return scroll_detector_.get(); }
309 void MoveCaret(const gfx::Point& point);
310 void QuerySelectionStyle();
311 void OnQuerySelectionStyleReply(const SelectionStylePrams& params);
312 void SelectLinkText(const gfx::Point& touch_point);
313 bool GetSelectionRange(Eina_Rectangle* left_rect, Eina_Rectangle* right_rect);
314 Eina_Bool ClearSelection();
316 // Callback OnCopyFromBackingStore will be called once we get the snapshot
318 void OnCopyFromBackingStore(bool success, const SkBitmap& bitmap);
320 void RenderViewCreated(content::RenderViewHost* render_view_host);
323 * Creates a snapshot of given rectangle from EWebView
325 * @param rect rectangle of EWebView which will be taken into snapshot
326 * @param scale_factor scale factor
327 * @return created snapshot or NULL if error occured.
328 * @note ownership of snapshot is passed to caller
330 Evas_Object* GetSnapshot(Eina_Rectangle rect, float scale_factor);
332 bool GetSnapshotAsync(Eina_Rectangle rect,
333 Ewk_Web_App_Screenshot_Captured_Callback callback,
336 void InvokePolicyResponseCallback(_Ewk_Policy_Decision* policy_decision,
338 void InvokePolicyNavigationCallback(const NavigationPolicyParams& params,
340 void UseSettingsFont();
342 _Ewk_Hit_Test* RequestHitTestDataAt(int x, int y, Ewk_Hit_Test_Mode mode);
343 Eina_Bool AsyncRequestHitTestDataAt(int x,
345 Ewk_Hit_Test_Mode mode,
346 Ewk_View_Hit_Test_Request_Callback,
348 _Ewk_Hit_Test* RequestHitTestDataAtBlinkCoords(int x,
350 Ewk_Hit_Test_Mode mode);
351 Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
354 Ewk_Hit_Test_Mode mode,
355 Ewk_View_Hit_Test_Request_Callback,
357 void DispatchAsyncHitTestData(const Hit_Test_Params& params,
359 void UpdateHitTestData(const Hit_Test_Params& params);
361 int current_find_request_id() const { return current_find_request_id_; }
362 bool PlainTextGet(Ewk_View_Plain_Text_Get_Callback callback, void* user_data);
363 void InvokePlainTextGetCallback(const std::string& content_text,
364 int plain_text_get_callback_id);
365 int SetEwkViewPlainTextGetCallback(Ewk_View_Plain_Text_Get_Callback callback,
367 void SetViewGeolocationPermissionCallback(
368 Ewk_View_Geolocation_Permission_Callback callback,
370 bool InvokeViewGeolocationPermissionCallback(
371 _Ewk_Geolocation_Permission_Request*
372 geolocation_permission_request_context,
374 void SetViewUserMediaPermissionCallback(
375 Ewk_View_User_Media_Permission_Callback callback,
377 bool InvokeViewUserMediaPermissionCallback(
378 _Ewk_User_Media_Permission_Request* user_media_permission_request_context,
380 void SetViewUnfocusAllowCallback(Ewk_View_Unfocus_Allow_Callback callback,
382 bool InvokeViewUnfocusAllowCallback(Ewk_Unfocus_Direction direction,
384 void DidChangeContentsSize(int width, int height);
385 const Eina_Rectangle GetContentsSize() const;
386 void GetScrollSize(int* w, int* h);
388 void SetProgressValue(double progress);
389 double GetProgressValue();
390 const char* GetTitle();
391 bool SaveAsPdf(int width, int height, const std::string& file_name);
392 void BackForwardListClear();
393 _Ewk_Back_Forward_List* GetBackForwardList() const;
394 void InvokeBackForwardListChangedCallback();
395 _Ewk_History* GetBackForwardHistory() const;
396 bool WebAppCapableGet(Ewk_Web_App_Capable_Get_Callback callback,
398 bool WebAppIconUrlGet(Ewk_Web_App_Icon_URL_Get_Callback callback,
400 bool WebAppIconUrlsGet(Ewk_Web_App_Icon_URLs_Get_Callback callback,
402 void InvokeWebAppCapableGetCallback(bool capable, int callbackId);
403 void InvokeWebAppIconUrlGetCallback(const std::string& iconUrl,
405 void InvokeWebAppIconUrlsGetCallback(
406 const std::map<std::string, std::string>& iconUrls,
408 void SetNotificationPermissionCallback(
409 Ewk_View_Notification_Permission_Callback callback,
411 bool IsNotificationPermissionCallbackSet() const;
412 bool InvokeNotificationPermissionCallback(
413 Ewk_Notification_Permission_Request* request);
415 bool GetMHTMLData(Ewk_View_MHTML_Data_Get_Callback callback, void* user_data);
416 void OnMHTMLContentGet(const std::string& mhtml_content, int callback_id);
418 void ExitFullscreen();
420 void DidChangePageScaleFactor(double scale_factor);
421 void SetScaledContentsSize();
422 void SetJavaScriptAlertCallback(Ewk_View_JavaScript_Alert_Callback callback,
424 void JavaScriptAlertReply();
425 void SetJavaScriptConfirmCallback(
426 Ewk_View_JavaScript_Confirm_Callback callback,
428 void JavaScriptConfirmReply(bool result);
429 void SetJavaScriptPromptCallback(Ewk_View_JavaScript_Prompt_Callback callback,
431 void JavaScriptPromptReply(const char* result);
432 void set_renderer_crashed();
433 void GetPageScaleRange(double* min_scale, double* max_scale);
434 void SetDrawsTransparentBackground(bool enabled);
435 void GetSessionData(const char** data, unsigned* length) const;
436 bool RestoreFromSessionData(const char* data, unsigned length);
437 void ShowFileChooser(content::RenderFrameHost* render_frame_host,
438 const blink::mojom::FileChooserParams&);
439 void SetBrowserFont();
440 void SetCertificatePem(const std::string& certificate);
441 bool IsDragging() const;
443 void RequestColorPicker(int r, int g, int b, int a);
444 bool SetColorPickerColor(int r, int g, int b, int a);
445 void InputPickerShow(ui::TextInputType input_type,
447 content::DateTimeChooserEfl* date_time_chooser);
449 void ShowContentsDetectedPopup(const char*);
451 // Returns TCP port number with Inspector, or 0 if error.
452 int StartInspectorServer(int port = 0);
453 bool StopInspectorServer();
455 void LoadNotFoundErrorPage(const std::string& invalidUrl);
456 static std::string GetPlatformLocale();
457 bool GetLinkMagnifierEnabled() const;
458 void SetLinkMagnifierEnabled(bool enabled);
460 void SetOverrideEncoding(const std::string& encoding);
461 void SetQuotaPermissionRequestCallback(
462 Ewk_Quota_Permission_Request_Callback callback,
464 void InvokeQuotaPermissionRequest(
465 _Ewk_Quota_Permission_Request* request,
466 content::QuotaPermissionContext::PermissionCallback cb);
467 void QuotaRequestReply(const _Ewk_Quota_Permission_Request* request,
469 void QuotaRequestCancel(const _Ewk_Quota_Permission_Request* request);
470 #if !defined(EWK_BRINGUP) // FIXME: m67 bringup
471 void SetViewMode(blink::WebViewMode view_mode);
473 gfx::Point GetContextMenuPosition() const;
475 content::ContextMenuControllerEfl* GetContextMenuController() {
476 return context_menu_.get();
478 void ResetContextMenuController();
479 Eina_Bool AddJavaScriptMessageHandler(Evas_Object* view,
480 Ewk_View_Script_Message_Cb callback,
483 content::GinNativeBridgeDispatcherHost* GetGinNativeBridgeDispatcherHost()
485 return gin_native_bridge_dispatcher_host_.get();
488 /// ---- Event handling
491 bool HandleMove(int x, int y);
492 bool HandleResize(int width, int height);
493 bool HandleTextSelectionDown(int x, int y);
494 bool HandleTextSelectionUp(int x, int y);
496 void HandleRendererProcessCrash();
497 void InvokeWebProcessCrashedCallback();
499 void HandleTapGestureForSelection(bool is_content_editable);
500 void HandleZoomGesture(blink::WebGestureEvent& event);
503 void RequestManifest(Ewk_View_Request_Manifest_Callback callback,
505 void DidRespondRequestManifest(_Ewk_View_Request_Manifest* manifest,
506 Ewk_View_Request_Manifest_Callback callback,
509 void SyncAcceptLanguages(const std::string& accept_languages);
511 void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
512 const gfx::Vector2dF& latest_overscroll_delta);
514 content::DateTimeChooserEfl* GetDateTimeChooser() {
515 return date_time_chooser_;
519 void InitializeContent();
520 void InitializeWindowTreeHost();
521 void SendDelayedMessages(content::RenderViewHost* render_view_host);
523 void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
524 Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
527 Ewk_Hit_Test_Mode mode,
528 WebViewAsyncRequestHitTestDataCallback* cb);
529 #if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
530 static void cameraResultCb(service_h request,
532 service_result_e result,
536 #if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
537 bool LaunchCamera(std::u16string mimetype);
539 #if !defined(USE_AURA)
540 content::RenderWidgetHostViewEfl* rwhv() const;
542 JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl();
544 void ReleasePopupMenuList();
546 void ShowContextMenuInternal(const content::ContextMenuParams&);
548 void UpdateWebkitPreferencesEfl(content::RenderViewHost*);
550 void ChangeScroll(int& x, int& y);
552 scoped_refptr<WebViewEvasEventHandler> evas_event_handler_;
553 scoped_refptr<Ewk_Context> context_;
554 scoped_refptr<Ewk_Context> old_context_;
555 std::unique_ptr<content::WebContents> web_contents_;
556 std::unique_ptr<content::WebContentsDelegateEfl> web_contents_delegate_;
557 std::string pending_url_request_;
558 std::unique_ptr<Ewk_Settings> settings_;
559 std::unique_ptr<_Ewk_Frame> frame_;
560 std::unique_ptr<_Ewk_Policy_Decision> window_policy_;
561 Evas_Object* evas_object_;
562 Evas_Object* native_view_;
563 bool touch_events_enabled_;
564 bool mouse_events_enabled_;
565 double text_zoom_factor_;
566 mutable std::string user_agent_;
567 mutable std::string user_agent_app_name_;
568 std::unique_ptr<_Ewk_Auth_Challenge> auth_challenge_;
569 std::string selected_text_cached_;
571 Eina_List* popupMenuItems_;
572 Popup_Picker* popupPicker_;
573 bool formIsNavigating_;
580 formNavigation formNavigation_;
581 std::unique_ptr<content::ContextMenuControllerEfl> context_menu_;
582 #if !defined(EWK_BRINGUP) // FIXME: m71 bringup
583 std::unique_ptr<content::FileChooserControllerEfl> file_chooser_;
585 std::unique_ptr<content::PopupControllerEfl> popup_controller_;
586 std::u16string previous_text_;
587 int current_find_request_id_;
588 static int find_request_id_counter_;
590 typedef WebViewCallback<Ewk_View_Plain_Text_Get_Callback, const char*>
591 EwkViewPlainTextGetCallback;
592 base::IDMap<EwkViewPlainTextGetCallback*> plain_text_get_callback_map_;
594 typedef WebViewCallback<Ewk_View_MHTML_Data_Get_Callback, const char*>
595 MHTMLCallbackDetails;
596 base::IDMap<MHTMLCallbackDetails*> mhtml_callback_map_;
598 gfx::Size contents_size_;
600 mutable std::string title_;
601 mutable std::string pem_certificate_;
602 Hit_Test_Params hit_test_params_;
603 base::WaitableEvent hit_test_completion_;
604 double page_scale_factor_;
608 WebViewCallback<Ewk_View_Geolocation_Permission_Callback,
609 _Ewk_Geolocation_Permission_Request*>
610 geolocation_permission_cb_;
611 WebViewCallback<Ewk_View_User_Media_Permission_Callback,
612 _Ewk_User_Media_Permission_Request*>
613 user_media_permission_cb_;
614 WebViewCallback<Ewk_View_Unfocus_Allow_Callback, Ewk_Unfocus_Direction>
616 WebViewCallback<Ewk_View_Notification_Permission_Callback,
617 Ewk_Notification_Permission_Request*>
618 notification_permission_callback_;
619 WebViewCallback<Ewk_Quota_Permission_Request_Callback,
620 const _Ewk_Quota_Permission_Request*>
621 quota_request_callback_;
622 WebViewCallback<Ewk_View_Authentication_Callback, _Ewk_Auth_Challenge*>
625 std::unique_ptr<content::InputPicker> input_picker_;
626 base::IDMap<WebApplicationIconUrlGetCallback*>
627 web_app_icon_url_get_callback_map_;
628 base::IDMap<WebApplicationIconUrlsGetCallback*>
629 web_app_icon_urls_get_callback_map_;
630 base::IDMap<WebApplicationCapableGetCallback*>
631 web_app_capable_get_callback_map_;
632 std::unique_ptr<PermissionPopupManager> permission_popup_manager_;
633 std::unique_ptr<ScrollDetector> scroll_detector_;
635 // Manages injecting native objects.
636 std::unique_ptr<content::GinNativeBridgeDispatcherHost>
637 gin_native_bridge_dispatcher_host_;
639 #if BUILDFLAG(IS_TIZEN)
640 blink::mojom::FileChooserParams::Mode filechooser_mode_;
642 std::map<const _Ewk_Quota_Permission_Request*,
643 content::QuotaPermissionContext::PermissionCallback>
644 quota_permission_request_map_;
646 bool is_initialized_;
648 std::unique_ptr<_Ewk_Back_Forward_List> back_forward_list_;
650 static content::WebContentsEflDelegate::WebContentsCreateCallback
651 create_new_window_web_contents_cb_;
654 gfx::Vector2d previous_scroll_position_;
656 gfx::Point context_menu_position_;
658 std::vector<IPC::Message*> delayed_messages_;
660 std::map<int64_t, WebViewAsyncRequestHitTestDataCallback*> hit_test_callback_;
662 content::ContentBrowserClientEfl::AcceptLangsChangedCallback
663 accept_langs_changed_callback_;
665 std::unique_ptr<aura::WindowTreeHost> host_;
666 std::unique_ptr<aura::client::FocusClient> focus_client_;
667 std::unique_ptr<aura::client::WindowParentingClient> window_parenting_client_;
668 content::DateTimeChooserEfl* date_time_chooser_ = nullptr;
671 const unsigned int g_default_tilt_motion_sensitivity = 3;