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>
36 #if defined(VCONF_ENABLED)
37 #include <vconf-keys.h>
49 #if defined(DEBUG_ENABLED)
50 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
53 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
54 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
56 #if defined(VCONF_ENABLED)
57 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
61 const char* BUS = "org.enlightenment.wm-screen-reader";
62 const char* INTERFACE = "org.tizen.GestureNavigation";
63 const char* PATH = "/org/tizen/GestureNavigation";
66 * Get the device name from the provided ecore key event
68 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
70 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
74 result = ecoreDeviceName;
79 * Get the device class from the provided ecore event
81 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
83 switch(ecoreDeviceClass)
85 case ECORE_DEVICE_CLASS_SEAT:
87 deviceClass = Device::Class::USER;
90 case ECORE_DEVICE_CLASS_KEYBOARD:
92 deviceClass = Device::Class::KEYBOARD;
95 case ECORE_DEVICE_CLASS_MOUSE:
97 deviceClass = Device::Class::MOUSE;
100 case ECORE_DEVICE_CLASS_TOUCH:
102 deviceClass = Device::Class::TOUCH;
105 case ECORE_DEVICE_CLASS_PEN:
107 deviceClass = Device::Class::PEN;
110 case ECORE_DEVICE_CLASS_POINTER:
112 deviceClass = Device::Class::POINTER;
115 case ECORE_DEVICE_CLASS_GAMEPAD:
117 deviceClass = Device::Class::GAMEPAD;
122 deviceClass = Device::Class::NONE;
128 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
130 switch(ecoreDeviceSubclass)
132 case ECORE_DEVICE_SUBCLASS_FINGER:
134 deviceSubclass = Device::Subclass::FINGER;
137 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
139 deviceSubclass = Device::Subclass::FINGERNAIL;
142 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
144 deviceSubclass = Device::Subclass::KNUCKLE;
147 case ECORE_DEVICE_SUBCLASS_PALM:
149 deviceSubclass = Device::Subclass::PALM;
152 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
154 deviceSubclass = Device::Subclass::HAND_SIDE;
157 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
159 deviceSubclass = Device::Subclass::HAND_FLAT;
162 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
164 deviceSubclass = Device::Subclass::PEN_TIP;
167 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
169 deviceSubclass = Device::Subclass::TRACKPAD;
172 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
174 deviceSubclass = Device::Subclass::TRACKPOINT;
177 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
179 deviceSubclass = Device::Subclass::TRACKBALL;
182 case ECORE_DEVICE_SUBCLASS_REMOCON:
184 deviceSubclass = Device::Subclass::REMOCON;
187 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
189 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
194 deviceSubclass = Device::Subclass::NONE;
200 /////////////////////////////////////////////////////////////////////////////////////////////////
202 /////////////////////////////////////////////////////////////////////////////////////////////////
204 /// Called when the window iconify state is changed.
205 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
207 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
210 return windowBase->OnIconifyStateChanged(data, type, event);
213 return ECORE_CALLBACK_PASS_ON;
216 /// Called when the window gains focus
217 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
219 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
222 return windowBase->OnFocusIn(data, type, event);
225 return ECORE_CALLBACK_PASS_ON;
228 /// Called when the window loses focus
229 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
231 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
234 return windowBase->OnFocusOut(data, type, event);
237 return ECORE_CALLBACK_PASS_ON;
240 /// Called when the output is transformed
241 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
243 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
246 return windowBase->OnOutputTransform(data, type, event);
249 return ECORE_CALLBACK_PASS_ON;
252 /// Called when the output transform should be ignored
253 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
255 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
258 return windowBase->OnIgnoreOutputTransform(data, type, event);
261 return ECORE_CALLBACK_PASS_ON;
265 * Called when rotate event is recevied.
267 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
269 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
272 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::EcoreEventRotate\n");
273 windowBase->OnRotation(data, type, event);
275 return ECORE_CALLBACK_PASS_ON;
278 /////////////////////////////////////////////////////////////////////////////////////////////////
280 /////////////////////////////////////////////////////////////////////////////////////////////////
283 * Called when a touch down is received.
285 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
287 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
290 windowBase->OnMouseButtonDown(data, type, event);
292 return ECORE_CALLBACK_PASS_ON;
296 * Called when a touch up is received.
298 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
300 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
303 windowBase->OnMouseButtonUp(data, type, event);
305 return ECORE_CALLBACK_PASS_ON;
309 * Called when a touch motion is received.
311 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
313 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
316 windowBase->OnMouseButtonMove(data, type, event);
318 return ECORE_CALLBACK_PASS_ON;
322 * Called when a touch is canceled.
324 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
326 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
329 windowBase->OnMouseButtonCancel(data, type, event);
331 return ECORE_CALLBACK_PASS_ON;
335 * Called when a mouse wheel is received.
337 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
339 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
342 windowBase->OnMouseWheel(data, type, event);
344 return ECORE_CALLBACK_PASS_ON;
348 * Called when a detent rotation event is recevied.
350 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
352 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
355 windowBase->OnDetentRotation(data, type, event);
357 return ECORE_CALLBACK_PASS_ON;
360 /////////////////////////////////////////////////////////////////////////////////////////////////
362 /////////////////////////////////////////////////////////////////////////////////////////////////
365 * Called when a key down is received.
367 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
369 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
372 windowBase->OnKeyDown(data, type, event);
374 return ECORE_CALLBACK_PASS_ON;
378 * Called when a key up is received.
380 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
382 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
385 windowBase->OnKeyUp(data, type, event);
387 return ECORE_CALLBACK_PASS_ON;
390 /////////////////////////////////////////////////////////////////////////////////////////////////
391 // Selection Callbacks
392 /////////////////////////////////////////////////////////////////////////////////////////////////
395 * Called when the source window notifies us the content in clipboard is selected.
397 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
399 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
402 windowBase->OnDataSend(data, type, event);
404 return ECORE_CALLBACK_PASS_ON;
408 * Called when the source window sends us about the selected content.
409 * For example, when item is selected in the clipboard.
411 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
413 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
416 windowBase->OnDataReceive(data, type, event);
418 return ECORE_CALLBACK_PASS_ON;
421 /////////////////////////////////////////////////////////////////////////////////////////////////
423 /////////////////////////////////////////////////////////////////////////////////////////////////
425 #if defined(VCONF_ENABLED)
427 * Called when a font name is changed.
429 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
431 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
434 windowBase->OnFontNameChanged();
439 * Called when a font size is changed.
441 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
443 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
446 windowBase->OnFontSizeChanged();
451 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
453 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
456 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
460 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
462 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
465 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
469 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
473 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)
477 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
479 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
482 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
486 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
490 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
492 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
495 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
499 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
503 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
507 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
511 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
515 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)
519 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
521 WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
524 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
528 const struct wl_registry_listener registryListener =
530 RegistryGlobalCallback,
531 RegistryGlobalCallbackRemove};
533 const struct tizen_policy_listener tizenPolicyListener =
535 TizenPolicyConformant,
536 TizenPolicyConformantArea,
537 TizenPolicyNotificationChangeDone,
538 TizenPolicyTransientForDone,
539 TizenPolicyScreenModeChangeDone,
540 TizenPolicyIconifyStateChanged,
541 TizenPolicySupportedAuxiliaryHints,
542 TizenPolicyAllowedAuxiliaryHint,
543 TizenPolicyAuxiliaryMessage,
544 TizenPolicyConformantRegion};
546 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
548 DisplayPolicyBrightnessChangeDone};
550 } // unnamed namespace
552 WindowBaseEcoreWl::WindowBaseEcoreWl(Dali::PositionSize positionSize, Any surface, bool isTransparent)
553 : mEcoreEventHandler(),
554 mEcoreWindow(nullptr),
558 mEventQueue(nullptr),
559 mTizenPolicy(nullptr),
560 mTizenDisplayPolicy(nullptr),
561 mSupportedAuxiliaryHints(),
563 mNotificationLevel(-1),
564 mNotificationChangeState(0),
565 mNotificationLevelChangeDone(true),
567 mScreenOffModeChangeState(0),
568 mScreenOffModeChangeDone(true),
570 mBrightnessChangeState(0),
571 mBrightnessChangeDone(true),
573 mWindowRotationAngle(0),
574 mScreenRotationAngle(0),
575 mSupportedPreProtation(0)
577 Initialize(positionSize, surface, isTransparent);
580 WindowBaseEcoreWl::~WindowBaseEcoreWl()
582 #if defined(VCONF_ENABLED)
583 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
584 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
587 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
589 ecore_event_handler_del(*iter);
591 mEcoreEventHandler.Clear();
595 wl_event_queue_destroy(mEventQueue);
598 mSupportedAuxiliaryHints.clear();
599 mAuxiliaryHints.clear();
601 if(mEglWindow != NULL)
603 wl_egl_window_destroy(mEglWindow);
609 ecore_wl_window_free(mEcoreWindow);
611 WindowSystem::Shutdown();
615 void WindowBaseEcoreWl::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
617 if(surface.Empty() == false)
619 // check we have a valid type
620 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl_Window*)) && "Surface type is invalid");
622 mEcoreWindow = AnyCast<Ecore_Wl_Window*>(surface);
626 // we own the surface about to created
627 WindowSystem::Initialize();
630 CreateWindow(positionSize);
633 mWlSurface = ecore_wl_window_surface_create(mEcoreWindow);
635 SetTransparency(isTransparent);
637 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
638 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
639 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
640 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
641 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
643 // Register Rotate event
644 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
646 // Register Touch events
647 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
648 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
649 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
650 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
652 // Register Mouse wheel events
653 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
655 // Register Detent event
656 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
658 // Register Key events
659 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
660 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
662 // Register Selection event - clipboard selection
663 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
664 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
666 #if defined(VCONF_ENABLED)
667 // Register Vconf notify - font name and size
668 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
669 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
672 mDisplay = ecore_wl_display_get();
676 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
679 mEventQueue = wl_display_create_queue(mDisplay);
682 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
684 wl_registry* registry = wl_display_get_registry(displayWrapper);
685 wl_registry_add_listener(registry, ®istryListener, this);
688 wl_proxy_wrapper_destroy(displayWrapper);
692 // get auxiliary hint
693 Eina_List* hints = ecore_wl_window_aux_hints_supported_get(mEcoreWindow);
699 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))))
701 mSupportedAuxiliaryHints.push_back(hint);
703 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint);
708 Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged(void* data, int type, void* event)
710 Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl_Event_Window_Iconify_State_Change*>(event));
711 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
713 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
715 if(iconifyChangedEvent->iconified == EINA_TRUE)
717 mIconifyChangedSignal.Emit(true);
721 mIconifyChangedSignal.Emit(false);
723 handled = ECORE_CALLBACK_DONE;
729 Eina_Bool WindowBaseEcoreWl::OnFocusIn(void* data, int type, void* event)
731 Ecore_Wl_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl_Event_Focus_In*>(event));
733 if(focusInEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
735 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
737 mFocusChangedSignal.Emit(true);
740 return ECORE_CALLBACK_PASS_ON;
743 Eina_Bool WindowBaseEcoreWl::OnFocusOut(void* data, int type, void* event)
745 Ecore_Wl_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl_Event_Focus_Out*>(event));
747 if(focusOutEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
749 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
751 mFocusChangedSignal.Emit(false);
754 return ECORE_CALLBACK_PASS_ON;
757 Eina_Bool WindowBaseEcoreWl::OnOutputTransform(void* data, int type, void* event)
759 Ecore_Wl_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl_Event_Output_Transform*>(event));
761 if(transformEvent->output == ecore_wl_window_output_find(mEcoreWindow))
763 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
765 mOutputTransformedSignal.Emit();
768 return ECORE_CALLBACK_PASS_ON;
771 Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform(void* data, int type, void* event)
773 Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl_Event_Ignore_Output_Transform*>(event));
775 if(ignoreTransformEvent->win == mEcoreWindow)
777 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
779 mOutputTransformedSignal.Emit();
782 return ECORE_CALLBACK_PASS_ON;
785 void WindowBaseEcoreWl::OnRotation(void* data, int type, void* event)
787 Ecore_Wl_Event_Window_Rotate* ev(static_cast<Ecore_Wl_Event_Window_Rotate*>(event));
789 if(ev->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
791 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
793 RotationEvent rotationEvent;
794 rotationEvent.angle = ev->angle;
795 rotationEvent.winResize = 0;
797 if(ev->angle == 0 || ev->angle == 180)
799 rotationEvent.width = ev->w;
800 rotationEvent.height = ev->h;
804 rotationEvent.width = ev->h;
805 rotationEvent.height = ev->w;
808 mRotationSignal.Emit(rotationEvent);
812 void WindowBaseEcoreWl::OnMouseButtonDown(void* data, int type, void* event)
814 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
816 if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
818 PointState::Type state(PointState::DOWN);
820 // Check if the buttons field is set and ensure it's the primary touch button.
821 // If this event was triggered by buttons other than the primary button (used for touch), then
822 // just send an interrupted event to Core.
823 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
825 state = PointState::INTERRUPTED;
828 Device::Class::Type deviceClass;
829 Device::Subclass::Type deviceSubclass;
831 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
832 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
834 Integration::Point point;
835 point.SetDeviceId(touchEvent->multi.device);
836 point.SetState(state);
837 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
838 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
839 point.SetPressure(touchEvent->multi.pressure);
840 point.SetAngle(Degree(touchEvent->multi.angle));
841 point.SetDeviceClass(deviceClass);
842 point.SetDeviceSubclass(deviceSubclass);
844 mTouchEventSignal.Emit(point, touchEvent->timestamp);
848 void WindowBaseEcoreWl::OnMouseButtonUp(void* data, int type, void* event)
850 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
852 if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
854 Device::Class::Type deviceClass;
855 Device::Subclass::Type deviceSubclass;
857 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
858 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
860 Integration::Point point;
861 point.SetDeviceId(touchEvent->multi.device);
862 point.SetState(PointState::UP);
863 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
864 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
865 point.SetPressure(touchEvent->multi.pressure);
866 point.SetAngle(Degree(touchEvent->multi.angle));
867 point.SetDeviceClass(deviceClass);
868 point.SetDeviceSubclass(deviceSubclass);
870 mTouchEventSignal.Emit(point, touchEvent->timestamp);
874 void WindowBaseEcoreWl::OnMouseButtonMove(void* data, int type, void* event)
876 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
878 if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
880 Device::Class::Type deviceClass;
881 Device::Subclass::Type deviceSubclass;
883 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
884 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
886 Integration::Point point;
887 point.SetDeviceId(touchEvent->multi.device);
888 point.SetState(PointState::MOTION);
889 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
890 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
891 point.SetPressure(touchEvent->multi.pressure);
892 point.SetAngle(Degree(touchEvent->multi.angle));
893 point.SetDeviceClass(deviceClass);
894 point.SetDeviceSubclass(deviceSubclass);
896 mTouchEventSignal.Emit(point, touchEvent->timestamp);
900 void WindowBaseEcoreWl::OnMouseButtonCancel(void* data, int type, void* event)
902 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
904 if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
906 Device::Class::Type deviceClass;
907 Device::Subclass::Type deviceSubclass;
909 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
910 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
912 Integration::Point point;
913 point.SetDeviceId(touchEvent->multi.device);
914 point.SetState(PointState::INTERRUPTED);
915 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
916 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
917 point.SetPressure(touchEvent->multi.pressure);
918 point.SetAngle(Degree(touchEvent->multi.angle));
919 point.SetDeviceClass(deviceClass);
920 point.SetDeviceSubclass(deviceSubclass);
922 mTouchEventSignal.Emit(point, touchEvent->timestamp);
924 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n");
928 void WindowBaseEcoreWl::OnMouseWheel(void* data, int type, void* event)
930 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
932 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
934 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);
936 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
938 mWheelEventSignal.Emit(wheelEvent);
942 void WindowBaseEcoreWl::OnDetentRotation(void* data, int type, void* event)
944 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
946 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n");
948 int direction = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
949 int timeStamp = detentEvent->timestamp;
951 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp);
953 mWheelEventSignal.Emit(wheelEvent);
956 void WindowBaseEcoreWl::OnKeyDown(void* data, int type, void* event)
958 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
960 if(keyEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
962 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n");
964 std::string keyName(keyEvent->keyname);
965 std::string logicalKey("");
966 std::string keyString("");
967 std::string compose("");
969 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
970 if(keyEvent->compose)
972 compose = keyEvent->compose;
975 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
978 logicalKey = keyEvent->key;
981 int keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
982 keyCode = (keyCode == -1) ? 0 : keyCode;
983 int modifier(keyEvent->modifiers);
984 unsigned long time = keyEvent->timestamp;
985 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
987 keyCode = atoi(keyEvent->keyname + 8);
990 // Ensure key event string is not NULL as keys like SHIFT have a null string.
993 keyString = keyEvent->string;
996 std::string deviceName;
997 Device::Class::Type deviceClass;
998 Device::Subclass::Type deviceSubclass;
1000 GetDeviceName(keyEvent, deviceName);
1001 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1002 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1004 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1006 mKeyEventSignal.Emit(keyEvent);
1010 void WindowBaseEcoreWl::OnKeyUp(void* data, int type, void* event)
1012 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1014 if(keyEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
1016 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n");
1018 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1019 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1020 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1022 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp: This event flag indicates the event is canceled. \n");
1025 #endif // Since ecore 1.23 version
1027 std::string keyName(keyEvent->keyname);
1028 std::string logicalKey("");
1029 std::string keyString("");
1030 std::string compose("");
1032 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1033 if(keyEvent->compose)
1035 compose = keyEvent->compose;
1038 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1041 logicalKey = keyEvent->key;
1044 int keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1045 keyCode = (keyCode == -1) ? 0 : keyCode;
1046 int modifier(keyEvent->modifiers);
1047 unsigned long time = keyEvent->timestamp;
1048 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1050 keyCode = atoi(keyEvent->keyname + 8);
1053 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1054 if(keyEvent->string)
1056 keyString = keyEvent->string;
1059 std::string deviceName;
1060 Device::Class::Type deviceClass;
1061 Device::Subclass::Type deviceSubclass;
1063 GetDeviceName(keyEvent, deviceName);
1064 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1065 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1067 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1069 mKeyEventSignal.Emit(keyEvent);
1073 void WindowBaseEcoreWl::OnDataSend(void* data, int type, void* event)
1075 mSelectionDataSendSignal.Emit(event);
1078 void WindowBaseEcoreWl::OnDataReceive(void* data, int type, void* event)
1080 mSelectionDataReceivedSignal.Emit(event);
1083 void WindowBaseEcoreWl::OnFontNameChanged()
1085 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1088 void WindowBaseEcoreWl::OnFontSizeChanged()
1090 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1093 void WindowBaseEcoreWl::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1095 if(strcmp(interface, tizen_policy_interface.name) == 0)
1097 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1099 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1102 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1106 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1108 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1110 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1112 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1113 if(!mTizenDisplayPolicy)
1115 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1119 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1121 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1125 void WindowBaseEcoreWl::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1127 mTizenPolicy = NULL;
1128 mTizenDisplayPolicy = NULL;
1131 void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1133 mNotificationLevel = level;
1134 mNotificationChangeState = state;
1135 mNotificationLevelChangeDone = true;
1137 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1140 void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1142 mScreenOffMode = mode;
1143 mScreenOffModeChangeState = state;
1144 mScreenOffModeChangeDone = true;
1146 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1149 void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1151 mBrightness = brightness;
1152 mBrightnessChangeState = state;
1153 mBrightnessChangeDone = true;
1155 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1158 Any WindowBaseEcoreWl::GetNativeWindow()
1160 return mEcoreWindow;
1163 int WindowBaseEcoreWl::GetNativeWindowId()
1165 return ecore_wl_window_id_get(mEcoreWindow);
1168 std::string WindowBaseEcoreWl::GetNativeWindowResourceId()
1170 return std::string();
1173 EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow(int width, int height)
1175 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1177 return static_cast<EGLNativeWindowType>(mEglWindow);
1180 void WindowBaseEcoreWl::DestroyEglWindow()
1182 if(mEglWindow != NULL)
1184 wl_egl_window_destroy(mEglWindow);
1189 void WindowBaseEcoreWl::SetEglWindowRotation(int angle)
1191 wl_egl_window_rotation rotation;
1197 rotation = ROTATION_0;
1202 rotation = ROTATION_270;
1207 rotation = ROTATION_180;
1212 rotation = ROTATION_90;
1217 rotation = ROTATION_0;
1222 wl_egl_window_set_rotation(mEglWindow, rotation);
1225 void WindowBaseEcoreWl::SetEglWindowBufferTransform(int angle)
1227 wl_output_transform bufferTransform;
1233 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1238 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1243 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1248 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1253 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1258 wl_egl_window_set_buffer_transform(mEglWindow, bufferTransform);
1261 void WindowBaseEcoreWl::SetEglWindowTransform(int angle)
1263 wl_output_transform windowTransform;
1269 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1274 windowTransform = WL_OUTPUT_TRANSFORM_90;
1279 windowTransform = WL_OUTPUT_TRANSFORM_180;
1284 windowTransform = WL_OUTPUT_TRANSFORM_270;
1289 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1294 wl_egl_window_set_window_transform(mEglWindow, windowTransform);
1297 void WindowBaseEcoreWl::ResizeEglWindow(PositionSize positionSize)
1299 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1302 bool WindowBaseEcoreWl::IsEglWindowRotationSupported()
1305 wl_egl_window_capability capability = static_cast<wl_egl_window_capability>(wl_egl_window_get_capabilities(mEglWindow));
1306 if(capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED)
1308 mSupportedPreProtation = true;
1311 mSupportedPreProtation = false;
1315 void WindowBaseEcoreWl::Move(PositionSize positionSize)
1317 ecore_wl_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
1320 void WindowBaseEcoreWl::Resize(PositionSize positionSize)
1322 ecore_wl_window_update_size(mEcoreWindow, positionSize.width, positionSize.height);
1325 void WindowBaseEcoreWl::MoveResize(PositionSize positionSize)
1327 ecore_wl_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
1328 ecore_wl_window_update_size(mEcoreWindow, positionSize.width, positionSize.height);
1331 void WindowBaseEcoreWl::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
1335 void WindowBaseEcoreWl::SetClass(const std::string& name, const std::string& className)
1337 ecore_wl_window_title_set(mEcoreWindow, name.c_str());
1338 ecore_wl_window_class_name_set(mEcoreWindow, className.c_str());
1341 void WindowBaseEcoreWl::Raise()
1343 // Use ecore_wl_window_activate to prevent the window shown without rendering
1344 ecore_wl_window_activate(mEcoreWindow);
1347 void WindowBaseEcoreWl::Lower()
1349 ecore_wl_window_lower(mEcoreWindow);
1352 void WindowBaseEcoreWl::Activate()
1354 ecore_wl_window_activate(mEcoreWindow);
1357 void WindowBaseEcoreWl::Maximize(bool maximize)
1361 bool WindowBaseEcoreWl::IsMaximized() const
1366 void WindowBaseEcoreWl::SetMaximumSize(Dali::Window::WindowSize size)
1370 void WindowBaseEcoreWl::Minimize(bool minimize)
1374 bool WindowBaseEcoreWl::IsMinimized() const
1379 void WindowBaseEcoreWl::SetMimimumSize(Dali::Window::WindowSize size)
1383 void WindowBaseEcoreWl::SetAvailableAnlges(const std::vector<int>& angles)
1385 int rotations[4] = {0};
1386 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::SetAvailableAnlges, angle's count: %d\n", angles.size());
1387 for(std::size_t i = 0; i < angles.size(); ++i)
1389 rotations[i] = static_cast<int>(angles[i]);
1390 DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
1392 ecore_wl_window_rotation_available_rotations_set(mEcoreWindow, rotations, angles.size());
1395 void WindowBaseEcoreWl::SetPreferredAngle(int angle)
1397 ecore_wl_window_rotation_preferred_rotation_set(mEcoreWindow, angle);
1400 void WindowBaseEcoreWl::SetAcceptFocus(bool accept)
1402 ecore_wl_window_focus_skip_set(mEcoreWindow, !accept);
1405 void WindowBaseEcoreWl::Show()
1407 ecore_wl_window_show(mEcoreWindow);
1410 void WindowBaseEcoreWl::Hide()
1412 ecore_wl_window_hide(mEcoreWindow);
1415 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
1417 return mSupportedAuxiliaryHints.size();
1420 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint(unsigned int index) const
1422 if(index >= GetSupportedAuxiliaryHintCount())
1424 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
1427 return mSupportedAuxiliaryHints[index];
1430 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint(const std::string& hint, const std::string& value)
1432 bool supported = false;
1434 // Check if the hint is suppported
1435 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
1446 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
1450 // Check if the hint is already added
1451 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1453 if(mAuxiliaryHints[i].first == hint)
1455 // Just change the value
1456 mAuxiliaryHints[i].second = value;
1458 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
1460 return i + 1; // id is index + 1
1465 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
1467 unsigned int id = mAuxiliaryHints.size();
1469 ecore_wl_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
1471 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
1476 bool WindowBaseEcoreWl::RemoveAuxiliaryHint(unsigned int id)
1478 if(id == 0 || id > mAuxiliaryHints.size())
1480 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
1484 mAuxiliaryHints[id - 1].second = std::string();
1486 ecore_wl_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
1488 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
1493 bool WindowBaseEcoreWl::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
1495 if(id == 0 || id > mAuxiliaryHints.size())
1497 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
1501 mAuxiliaryHints[id - 1].second = value;
1503 ecore_wl_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
1505 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());
1510 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue(unsigned int id) const
1512 if(id == 0 || id > mAuxiliaryHints.size())
1514 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
1515 return std::string();
1518 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());
1520 return mAuxiliaryHints[id - 1].second;
1523 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId(const std::string& hint) const
1525 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1527 if(mAuxiliaryHints[i].first == hint)
1529 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
1534 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
1539 void WindowBaseEcoreWl::SetInputRegion(const Rect<int>& inputRegion)
1541 ecore_wl_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1544 void WindowBaseEcoreWl::SetType(Dali::WindowType type)
1546 Ecore_Wl_Window_Type windowType;
1550 case Dali::WindowType::NORMAL:
1552 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1555 case Dali::WindowType::NOTIFICATION:
1557 windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
1560 case Dali::WindowType::UTILITY:
1562 windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
1565 case Dali::WindowType::DIALOG:
1567 windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
1572 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1577 ecore_wl_window_type_set(mEcoreWindow, windowType);
1580 Dali::WindowType WindowBaseEcoreWl::GetType() const
1582 return Dali::WindowType::NORMAL;
1585 Dali::WindowOperationResult WindowBaseEcoreWl::SetNotificationLevel(Dali::WindowNotificationLevel level)
1587 while(!mTizenPolicy)
1589 wl_display_dispatch_queue(mDisplay, mEventQueue);
1592 int notificationLevel;
1596 case Dali::WindowNotificationLevel::NONE:
1598 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1601 case Dali::WindowNotificationLevel::BASE:
1603 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1606 case Dali::WindowNotificationLevel::MEDIUM:
1608 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1611 case Dali::WindowNotificationLevel::HIGH:
1613 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1616 case Dali::WindowNotificationLevel::TOP:
1618 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1623 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level);
1624 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1629 mNotificationLevelChangeDone = false;
1630 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1632 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), notificationLevel);
1636 while(!mNotificationLevelChangeDone && count < 3)
1639 wl_display_dispatch_queue(mDisplay, mEventQueue);
1643 if(!mNotificationLevelChangeDone)
1645 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
1646 return Dali::WindowOperationResult::UNKNOWN_ERROR;
1648 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1650 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level);
1651 return Dali::WindowOperationResult::PERMISSION_DENIED;
1654 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
1656 return Dali::WindowOperationResult::SUCCEED;
1659 Dali::WindowNotificationLevel WindowBaseEcoreWl::GetNotificationLevel() const
1661 while(!mTizenPolicy)
1663 wl_display_dispatch_queue(mDisplay, mEventQueue);
1668 while(!mNotificationLevelChangeDone && count < 3)
1671 wl_display_dispatch_queue(mDisplay, mEventQueue);
1675 if(!mNotificationLevelChangeDone)
1677 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
1678 return Dali::Window::NotificationLevel::NONE;
1681 Dali::WindowNotificationLevel level;
1683 switch(mNotificationLevel)
1685 case TIZEN_POLICY_LEVEL_NONE:
1687 level = Dali::WindowNotificationLevel::NONE;
1690 case TIZEN_POLICY_LEVEL_DEFAULT:
1692 level = Dali::WindowNotificationLevel::BASE;
1695 case TIZEN_POLICY_LEVEL_MEDIUM:
1697 level = Dali::WindowNotificationLevel::MEDIUM;
1700 case TIZEN_POLICY_LEVEL_HIGH:
1702 level = Dali::WindowNotificationLevel::HIGH;
1705 case TIZEN_POLICY_LEVEL_TOP:
1707 level = Dali::WindowNotificationLevel::TOP;
1712 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
1713 level = Dali::WindowNotificationLevel::NONE;
1718 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel);
1723 void WindowBaseEcoreWl::SetOpaqueState(bool opaque)
1725 while(!mTizenPolicy)
1727 wl_display_dispatch_queue(mDisplay, mEventQueue);
1730 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
1733 Dali::WindowOperationResult WindowBaseEcoreWl::SetScreenOffMode(WindowScreenOffMode screenOffMode)
1735 while(!mTizenPolicy)
1737 wl_display_dispatch_queue(mDisplay, mEventQueue);
1740 mScreenOffModeChangeDone = false;
1741 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1743 unsigned int mode = 0;
1745 switch(screenOffMode)
1747 case WindowScreenOffMode::TIMEOUT:
1752 case WindowScreenOffMode::NEVER:
1759 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), mode);
1763 while(!mScreenOffModeChangeDone && count < 3)
1766 wl_display_dispatch_queue(mDisplay, mEventQueue);
1770 if(!mScreenOffModeChangeDone)
1772 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
1773 return Dali::WindowOperationResult::UNKNOWN_ERROR;
1775 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1777 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
1778 return Dali::WindowOperationResult::PERMISSION_DENIED;
1781 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
1783 return Dali::WindowOperationResult::SUCCEED;
1786 WindowScreenOffMode WindowBaseEcoreWl::GetScreenOffMode() const
1788 while(!mTizenPolicy)
1790 wl_display_dispatch_queue(mDisplay, mEventQueue);
1795 while(!mScreenOffModeChangeDone && count < 3)
1798 wl_display_dispatch_queue(mDisplay, mEventQueue);
1802 if(!mScreenOffModeChangeDone)
1804 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
1805 return WindowScreenOffMode::TIMEOUT;
1808 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
1810 switch(mScreenOffMode)
1814 screenMode = WindowScreenOffMode::TIMEOUT;
1819 screenMode = WindowScreenOffMode::NEVER;
1824 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
1829 Dali::WindowOperationResult WindowBaseEcoreWl::SetBrightness(int brightness)
1831 while(!mTizenDisplayPolicy)
1833 wl_display_dispatch_queue(mDisplay, mEventQueue);
1836 mBrightnessChangeDone = false;
1837 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1839 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl_window_surface_get(mEcoreWindow), brightness);
1843 while(!mBrightnessChangeDone && count < 3)
1846 wl_display_dispatch_queue(mDisplay, mEventQueue);
1850 if(!mBrightnessChangeDone)
1852 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
1853 return Dali::WindowOperationResult::UNKNOWN_ERROR;
1855 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1857 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness);
1858 return Dali::WindowOperationResult::PERMISSION_DENIED;
1861 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness);
1863 return Dali::WindowOperationResult::SUCCEED;
1866 int WindowBaseEcoreWl::GetBrightness() const
1868 while(!mTizenDisplayPolicy)
1870 wl_display_dispatch_queue(mDisplay, mEventQueue);
1875 while(!mBrightnessChangeDone && count < 3)
1878 wl_display_dispatch_queue(mDisplay, mEventQueue);
1882 if(!mBrightnessChangeDone)
1884 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
1888 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness);
1893 bool WindowBaseEcoreWl::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
1895 Ecore_Wl_Window_Keygrab_Mode mode;
1899 case KeyGrab::TOPMOST:
1901 mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1904 case KeyGrab::SHARED:
1906 mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1909 case KeyGrab::OVERRIDE_EXCLUSIVE:
1911 mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1914 case KeyGrab::EXCLUSIVE:
1916 mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1925 return ecore_wl_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
1928 bool WindowBaseEcoreWl::UngrabKey(Dali::KEY key)
1930 return ecore_wl_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
1933 bool WindowBaseEcoreWl::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
1935 int keyCount = key.Count();
1936 int keyGrabModeCount = grabMode.Count();
1938 if(keyCount != keyGrabModeCount || keyCount == 0)
1945 Eina_List* keyList = NULL;
1946 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1948 for(int index = 0; index < keyCount; ++index)
1950 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
1952 switch(grabMode[index])
1954 case KeyGrab::TOPMOST:
1956 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1959 case KeyGrab::SHARED:
1961 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1964 case KeyGrab::OVERRIDE_EXCLUSIVE:
1966 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1969 case KeyGrab::EXCLUSIVE:
1971 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1976 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN;
1981 keyList = eina_list_append(keyList, &info);
1984 Eina_List* grabList = ecore_wl_window_keygrab_list_set(mEcoreWindow, keyList);
1986 result.Resize(keyCount, true);
1988 Eina_List* l = NULL;
1989 Eina_List* m = NULL;
1990 void* listData = NULL;
1992 if(grabList != NULL)
1994 EINA_LIST_FOREACH(grabList, m, data)
1997 EINA_LIST_FOREACH(keyList, l, listData)
1999 if(static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key == NULL)
2001 DALI_LOG_ERROR("input key list has null data!");
2005 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
2007 result[index] = false;
2016 eina_list_free(keyList);
2017 eina_list_free(grabList);
2023 bool WindowBaseEcoreWl::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
2025 int keyCount = key.Count();
2033 Eina_List* keyList = NULL;
2034 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
2036 for(int index = 0; index < keyCount; ++index)
2038 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2039 keyList = eina_list_append(keyList, &info);
2042 Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset(mEcoreWindow, keyList);
2044 result.Resize(keyCount, true);
2046 Eina_List* l = NULL;
2047 Eina_List* m = NULL;
2048 void* listData = NULL;
2051 if(ungrabList != NULL)
2053 EINA_LIST_FOREACH(ungrabList, m, data)
2056 EINA_LIST_FOREACH(keyList, l, listData)
2058 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
2060 result[index] = false;
2069 eina_list_free(keyList);
2070 eina_list_free(ungrabList);
2076 void WindowBaseEcoreWl::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2081 // 1 inch = 25.4 millimeters
2082 xres = ecore_wl_dpi_get();
2083 yres = ecore_wl_dpi_get();
2085 dpiHorizontal = int(xres + 0.5f); // rounding
2086 dpiVertical = int(yres + 0.5f);
2089 int WindowBaseEcoreWl::GetWindowRotationAngle() const
2091 int orientation = mWindowRotationAngle;
2092 if(mSupportedPreProtation)
2099 int WindowBaseEcoreWl::GetScreenRotationAngle()
2103 if(ecore_wl_window_ignore_output_transform_get(mEcoreWindow))
2109 transform = ecore_wl_output_transform_get(ecore_wl_window_output_find(mEcoreWindow));
2112 mScreenRotationAngle = transform * 90;
2113 return mScreenRotationAngle;
2116 void WindowBaseEcoreWl::SetWindowRotationAngle(int degree)
2118 mWindowRotationAngle = degree;
2119 ecore_wl_window_rotation_set(mEcoreWindow, degree);
2122 void WindowBaseEcoreWl::WindowRotationCompleted(int degree, int width, int height)
2124 ecore_wl_window_rotation_change_done_send(mEcoreWindow);
2127 void WindowBaseEcoreWl::SetTransparency(bool transparent)
2129 ecore_wl_window_alpha_set(mEcoreWindow, transparent);
2132 void WindowBaseEcoreWl::CreateWindow(PositionSize positionSize)
2134 mEcoreWindow = ecore_wl_window_new(0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
2136 if(mEcoreWindow == 0)
2138 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2142 void WindowBaseEcoreWl::SetParent(WindowBase* parentWinBase, bool belowParent)
2144 Ecore_Wl_Window* ecoreParent = NULL;
2147 WindowBaseEcoreWl* winBaseEcore = static_cast<WindowBaseEcoreWl*>(parentWinBase);
2148 ecoreParent = winBaseEcore->mEcoreWindow;
2150 ecore_wl_window_parent_set(mEcoreWindow, ecoreParent);
2153 int WindowBaseEcoreWl::CreateFrameRenderedSyncFence()
2158 int WindowBaseEcoreWl::CreateFramePresentedSyncFence()
2163 void WindowBaseEcoreWl::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2167 void WindowBaseEcoreWl::InitializeIme()
2171 void WindowBaseEcoreWl::ImeWindowReadyToRender()
2175 void WindowBaseEcoreWl::RequestMoveToServer()
2179 void WindowBaseEcoreWl::RequestResizeToServer(WindowResizeDirection direction)
2183 void WindowBaseEcoreWl::EnableFloatingMode(bool enable)
2187 bool WindowBaseEcoreWl::IsFloatingModeEnabled() const
2192 void WindowBaseEcoreWl::IncludeInputRegion(const Rect<int>& inputRegion)
2196 void WindowBaseEcoreWl::ExcludeInputRegion(const Rect<int>& inputRegion)
2200 } // namespace Adaptor
2202 } // namespace Internal
2206 #pragma GCC diagnostic pop