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(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
659 vconf_notify_key_changed(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::Minimize(bool minimize)
1344 bool WindowBaseEcoreWl::IsMinimized() const
1349 void WindowBaseEcoreWl::SetAvailableAnlges(const std::vector<int>& angles)
1351 int rotations[4] = {0};
1352 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::SetAvailableAnlges, angle's count: %d\n", angles.size());
1353 for(std::size_t i = 0; i < angles.size(); ++i)
1355 rotations[i] = static_cast<int>(angles[i]);
1356 DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
1358 ecore_wl_window_rotation_available_rotations_set(mEcoreWindow, rotations, angles.size());
1361 void WindowBaseEcoreWl::SetPreferredAngle(int angle)
1363 ecore_wl_window_rotation_preferred_rotation_set(mEcoreWindow, angle);
1366 void WindowBaseEcoreWl::SetAcceptFocus(bool accept)
1368 ecore_wl_window_focus_skip_set(mEcoreWindow, !accept);
1371 void WindowBaseEcoreWl::Show()
1373 ecore_wl_window_show(mEcoreWindow);
1376 void WindowBaseEcoreWl::Hide()
1378 ecore_wl_window_hide(mEcoreWindow);
1381 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
1383 return mSupportedAuxiliaryHints.size();
1386 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint(unsigned int index) const
1388 if(index >= GetSupportedAuxiliaryHintCount())
1390 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
1393 return mSupportedAuxiliaryHints[index];
1396 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint(const std::string& hint, const std::string& value)
1398 bool supported = false;
1400 // Check if the hint is suppported
1401 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
1412 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
1416 // Check if the hint is already added
1417 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1419 if(mAuxiliaryHints[i].first == hint)
1421 // Just change the value
1422 mAuxiliaryHints[i].second = value;
1424 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
1426 return i + 1; // id is index + 1
1431 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
1433 unsigned int id = mAuxiliaryHints.size();
1435 ecore_wl_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
1437 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
1442 bool WindowBaseEcoreWl::RemoveAuxiliaryHint(unsigned int id)
1444 if(id == 0 || id > mAuxiliaryHints.size())
1446 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
1450 mAuxiliaryHints[id - 1].second = std::string();
1452 ecore_wl_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
1454 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
1459 bool WindowBaseEcoreWl::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
1461 if(id == 0 || id > mAuxiliaryHints.size())
1463 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
1467 mAuxiliaryHints[id - 1].second = value;
1469 ecore_wl_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
1471 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());
1476 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue(unsigned int id) const
1478 if(id == 0 || id > mAuxiliaryHints.size())
1480 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
1481 return std::string();
1484 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());
1486 return mAuxiliaryHints[id - 1].second;
1489 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId(const std::string& hint) const
1491 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1493 if(mAuxiliaryHints[i].first == hint)
1495 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
1500 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
1505 void WindowBaseEcoreWl::SetInputRegion(const Rect<int>& inputRegion)
1507 ecore_wl_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1510 void WindowBaseEcoreWl::SetType(Dali::WindowType type)
1512 Ecore_Wl_Window_Type windowType;
1516 case Dali::WindowType::NORMAL:
1518 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1521 case Dali::WindowType::NOTIFICATION:
1523 windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
1526 case Dali::WindowType::UTILITY:
1528 windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
1531 case Dali::WindowType::DIALOG:
1533 windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
1538 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1543 ecore_wl_window_type_set(mEcoreWindow, windowType);
1546 Dali::WindowType WindowBaseEcoreWl::GetType() const
1548 return Dali::WindowType::NORMAL;
1551 Dali::WindowOperationResult WindowBaseEcoreWl::SetNotificationLevel(Dali::WindowNotificationLevel level)
1553 while(!mTizenPolicy)
1555 wl_display_dispatch_queue(mDisplay, mEventQueue);
1558 int notificationLevel;
1562 case Dali::WindowNotificationLevel::NONE:
1564 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1567 case Dali::WindowNotificationLevel::BASE:
1569 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1572 case Dali::WindowNotificationLevel::MEDIUM:
1574 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1577 case Dali::WindowNotificationLevel::HIGH:
1579 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1582 case Dali::WindowNotificationLevel::TOP:
1584 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1589 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level);
1590 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1595 mNotificationLevelChangeDone = false;
1596 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1598 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), notificationLevel);
1602 while(!mNotificationLevelChangeDone && count < 3)
1605 wl_display_dispatch_queue(mDisplay, mEventQueue);
1609 if(!mNotificationLevelChangeDone)
1611 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
1612 return Dali::WindowOperationResult::UNKNOWN_ERROR;
1614 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1616 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level);
1617 return Dali::WindowOperationResult::PERMISSION_DENIED;
1620 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
1622 return Dali::WindowOperationResult::SUCCEED;
1625 Dali::WindowNotificationLevel WindowBaseEcoreWl::GetNotificationLevel() const
1627 while(!mTizenPolicy)
1629 wl_display_dispatch_queue(mDisplay, mEventQueue);
1634 while(!mNotificationLevelChangeDone && count < 3)
1637 wl_display_dispatch_queue(mDisplay, mEventQueue);
1641 if(!mNotificationLevelChangeDone)
1643 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
1644 return Dali::Window::NotificationLevel::NONE;
1647 Dali::WindowNotificationLevel level;
1649 switch(mNotificationLevel)
1651 case TIZEN_POLICY_LEVEL_NONE:
1653 level = Dali::WindowNotificationLevel::NONE;
1656 case TIZEN_POLICY_LEVEL_DEFAULT:
1658 level = Dali::WindowNotificationLevel::BASE;
1661 case TIZEN_POLICY_LEVEL_MEDIUM:
1663 level = Dali::WindowNotificationLevel::MEDIUM;
1666 case TIZEN_POLICY_LEVEL_HIGH:
1668 level = Dali::WindowNotificationLevel::HIGH;
1671 case TIZEN_POLICY_LEVEL_TOP:
1673 level = Dali::WindowNotificationLevel::TOP;
1678 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
1679 level = Dali::WindowNotificationLevel::NONE;
1684 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel);
1689 void WindowBaseEcoreWl::SetOpaqueState(bool opaque)
1691 while(!mTizenPolicy)
1693 wl_display_dispatch_queue(mDisplay, mEventQueue);
1696 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
1699 Dali::WindowOperationResult WindowBaseEcoreWl::SetScreenOffMode(WindowScreenOffMode screenOffMode)
1701 while(!mTizenPolicy)
1703 wl_display_dispatch_queue(mDisplay, mEventQueue);
1706 mScreenOffModeChangeDone = false;
1707 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1709 unsigned int mode = 0;
1711 switch(screenOffMode)
1713 case WindowScreenOffMode::TIMEOUT:
1718 case WindowScreenOffMode::NEVER:
1725 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), mode);
1729 while(!mScreenOffModeChangeDone && count < 3)
1732 wl_display_dispatch_queue(mDisplay, mEventQueue);
1736 if(!mScreenOffModeChangeDone)
1738 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
1739 return Dali::WindowOperationResult::UNKNOWN_ERROR;
1741 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1743 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
1744 return Dali::WindowOperationResult::PERMISSION_DENIED;
1747 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
1749 return Dali::WindowOperationResult::SUCCEED;
1752 WindowScreenOffMode WindowBaseEcoreWl::GetScreenOffMode() const
1754 while(!mTizenPolicy)
1756 wl_display_dispatch_queue(mDisplay, mEventQueue);
1761 while(!mScreenOffModeChangeDone && count < 3)
1764 wl_display_dispatch_queue(mDisplay, mEventQueue);
1768 if(!mScreenOffModeChangeDone)
1770 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
1771 return WindowScreenOffMode::TIMEOUT;
1774 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
1776 switch(mScreenOffMode)
1780 screenMode = WindowScreenOffMode::TIMEOUT;
1785 screenMode = WindowScreenOffMode::NEVER;
1790 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
1795 Dali::WindowOperationResult WindowBaseEcoreWl::SetBrightness(int brightness)
1797 while(!mTizenDisplayPolicy)
1799 wl_display_dispatch_queue(mDisplay, mEventQueue);
1802 mBrightnessChangeDone = false;
1803 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1805 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl_window_surface_get(mEcoreWindow), brightness);
1809 while(!mBrightnessChangeDone && count < 3)
1812 wl_display_dispatch_queue(mDisplay, mEventQueue);
1816 if(!mBrightnessChangeDone)
1818 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
1819 return Dali::WindowOperationResult::UNKNOWN_ERROR;
1821 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1823 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness);
1824 return Dali::WindowOperationResult::PERMISSION_DENIED;
1827 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness);
1829 return Dali::WindowOperationResult::SUCCEED;
1832 int WindowBaseEcoreWl::GetBrightness() const
1834 while(!mTizenDisplayPolicy)
1836 wl_display_dispatch_queue(mDisplay, mEventQueue);
1841 while(!mBrightnessChangeDone && count < 3)
1844 wl_display_dispatch_queue(mDisplay, mEventQueue);
1848 if(!mBrightnessChangeDone)
1850 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
1854 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness);
1859 bool WindowBaseEcoreWl::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
1861 Ecore_Wl_Window_Keygrab_Mode mode;
1865 case KeyGrab::TOPMOST:
1867 mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1870 case KeyGrab::SHARED:
1872 mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1875 case KeyGrab::OVERRIDE_EXCLUSIVE:
1877 mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1880 case KeyGrab::EXCLUSIVE:
1882 mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1891 return ecore_wl_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
1894 bool WindowBaseEcoreWl::UngrabKey(Dali::KEY key)
1896 return ecore_wl_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
1899 bool WindowBaseEcoreWl::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
1901 int keyCount = key.Count();
1902 int keyGrabModeCount = grabMode.Count();
1904 if(keyCount != keyGrabModeCount || keyCount == 0)
1911 Eina_List* keyList = NULL;
1912 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1914 for(int index = 0; index < keyCount; ++index)
1916 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
1918 switch(grabMode[index])
1920 case KeyGrab::TOPMOST:
1922 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1925 case KeyGrab::SHARED:
1927 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1930 case KeyGrab::OVERRIDE_EXCLUSIVE:
1932 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1935 case KeyGrab::EXCLUSIVE:
1937 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1942 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN;
1947 keyList = eina_list_append(keyList, &info);
1950 Eina_List* grabList = ecore_wl_window_keygrab_list_set(mEcoreWindow, keyList);
1952 result.Resize(keyCount, true);
1954 Eina_List* l = NULL;
1955 Eina_List* m = NULL;
1956 void* listData = NULL;
1958 if(grabList != NULL)
1960 EINA_LIST_FOREACH(grabList, m, data)
1963 EINA_LIST_FOREACH(keyList, l, listData)
1965 if(static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key == NULL)
1967 DALI_LOG_ERROR("input key list has null data!");
1971 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
1973 result[index] = false;
1982 eina_list_free(keyList);
1983 eina_list_free(grabList);
1989 bool WindowBaseEcoreWl::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
1991 int keyCount = key.Count();
1999 Eina_List* keyList = NULL;
2000 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
2002 for(int index = 0; index < keyCount; ++index)
2004 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2005 keyList = eina_list_append(keyList, &info);
2008 Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset(mEcoreWindow, keyList);
2010 result.Resize(keyCount, true);
2012 Eina_List* l = NULL;
2013 Eina_List* m = NULL;
2014 void* listData = NULL;
2017 if(ungrabList != NULL)
2019 EINA_LIST_FOREACH(ungrabList, m, data)
2022 EINA_LIST_FOREACH(keyList, l, listData)
2024 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
2026 result[index] = false;
2035 eina_list_free(keyList);
2036 eina_list_free(ungrabList);
2042 void WindowBaseEcoreWl::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2047 // 1 inch = 25.4 millimeters
2048 xres = ecore_wl_dpi_get();
2049 yres = ecore_wl_dpi_get();
2051 dpiHorizontal = int(xres + 0.5f); // rounding
2052 dpiVertical = int(yres + 0.5f);
2055 int WindowBaseEcoreWl::GetOrientation() const
2057 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2058 if(mSupportedPreProtation)
2065 int WindowBaseEcoreWl::GetScreenRotationAngle()
2069 if(ecore_wl_window_ignore_output_transform_get(mEcoreWindow))
2075 transform = ecore_wl_output_transform_get(ecore_wl_window_output_find(mEcoreWindow));
2078 mScreenRotationAngle = transform * 90;
2079 return mScreenRotationAngle;
2082 void WindowBaseEcoreWl::SetWindowRotationAngle(int degree)
2084 mWindowRotationAngle = degree;
2085 ecore_wl_window_rotation_set(mEcoreWindow, degree);
2088 void WindowBaseEcoreWl::WindowRotationCompleted(int degree, int width, int height)
2090 ecore_wl_window_rotation_change_done_send(mEcoreWindow);
2093 void WindowBaseEcoreWl::SetTransparency(bool transparent)
2095 ecore_wl_window_alpha_set(mEcoreWindow, transparent);
2098 void WindowBaseEcoreWl::CreateWindow(PositionSize positionSize)
2100 mEcoreWindow = ecore_wl_window_new(0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
2102 if(mEcoreWindow == 0)
2104 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2108 void WindowBaseEcoreWl::SetParent(WindowBase* parentWinBase, bool belowParent)
2110 Ecore_Wl_Window* ecoreParent = NULL;
2113 WindowBaseEcoreWl* winBaseEcore = static_cast<WindowBaseEcoreWl*>(parentWinBase);
2114 ecoreParent = winBaseEcore->mEcoreWindow;
2116 ecore_wl_window_parent_set(mEcoreWindow, ecoreParent);
2119 int WindowBaseEcoreWl::CreateFrameRenderedSyncFence()
2124 int WindowBaseEcoreWl::CreateFramePresentedSyncFence()
2129 void WindowBaseEcoreWl::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2133 void WindowBaseEcoreWl::InitializeIme()
2137 void WindowBaseEcoreWl::ImeWindowReadyToRender()
2141 void WindowBaseEcoreWl::RequestMoveToServer()
2145 void WindowBaseEcoreWl::RequestResizeToServer(WindowResizeDirection direction)
2149 void WindowBaseEcoreWl::EnableFloatingMode(bool enable)
2153 bool WindowBaseEcoreWl::IsFloatingModeEnabled() const
2158 void WindowBaseEcoreWl::IncludeInputRegion(const Rect<int>& inputRegion)
2162 void WindowBaseEcoreWl::ExcludeInputRegion(const Rect<int>& inputRegion)
2166 } // namespace Adaptor
2168 } // namespace Internal
2172 #pragma GCC diagnostic pop