2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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.
18 // Ecore is littered with C style cast
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wold-style-cast"
23 #include <dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h>
26 #include <dali/internal/input/common/key-impl.h>
27 #include <dali/internal/window-system/common/window-impl.h>
28 #include <dali/internal/window-system/common/window-render-surface.h>
29 #include <dali/internal/window-system/common/window-system.h>
32 #include <Ecore_Input.h>
33 #include <dali/integration-api/debug.h>
34 #include <dali/public-api/object/any.h>
35 #include <vconf-keys.h>
46 #if defined(DEBUG_ENABLED)
47 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
50 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
51 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
53 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
56 const char* BUS = "org.enlightenment.wm-screen-reader";
57 const char* INTERFACE = "org.tizen.GestureNavigation";
58 const char* PATH = "/org/tizen/GestureNavigation";
61 * Get the device name from the provided ecore key event
63 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
65 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
69 result = ecoreDeviceName;
74 * Get the device class from the provided ecore event
76 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
78 switch(ecoreDeviceClass)
80 case ECORE_DEVICE_CLASS_SEAT:
82 deviceClass = Device::Class::USER;
85 case ECORE_DEVICE_CLASS_KEYBOARD:
87 deviceClass = Device::Class::KEYBOARD;
90 case ECORE_DEVICE_CLASS_MOUSE:
92 deviceClass = Device::Class::MOUSE;
95 case ECORE_DEVICE_CLASS_TOUCH:
97 deviceClass = Device::Class::TOUCH;
100 case ECORE_DEVICE_CLASS_PEN:
102 deviceClass = Device::Class::PEN;
105 case ECORE_DEVICE_CLASS_POINTER:
107 deviceClass = Device::Class::POINTER;
110 case ECORE_DEVICE_CLASS_GAMEPAD:
112 deviceClass = Device::Class::GAMEPAD;
117 deviceClass = Device::Class::NONE;
123 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
125 switch(ecoreDeviceSubclass)
127 case ECORE_DEVICE_SUBCLASS_FINGER:
129 deviceSubclass = Device::Subclass::FINGER;
132 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
134 deviceSubclass = Device::Subclass::FINGERNAIL;
137 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
139 deviceSubclass = Device::Subclass::KNUCKLE;
142 case ECORE_DEVICE_SUBCLASS_PALM:
144 deviceSubclass = Device::Subclass::PALM;
147 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
149 deviceSubclass = Device::Subclass::HAND_SIDE;
152 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
154 deviceSubclass = Device::Subclass::HAND_FLAT;
157 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
159 deviceSubclass = Device::Subclass::PEN_TIP;
162 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
164 deviceSubclass = Device::Subclass::TRACKPAD;
167 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
169 deviceSubclass = Device::Subclass::TRACKPOINT;
172 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
174 deviceSubclass = Device::Subclass::TRACKBALL;
177 case ECORE_DEVICE_SUBCLASS_REMOCON:
179 deviceSubclass = Device::Subclass::REMOCON;
182 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
184 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
189 deviceSubclass = Device::Subclass::NONE;
195 /////////////////////////////////////////////////////////////////////////////////////////////////
197 /////////////////////////////////////////////////////////////////////////////////////////////////
199 /// Called when the window iconify state is changed.
200 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
202 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
205 return windowBase->OnIconifyStateChanged(data, type, event);
208 return ECORE_CALLBACK_PASS_ON;
211 /// Called when the window gains focus
212 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
214 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
217 return windowBase->OnFocusIn(data, type, event);
220 return ECORE_CALLBACK_PASS_ON;
223 /// Called when the window loses focus
224 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
226 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
229 return windowBase->OnFocusOut(data, type, event);
232 return ECORE_CALLBACK_PASS_ON;
235 /// Called when the output is transformed
236 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
238 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
241 return windowBase->OnOutputTransform(data, type, event);
244 return ECORE_CALLBACK_PASS_ON;
247 /// Called when the output transform should be ignored
248 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
250 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
253 return windowBase->OnIgnoreOutputTransform(data, type, event);
256 return ECORE_CALLBACK_PASS_ON;
260 * Called when rotate event is recevied.
262 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
264 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
267 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::EcoreEventRotate\n");
268 windowBase->OnRotation(data, type, event);
270 return ECORE_CALLBACK_PASS_ON;
273 /////////////////////////////////////////////////////////////////////////////////////////////////
275 /////////////////////////////////////////////////////////////////////////////////////////////////
278 * Called when a touch down is received.
280 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
282 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
285 windowBase->OnMouseButtonDown(data, type, event);
287 return ECORE_CALLBACK_PASS_ON;
291 * Called when a touch up is received.
293 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
295 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
298 windowBase->OnMouseButtonUp(data, type, event);
300 return ECORE_CALLBACK_PASS_ON;
304 * Called when a touch motion is received.
306 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
308 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
311 windowBase->OnMouseButtonMove(data, type, event);
313 return ECORE_CALLBACK_PASS_ON;
317 * Called when a touch is canceled.
319 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
321 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
324 windowBase->OnMouseButtonCancel(data, type, event);
326 return ECORE_CALLBACK_PASS_ON;
330 * Called when a mouse wheel is received.
332 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
334 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
337 windowBase->OnMouseWheel(data, type, event);
339 return ECORE_CALLBACK_PASS_ON;
343 * Called when a detent rotation event is recevied.
345 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
347 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
350 windowBase->OnDetentRotation(data, type, event);
352 return ECORE_CALLBACK_PASS_ON;
355 /////////////////////////////////////////////////////////////////////////////////////////////////
357 /////////////////////////////////////////////////////////////////////////////////////////////////
360 * Called when a key down is received.
362 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
364 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
367 windowBase->OnKeyDown(data, type, event);
369 return ECORE_CALLBACK_PASS_ON;
373 * Called when a key up is received.
375 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
377 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
380 windowBase->OnKeyUp(data, type, event);
382 return ECORE_CALLBACK_PASS_ON;
385 /////////////////////////////////////////////////////////////////////////////////////////////////
386 // Selection Callbacks
387 /////////////////////////////////////////////////////////////////////////////////////////////////
390 * Called when the source window notifies us the content in clipboard is selected.
392 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
394 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
397 windowBase->OnDataSend(data, type, event);
399 return ECORE_CALLBACK_PASS_ON;
403 * Called when the source window sends us about the selected content.
404 * For example, when item is selected in the clipboard.
406 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
408 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
411 windowBase->OnDataReceive(data, type, event);
413 return ECORE_CALLBACK_PASS_ON;
416 /////////////////////////////////////////////////////////////////////////////////////////////////
418 /////////////////////////////////////////////////////////////////////////////////////////////////
421 * Called when a font name is changed.
423 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
425 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
428 windowBase->OnFontNameChanged();
433 * Called when a font size is changed.
435 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
437 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
440 windowBase->OnFontSizeChanged();
444 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
446 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
449 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
453 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
455 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
458 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
462 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
466 static void TizenPolicyConformantArea(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
470 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
472 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
475 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
479 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
483 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
485 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
488 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
492 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
496 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
500 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
504 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
508 static void TizenPolicyConformantRegion(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial)
512 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
514 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
517 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
521 const struct wl_registry_listener registryListener =
523 RegistryGlobalCallback,
524 RegistryGlobalCallbackRemove};
526 const struct tizen_policy_listener tizenPolicyListener =
528 TizenPolicyConformant,
529 TizenPolicyConformantArea,
530 TizenPolicyNotificationChangeDone,
531 TizenPolicyTransientForDone,
532 TizenPolicyScreenModeChangeDone,
533 TizenPolicyIconifyStateChanged,
534 TizenPolicySupportedAuxiliaryHints,
535 TizenPolicyAllowedAuxiliaryHint,
536 TizenPolicyAuxiliaryMessage,
537 TizenPolicyConformantRegion};
539 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
541 DisplayPolicyBrightnessChangeDone};
543 } // unnamed namespace
545 WindowBaseEcoreWl::WindowBaseEcoreWl(Dali::PositionSize positionSize, Any surface, bool isTransparent)
546 : mEcoreEventHandler(),
547 mEcoreWindow(nullptr),
551 mEventQueue(nullptr),
552 mTizenPolicy(nullptr),
553 mTizenDisplayPolicy(nullptr),
554 mSupportedAuxiliaryHints(),
556 mNotificationLevel(-1),
557 mNotificationChangeState(0),
558 mNotificationLevelChangeDone(true),
560 mScreenOffModeChangeState(0),
561 mScreenOffModeChangeDone(true),
563 mBrightnessChangeState(0),
564 mBrightnessChangeDone(true),
566 mWindowRotationAngle(0),
567 mScreenRotationAngle(0),
568 mSupportedPreProtation(0)
570 Initialize(positionSize, surface, isTransparent);
573 WindowBaseEcoreWl::~WindowBaseEcoreWl()
575 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
576 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
578 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
580 ecore_event_handler_del(*iter);
582 mEcoreEventHandler.Clear();
586 wl_event_queue_destroy(mEventQueue);
589 mSupportedAuxiliaryHints.clear();
590 mAuxiliaryHints.clear();
592 if(mEglWindow != NULL)
594 wl_egl_window_destroy(mEglWindow);
600 ecore_wl_window_free(mEcoreWindow);
602 WindowSystem::Shutdown();
606 void WindowBaseEcoreWl::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
608 if(surface.Empty() == false)
610 // check we have a valid type
611 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl_Window*)) && "Surface type is invalid");
613 mEcoreWindow = AnyCast<Ecore_Wl_Window*>(surface);
617 // we own the surface about to created
618 WindowSystem::Initialize();
621 CreateWindow(positionSize);
624 mWlSurface = ecore_wl_window_surface_create(mEcoreWindow);
626 SetTransparency(isTransparent);
628 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
629 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
630 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
631 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
632 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
634 // Register Rotate event
635 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
637 // Register Touch events
638 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
639 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
640 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
641 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
643 // Register Mouse wheel events
644 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
646 // Register Detent event
647 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
649 // Register Key events
650 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
651 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
653 // Register Selection event - clipboard selection
654 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
655 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
657 // Register Vconf notify - font name and size
658 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
659 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
661 mDisplay = ecore_wl_display_get();
665 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
668 mEventQueue = wl_display_create_queue(mDisplay);
671 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
673 wl_registry* registry = wl_display_get_registry(displayWrapper);
674 wl_registry_add_listener(registry, ®istryListener, this);
677 wl_proxy_wrapper_destroy(displayWrapper);
681 // get auxiliary hint
682 Eina_List* hints = ecore_wl_window_aux_hints_supported_get(mEcoreWindow);
688 for(l = hints, (hint = static_cast<char*>(eina_list_data_get(l))); l; l = eina_list_next(l), (hint = static_cast<char*>(eina_list_data_get(l))))
690 mSupportedAuxiliaryHints.push_back(hint);
692 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint);
697 Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged(void* data, int type, void* event)
699 Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl_Event_Window_Iconify_State_Change*>(event));
700 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
702 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
704 if(iconifyChangedEvent->iconified == EINA_TRUE)
706 mIconifyChangedSignal.Emit(true);
710 mIconifyChangedSignal.Emit(false);
712 handled = ECORE_CALLBACK_DONE;
718 Eina_Bool WindowBaseEcoreWl::OnFocusIn(void* data, int type, void* event)
720 Ecore_Wl_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl_Event_Focus_In*>(event));
722 if(focusInEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
724 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
726 mFocusChangedSignal.Emit(true);
729 return ECORE_CALLBACK_PASS_ON;
732 Eina_Bool WindowBaseEcoreWl::OnFocusOut(void* data, int type, void* event)
734 Ecore_Wl_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl_Event_Focus_Out*>(event));
736 if(focusOutEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
738 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
740 mFocusChangedSignal.Emit(false);
743 return ECORE_CALLBACK_PASS_ON;
746 Eina_Bool WindowBaseEcoreWl::OnOutputTransform(void* data, int type, void* event)
748 Ecore_Wl_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl_Event_Output_Transform*>(event));
750 if(transformEvent->output == ecore_wl_window_output_find(mEcoreWindow))
752 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
754 mOutputTransformedSignal.Emit();
757 return ECORE_CALLBACK_PASS_ON;
760 Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform(void* data, int type, void* event)
762 Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl_Event_Ignore_Output_Transform*>(event));
764 if(ignoreTransformEvent->win == mEcoreWindow)
766 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
768 mOutputTransformedSignal.Emit();
771 return ECORE_CALLBACK_PASS_ON;
774 void WindowBaseEcoreWl::OnRotation(void* data, int type, void* event)
776 Ecore_Wl_Event_Window_Rotate* ev(static_cast<Ecore_Wl_Event_Window_Rotate*>(event));
778 if(ev->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
780 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
782 RotationEvent rotationEvent;
783 rotationEvent.angle = ev->angle;
784 rotationEvent.winResize = 0;
786 if(ev->angle == 0 || ev->angle == 180)
788 rotationEvent.width = ev->w;
789 rotationEvent.height = ev->h;
793 rotationEvent.width = ev->h;
794 rotationEvent.height = ev->w;
797 mRotationSignal.Emit(rotationEvent);
801 void WindowBaseEcoreWl::OnMouseButtonDown(void* data, int type, void* event)
803 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
805 if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
807 PointState::Type state(PointState::DOWN);
809 // Check if the buttons field is set and ensure it's the primary touch button.
810 // If this event was triggered by buttons other than the primary button (used for touch), then
811 // just send an interrupted event to Core.
812 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
814 state = PointState::INTERRUPTED;
817 Device::Class::Type deviceClass;
818 Device::Subclass::Type deviceSubclass;
820 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
821 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
823 Integration::Point point;
824 point.SetDeviceId(touchEvent->multi.device);
825 point.SetState(state);
826 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
827 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
828 point.SetPressure(touchEvent->multi.pressure);
829 point.SetAngle(Degree(touchEvent->multi.angle));
830 point.SetDeviceClass(deviceClass);
831 point.SetDeviceSubclass(deviceSubclass);
833 mTouchEventSignal.Emit(point, touchEvent->timestamp);
837 void WindowBaseEcoreWl::OnMouseButtonUp(void* data, int type, void* event)
839 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
841 if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
843 Device::Class::Type deviceClass;
844 Device::Subclass::Type deviceSubclass;
846 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
847 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
849 Integration::Point point;
850 point.SetDeviceId(touchEvent->multi.device);
851 point.SetState(PointState::UP);
852 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
853 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
854 point.SetPressure(touchEvent->multi.pressure);
855 point.SetAngle(Degree(touchEvent->multi.angle));
856 point.SetDeviceClass(deviceClass);
857 point.SetDeviceSubclass(deviceSubclass);
859 mTouchEventSignal.Emit(point, touchEvent->timestamp);
863 void WindowBaseEcoreWl::OnMouseButtonMove(void* data, int type, void* event)
865 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
867 if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
869 Device::Class::Type deviceClass;
870 Device::Subclass::Type deviceSubclass;
872 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
873 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
875 Integration::Point point;
876 point.SetDeviceId(touchEvent->multi.device);
877 point.SetState(PointState::MOTION);
878 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
879 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
880 point.SetPressure(touchEvent->multi.pressure);
881 point.SetAngle(Degree(touchEvent->multi.angle));
882 point.SetDeviceClass(deviceClass);
883 point.SetDeviceSubclass(deviceSubclass);
885 mTouchEventSignal.Emit(point, touchEvent->timestamp);
889 void WindowBaseEcoreWl::OnMouseButtonCancel(void* data, int type, void* event)
891 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
893 if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
895 Integration::Point point;
896 point.SetDeviceId(touchEvent->multi.device);
897 point.SetState(PointState::INTERRUPTED);
898 point.SetScreenPosition(Vector2(0.0f, 0.0f));
900 mTouchEventSignal.Emit(point, touchEvent->timestamp);
902 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n");
906 void WindowBaseEcoreWl::OnMouseWheel(void* data, int type, void* event)
908 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
910 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
912 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
914 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
916 mWheelEventSignal.Emit(wheelEvent);
920 void WindowBaseEcoreWl::OnDetentRotation(void* data, int type, void* event)
922 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
924 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n");
926 int direction = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
927 int timeStamp = detentEvent->timestamp;
929 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp);
931 mWheelEventSignal.Emit(wheelEvent);
934 void WindowBaseEcoreWl::OnKeyDown(void* data, int type, void* event)
936 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
938 if(keyEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
940 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n");
942 std::string keyName(keyEvent->keyname);
943 std::string logicalKey("");
944 std::string keyString("");
945 std::string compose("");
947 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
948 if(keyEvent->compose)
950 compose = keyEvent->compose;
953 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
956 logicalKey = keyEvent->key;
959 int keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
960 keyCode = (keyCode == -1) ? 0 : keyCode;
961 int modifier(keyEvent->modifiers);
962 unsigned long time = keyEvent->timestamp;
963 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
965 keyCode = atoi(keyEvent->keyname + 8);
968 // Ensure key event string is not NULL as keys like SHIFT have a null string.
971 keyString = keyEvent->string;
974 std::string deviceName;
975 Device::Class::Type deviceClass;
976 Device::Subclass::Type deviceSubclass;
978 GetDeviceName(keyEvent, deviceName);
979 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
980 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
982 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
984 mKeyEventSignal.Emit(keyEvent);
988 void WindowBaseEcoreWl::OnKeyUp(void* data, int type, void* event)
990 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
992 if(keyEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
994 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n");
996 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
997 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
998 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1000 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp: This event flag indicates the event is canceled. \n");
1003 #endif // Since ecore 1.23 version
1005 std::string keyName(keyEvent->keyname);
1006 std::string logicalKey("");
1007 std::string keyString("");
1008 std::string compose("");
1010 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1011 if(keyEvent->compose)
1013 compose = keyEvent->compose;
1016 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1019 logicalKey = keyEvent->key;
1022 int keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1023 keyCode = (keyCode == -1) ? 0 : keyCode;
1024 int modifier(keyEvent->modifiers);
1025 unsigned long time = keyEvent->timestamp;
1026 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1028 keyCode = atoi(keyEvent->keyname + 8);
1031 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1032 if(keyEvent->string)
1034 keyString = keyEvent->string;
1037 std::string deviceName;
1038 Device::Class::Type deviceClass;
1039 Device::Subclass::Type deviceSubclass;
1041 GetDeviceName(keyEvent, deviceName);
1042 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1043 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1045 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1047 mKeyEventSignal.Emit(keyEvent);
1051 void WindowBaseEcoreWl::OnDataSend(void* data, int type, void* event)
1053 mSelectionDataSendSignal.Emit(event);
1056 void WindowBaseEcoreWl::OnDataReceive(void* data, int type, void* event)
1058 mSelectionDataReceivedSignal.Emit(event);
1061 void WindowBaseEcoreWl::OnFontNameChanged()
1063 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1066 void WindowBaseEcoreWl::OnFontSizeChanged()
1068 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1071 void WindowBaseEcoreWl::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1073 if(strcmp(interface, tizen_policy_interface.name) == 0)
1075 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1077 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1080 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1084 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1086 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1088 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1090 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1091 if(!mTizenDisplayPolicy)
1093 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1097 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1099 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1103 void WindowBaseEcoreWl::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1105 mTizenPolicy = NULL;
1106 mTizenDisplayPolicy = NULL;
1109 void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1111 mNotificationLevel = level;
1112 mNotificationChangeState = state;
1113 mNotificationLevelChangeDone = true;
1115 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1118 void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1120 mScreenOffMode = mode;
1121 mScreenOffModeChangeState = state;
1122 mScreenOffModeChangeDone = true;
1124 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1127 void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1129 mBrightness = brightness;
1130 mBrightnessChangeState = state;
1131 mBrightnessChangeDone = true;
1133 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1136 Any WindowBaseEcoreWl::GetNativeWindow()
1138 return mEcoreWindow;
1141 int WindowBaseEcoreWl::GetNativeWindowId()
1143 return ecore_wl_window_id_get(mEcoreWindow);
1146 std::string WindowBaseEcoreWl::GetNativeWindowResourceId()
1148 return std::string();
1151 EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow(int width, int height)
1153 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1155 return static_cast<EGLNativeWindowType>(mEglWindow);
1158 void WindowBaseEcoreWl::DestroyEglWindow()
1160 if(mEglWindow != NULL)
1162 wl_egl_window_destroy(mEglWindow);
1167 void WindowBaseEcoreWl::SetEglWindowRotation(int angle)
1169 wl_egl_window_rotation rotation;
1175 rotation = ROTATION_0;
1180 rotation = ROTATION_270;
1185 rotation = ROTATION_180;
1190 rotation = ROTATION_90;
1195 rotation = ROTATION_0;
1200 wl_egl_window_set_rotation(mEglWindow, rotation);
1203 void WindowBaseEcoreWl::SetEglWindowBufferTransform(int angle)
1205 wl_output_transform bufferTransform;
1211 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1216 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1221 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1226 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1231 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1236 wl_egl_window_set_buffer_transform(mEglWindow, bufferTransform);
1239 void WindowBaseEcoreWl::SetEglWindowTransform(int angle)
1241 wl_output_transform windowTransform;
1247 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1252 windowTransform = WL_OUTPUT_TRANSFORM_90;
1257 windowTransform = WL_OUTPUT_TRANSFORM_180;
1262 windowTransform = WL_OUTPUT_TRANSFORM_270;
1267 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1272 wl_egl_window_set_window_transform(mEglWindow, windowTransform);
1275 void WindowBaseEcoreWl::ResizeEglWindow(PositionSize positionSize)
1277 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1280 bool WindowBaseEcoreWl::IsEglWindowRotationSupported()
1283 wl_egl_window_capability capability = static_cast<wl_egl_window_capability>(wl_egl_window_get_capabilities(mEglWindow));
1284 if(capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED)
1286 mSupportedPreProtation = true;
1289 mSupportedPreProtation = false;
1293 void WindowBaseEcoreWl::Move(PositionSize positionSize)
1295 ecore_wl_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
1298 void WindowBaseEcoreWl::Resize(PositionSize positionSize)
1300 ecore_wl_window_update_size(mEcoreWindow, positionSize.width, positionSize.height);
1303 void WindowBaseEcoreWl::MoveResize(PositionSize positionSize)
1305 ecore_wl_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
1306 ecore_wl_window_update_size(mEcoreWindow, positionSize.width, positionSize.height);
1309 void WindowBaseEcoreWl::SetClass(const std::string& name, const std::string& className)
1311 ecore_wl_window_title_set(mEcoreWindow, name.c_str());
1312 ecore_wl_window_class_name_set(mEcoreWindow, className.c_str());
1315 void WindowBaseEcoreWl::Raise()
1317 // Use ecore_wl_window_activate to prevent the window shown without rendering
1318 ecore_wl_window_activate(mEcoreWindow);
1321 void WindowBaseEcoreWl::Lower()
1323 ecore_wl_window_lower(mEcoreWindow);
1326 void WindowBaseEcoreWl::Activate()
1328 ecore_wl_window_activate(mEcoreWindow);
1331 void WindowBaseEcoreWl::Maximize(bool maximize)
1335 bool WindowBaseEcoreWl::IsMaximized() const
1340 void WindowBaseEcoreWl::SetMaximumSize(Dali::Window::WindowSize size)
1344 void WindowBaseEcoreWl::Minimize(bool minimize)
1348 bool WindowBaseEcoreWl::IsMinimized() const
1353 void WindowBaseEcoreWl::SetMimimumSize(Dali::Window::WindowSize size)
1357 void WindowBaseEcoreWl::SetAvailableAnlges(const std::vector<int>& angles)
1359 int rotations[4] = {0};
1360 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::SetAvailableAnlges, angle's count: %d\n", angles.size());
1361 for(std::size_t i = 0; i < angles.size(); ++i)
1363 rotations[i] = static_cast<int>(angles[i]);
1364 DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
1366 ecore_wl_window_rotation_available_rotations_set(mEcoreWindow, rotations, angles.size());
1369 void WindowBaseEcoreWl::SetPreferredAngle(int angle)
1371 ecore_wl_window_rotation_preferred_rotation_set(mEcoreWindow, angle);
1374 void WindowBaseEcoreWl::SetAcceptFocus(bool accept)
1376 ecore_wl_window_focus_skip_set(mEcoreWindow, !accept);
1379 void WindowBaseEcoreWl::Show()
1381 ecore_wl_window_show(mEcoreWindow);
1384 void WindowBaseEcoreWl::Hide()
1386 ecore_wl_window_hide(mEcoreWindow);
1389 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
1391 return mSupportedAuxiliaryHints.size();
1394 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint(unsigned int index) const
1396 if(index >= GetSupportedAuxiliaryHintCount())
1398 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
1401 return mSupportedAuxiliaryHints[index];
1404 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint(const std::string& hint, const std::string& value)
1406 bool supported = false;
1408 // Check if the hint is suppported
1409 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
1420 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
1424 // Check if the hint is already added
1425 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1427 if(mAuxiliaryHints[i].first == hint)
1429 // Just change the value
1430 mAuxiliaryHints[i].second = value;
1432 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
1434 return i + 1; // id is index + 1
1439 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
1441 unsigned int id = mAuxiliaryHints.size();
1443 ecore_wl_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
1445 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
1450 bool WindowBaseEcoreWl::RemoveAuxiliaryHint(unsigned int id)
1452 if(id == 0 || id > mAuxiliaryHints.size())
1454 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
1458 mAuxiliaryHints[id - 1].second = std::string();
1460 ecore_wl_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
1462 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
1467 bool WindowBaseEcoreWl::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
1469 if(id == 0 || id > mAuxiliaryHints.size())
1471 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
1475 mAuxiliaryHints[id - 1].second = value;
1477 ecore_wl_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
1479 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
1484 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue(unsigned int id) const
1486 if(id == 0 || id > mAuxiliaryHints.size())
1488 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
1489 return std::string();
1492 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
1494 return mAuxiliaryHints[id - 1].second;
1497 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId(const std::string& hint) const
1499 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1501 if(mAuxiliaryHints[i].first == hint)
1503 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
1508 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
1513 void WindowBaseEcoreWl::SetInputRegion(const Rect<int>& inputRegion)
1515 ecore_wl_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1518 void WindowBaseEcoreWl::SetType(Dali::WindowType type)
1520 Ecore_Wl_Window_Type windowType;
1524 case Dali::WindowType::NORMAL:
1526 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1529 case Dali::WindowType::NOTIFICATION:
1531 windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
1534 case Dali::WindowType::UTILITY:
1536 windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
1539 case Dali::WindowType::DIALOG:
1541 windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
1546 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1551 ecore_wl_window_type_set(mEcoreWindow, windowType);
1554 Dali::WindowType WindowBaseEcoreWl::GetType() const
1556 return Dali::WindowType::NORMAL;
1559 Dali::WindowOperationResult WindowBaseEcoreWl::SetNotificationLevel(Dali::WindowNotificationLevel level)
1561 while(!mTizenPolicy)
1563 wl_display_dispatch_queue(mDisplay, mEventQueue);
1566 int notificationLevel;
1570 case Dali::WindowNotificationLevel::NONE:
1572 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1575 case Dali::WindowNotificationLevel::BASE:
1577 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1580 case Dali::WindowNotificationLevel::MEDIUM:
1582 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1585 case Dali::WindowNotificationLevel::HIGH:
1587 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1590 case Dali::WindowNotificationLevel::TOP:
1592 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1597 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level);
1598 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1603 mNotificationLevelChangeDone = false;
1604 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1606 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), notificationLevel);
1610 while(!mNotificationLevelChangeDone && count < 3)
1613 wl_display_dispatch_queue(mDisplay, mEventQueue);
1617 if(!mNotificationLevelChangeDone)
1619 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
1620 return Dali::WindowOperationResult::UNKNOWN_ERROR;
1622 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1624 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level);
1625 return Dali::WindowOperationResult::PERMISSION_DENIED;
1628 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
1630 return Dali::WindowOperationResult::SUCCEED;
1633 Dali::WindowNotificationLevel WindowBaseEcoreWl::GetNotificationLevel() const
1635 while(!mTizenPolicy)
1637 wl_display_dispatch_queue(mDisplay, mEventQueue);
1642 while(!mNotificationLevelChangeDone && count < 3)
1645 wl_display_dispatch_queue(mDisplay, mEventQueue);
1649 if(!mNotificationLevelChangeDone)
1651 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
1652 return Dali::Window::NotificationLevel::NONE;
1655 Dali::WindowNotificationLevel level;
1657 switch(mNotificationLevel)
1659 case TIZEN_POLICY_LEVEL_NONE:
1661 level = Dali::WindowNotificationLevel::NONE;
1664 case TIZEN_POLICY_LEVEL_DEFAULT:
1666 level = Dali::WindowNotificationLevel::BASE;
1669 case TIZEN_POLICY_LEVEL_MEDIUM:
1671 level = Dali::WindowNotificationLevel::MEDIUM;
1674 case TIZEN_POLICY_LEVEL_HIGH:
1676 level = Dali::WindowNotificationLevel::HIGH;
1679 case TIZEN_POLICY_LEVEL_TOP:
1681 level = Dali::WindowNotificationLevel::TOP;
1686 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
1687 level = Dali::WindowNotificationLevel::NONE;
1692 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel);
1697 void WindowBaseEcoreWl::SetOpaqueState(bool opaque)
1699 while(!mTizenPolicy)
1701 wl_display_dispatch_queue(mDisplay, mEventQueue);
1704 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
1707 Dali::WindowOperationResult WindowBaseEcoreWl::SetScreenOffMode(WindowScreenOffMode screenOffMode)
1709 while(!mTizenPolicy)
1711 wl_display_dispatch_queue(mDisplay, mEventQueue);
1714 mScreenOffModeChangeDone = false;
1715 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1717 unsigned int mode = 0;
1719 switch(screenOffMode)
1721 case WindowScreenOffMode::TIMEOUT:
1726 case WindowScreenOffMode::NEVER:
1733 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), mode);
1737 while(!mScreenOffModeChangeDone && count < 3)
1740 wl_display_dispatch_queue(mDisplay, mEventQueue);
1744 if(!mScreenOffModeChangeDone)
1746 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
1747 return Dali::WindowOperationResult::UNKNOWN_ERROR;
1749 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1751 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
1752 return Dali::WindowOperationResult::PERMISSION_DENIED;
1755 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
1757 return Dali::WindowOperationResult::SUCCEED;
1760 WindowScreenOffMode WindowBaseEcoreWl::GetScreenOffMode() const
1762 while(!mTizenPolicy)
1764 wl_display_dispatch_queue(mDisplay, mEventQueue);
1769 while(!mScreenOffModeChangeDone && count < 3)
1772 wl_display_dispatch_queue(mDisplay, mEventQueue);
1776 if(!mScreenOffModeChangeDone)
1778 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
1779 return WindowScreenOffMode::TIMEOUT;
1782 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
1784 switch(mScreenOffMode)
1788 screenMode = WindowScreenOffMode::TIMEOUT;
1793 screenMode = WindowScreenOffMode::NEVER;
1798 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
1803 Dali::WindowOperationResult WindowBaseEcoreWl::SetBrightness(int brightness)
1805 while(!mTizenDisplayPolicy)
1807 wl_display_dispatch_queue(mDisplay, mEventQueue);
1810 mBrightnessChangeDone = false;
1811 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1813 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl_window_surface_get(mEcoreWindow), brightness);
1817 while(!mBrightnessChangeDone && count < 3)
1820 wl_display_dispatch_queue(mDisplay, mEventQueue);
1824 if(!mBrightnessChangeDone)
1826 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
1827 return Dali::WindowOperationResult::UNKNOWN_ERROR;
1829 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1831 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness);
1832 return Dali::WindowOperationResult::PERMISSION_DENIED;
1835 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness);
1837 return Dali::WindowOperationResult::SUCCEED;
1840 int WindowBaseEcoreWl::GetBrightness() const
1842 while(!mTizenDisplayPolicy)
1844 wl_display_dispatch_queue(mDisplay, mEventQueue);
1849 while(!mBrightnessChangeDone && count < 3)
1852 wl_display_dispatch_queue(mDisplay, mEventQueue);
1856 if(!mBrightnessChangeDone)
1858 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
1862 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness);
1867 bool WindowBaseEcoreWl::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
1869 Ecore_Wl_Window_Keygrab_Mode mode;
1873 case KeyGrab::TOPMOST:
1875 mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1878 case KeyGrab::SHARED:
1880 mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1883 case KeyGrab::OVERRIDE_EXCLUSIVE:
1885 mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1888 case KeyGrab::EXCLUSIVE:
1890 mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1899 return ecore_wl_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
1902 bool WindowBaseEcoreWl::UngrabKey(Dali::KEY key)
1904 return ecore_wl_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
1907 bool WindowBaseEcoreWl::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
1909 int keyCount = key.Count();
1910 int keyGrabModeCount = grabMode.Count();
1912 if(keyCount != keyGrabModeCount || keyCount == 0)
1919 Eina_List* keyList = NULL;
1920 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1922 for(int index = 0; index < keyCount; ++index)
1924 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
1926 switch(grabMode[index])
1928 case KeyGrab::TOPMOST:
1930 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1933 case KeyGrab::SHARED:
1935 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1938 case KeyGrab::OVERRIDE_EXCLUSIVE:
1940 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1943 case KeyGrab::EXCLUSIVE:
1945 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1950 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN;
1955 keyList = eina_list_append(keyList, &info);
1958 Eina_List* grabList = ecore_wl_window_keygrab_list_set(mEcoreWindow, keyList);
1960 result.Resize(keyCount, true);
1962 Eina_List* l = NULL;
1963 Eina_List* m = NULL;
1964 void* listData = NULL;
1966 if(grabList != NULL)
1968 EINA_LIST_FOREACH(grabList, m, data)
1971 EINA_LIST_FOREACH(keyList, l, listData)
1973 if(static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key == NULL)
1975 DALI_LOG_ERROR("input key list has null data!");
1979 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
1981 result[index] = false;
1990 eina_list_free(keyList);
1991 eina_list_free(grabList);
1997 bool WindowBaseEcoreWl::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
1999 int keyCount = key.Count();
2007 Eina_List* keyList = NULL;
2008 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
2010 for(int index = 0; index < keyCount; ++index)
2012 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2013 keyList = eina_list_append(keyList, &info);
2016 Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset(mEcoreWindow, keyList);
2018 result.Resize(keyCount, true);
2020 Eina_List* l = NULL;
2021 Eina_List* m = NULL;
2022 void* listData = NULL;
2025 if(ungrabList != NULL)
2027 EINA_LIST_FOREACH(ungrabList, m, data)
2030 EINA_LIST_FOREACH(keyList, l, listData)
2032 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
2034 result[index] = false;
2043 eina_list_free(keyList);
2044 eina_list_free(ungrabList);
2050 void WindowBaseEcoreWl::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2055 // 1 inch = 25.4 millimeters
2056 xres = ecore_wl_dpi_get();
2057 yres = ecore_wl_dpi_get();
2059 dpiHorizontal = int(xres + 0.5f); // rounding
2060 dpiVertical = int(yres + 0.5f);
2063 int WindowBaseEcoreWl::GetOrientation() const
2065 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2066 if(mSupportedPreProtation)
2073 int WindowBaseEcoreWl::GetScreenRotationAngle()
2077 if(ecore_wl_window_ignore_output_transform_get(mEcoreWindow))
2083 transform = ecore_wl_output_transform_get(ecore_wl_window_output_find(mEcoreWindow));
2086 mScreenRotationAngle = transform * 90;
2087 return mScreenRotationAngle;
2090 void WindowBaseEcoreWl::SetWindowRotationAngle(int degree)
2092 mWindowRotationAngle = degree;
2093 ecore_wl_window_rotation_set(mEcoreWindow, degree);
2096 void WindowBaseEcoreWl::WindowRotationCompleted(int degree, int width, int height)
2098 ecore_wl_window_rotation_change_done_send(mEcoreWindow);
2101 void WindowBaseEcoreWl::SetTransparency(bool transparent)
2103 ecore_wl_window_alpha_set(mEcoreWindow, transparent);
2106 void WindowBaseEcoreWl::CreateWindow(PositionSize positionSize)
2108 mEcoreWindow = ecore_wl_window_new(0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
2110 if(mEcoreWindow == 0)
2112 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2116 void WindowBaseEcoreWl::SetParent(WindowBase* parentWinBase, bool belowParent)
2118 Ecore_Wl_Window* ecoreParent = NULL;
2121 WindowBaseEcoreWl* winBaseEcore = static_cast<WindowBaseEcoreWl*>(parentWinBase);
2122 ecoreParent = winBaseEcore->mEcoreWindow;
2124 ecore_wl_window_parent_set(mEcoreWindow, ecoreParent);
2127 int WindowBaseEcoreWl::CreateFrameRenderedSyncFence()
2132 int WindowBaseEcoreWl::CreateFramePresentedSyncFence()
2137 void WindowBaseEcoreWl::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2141 void WindowBaseEcoreWl::InitializeIme()
2145 void WindowBaseEcoreWl::ImeWindowReadyToRender()
2149 void WindowBaseEcoreWl::RequestMoveToServer()
2153 void WindowBaseEcoreWl::RequestResizeToServer(WindowResizeDirection direction)
2157 void WindowBaseEcoreWl::EnableFloatingMode(bool enable)
2161 bool WindowBaseEcoreWl::IsFloatingModeEnabled() const
2166 void WindowBaseEcoreWl::IncludeInputRegion(const Rect<int>& inputRegion)
2170 void WindowBaseEcoreWl::ExcludeInputRegion(const Rect<int>& inputRegion)
2174 } // namespace Adaptor
2176 } // namespace Internal
2180 #pragma GCC diagnostic pop