2 * Copyright (c) 2023 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-wl2/window-base-ecore-wl2.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/integration-api/trace.h>
35 #include <dali/public-api/adaptor-framework/window-enumerations.h>
36 #include <dali/public-api/events/mouse-button.h>
37 #include <dali/public-api/object/any.h>
39 #if defined(VCONF_ENABLED)
40 #include <vconf-keys.h>
44 #include <wayland-egl-tizen.h>
54 #if defined(DEBUG_ENABLED)
55 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
58 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
61 * @brief Enumeration of location for window resized by display server.
63 enum class ResizeLocation
65 INVALID = 0, ///< Invalid value
66 TOP_LEFT = 5, ///< Start resizing window to the top-left edge.
67 LEFT = 4, ///< Start resizing window to the left side.
68 BOTTOM_LEFT = 6, ///< Start resizing window to the bottom-left edge.
69 BOTTOM = 2, ///< Start resizing window to the bottom side.
70 BOTTOM_RIGHT = 10, ///< Start resizing window to the bottom-right edge.
71 RIGHT = 8, ///< Start resizing window to the right side.
72 TOP_RIGHT = 9, ///< Start resizing window to the top-right edge.
73 TOP = 1 ///< Start resizing window to the top side.
76 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
77 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
78 const ResizeLocation RESIZE_LOCATIONS[] = {ResizeLocation::TOP_LEFT, ResizeLocation::LEFT, ResizeLocation::BOTTOM_LEFT, ResizeLocation::BOTTOM, ResizeLocation::BOTTOM_RIGHT, ResizeLocation::RIGHT, ResizeLocation::TOP_RIGHT, ResizeLocation::TOP, ResizeLocation::INVALID};
80 #if defined(VCONF_ENABLED)
81 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
87 xkb_keycode_t keyCode;
92 * Get the device name from the provided ecore key event
94 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
96 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
100 result = ecoreDeviceName;
105 * Get the device class from the provided ecore event
107 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
109 switch(ecoreDeviceClass)
111 case ECORE_DEVICE_CLASS_SEAT:
113 deviceClass = Device::Class::USER;
116 case ECORE_DEVICE_CLASS_KEYBOARD:
118 deviceClass = Device::Class::KEYBOARD;
121 case ECORE_DEVICE_CLASS_MOUSE:
123 deviceClass = Device::Class::MOUSE;
126 case ECORE_DEVICE_CLASS_TOUCH:
128 deviceClass = Device::Class::TOUCH;
131 case ECORE_DEVICE_CLASS_PEN:
133 deviceClass = Device::Class::PEN;
136 case ECORE_DEVICE_CLASS_POINTER:
138 deviceClass = Device::Class::POINTER;
141 case ECORE_DEVICE_CLASS_GAMEPAD:
143 deviceClass = Device::Class::GAMEPAD;
148 deviceClass = Device::Class::NONE;
154 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
156 switch(ecoreDeviceSubclass)
158 case ECORE_DEVICE_SUBCLASS_FINGER:
160 deviceSubclass = Device::Subclass::FINGER;
163 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
165 deviceSubclass = Device::Subclass::FINGERNAIL;
168 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
170 deviceSubclass = Device::Subclass::KNUCKLE;
173 case ECORE_DEVICE_SUBCLASS_PALM:
175 deviceSubclass = Device::Subclass::PALM;
178 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
180 deviceSubclass = Device::Subclass::HAND_SIDE;
183 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
185 deviceSubclass = Device::Subclass::HAND_FLAT;
188 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
190 deviceSubclass = Device::Subclass::PEN_TIP;
193 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
195 deviceSubclass = Device::Subclass::TRACKPAD;
198 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
200 deviceSubclass = Device::Subclass::TRACKPOINT;
203 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
205 deviceSubclass = Device::Subclass::TRACKBALL;
208 case ECORE_DEVICE_SUBCLASS_REMOCON:
210 deviceSubclass = Device::Subclass::REMOCON;
213 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
215 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
220 deviceSubclass = Device::Subclass::NONE;
226 void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
228 KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
229 if(foundKeyCode->isKeyCode)
234 xkb_keysym_t keySym = foundKeyCode->keySym;
236 const xkb_keysym_t* symsOut = NULL;
238 nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
242 if(*symsOut == keySym)
244 foundKeyCode->keyCode = key;
245 foundKeyCode->isKeyCode = true;
251 * Return the recalculated window resizing location according to the current orientation.
253 ResizeLocation RecalculateLocationToCurrentOrientation(WindowResizeDirection direction, int windowRotationAngle)
258 case WindowResizeDirection::TOP_LEFT:
263 case WindowResizeDirection::LEFT:
268 case WindowResizeDirection::BOTTOM_LEFT:
273 case WindowResizeDirection::BOTTOM:
278 case WindowResizeDirection::BOTTOM_RIGHT:
283 case WindowResizeDirection::RIGHT:
288 case WindowResizeDirection::TOP_RIGHT:
293 case WindowResizeDirection::TOP:
305 if(index != 8 && windowRotationAngle != 0)
307 index = (index + (windowRotationAngle / 90) * 2) % 8;
310 return RESIZE_LOCATIONS[index];
313 /////////////////////////////////////////////////////////////////////////////////////////////////
315 /////////////////////////////////////////////////////////////////////////////////////////////////
317 /// Called when the window iconify state is changed.
318 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
320 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
323 return windowBase->OnIconifyStateChanged(data, type, event);
326 return ECORE_CALLBACK_PASS_ON;
329 /// Called when the window gains focus
330 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
332 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
335 return windowBase->OnFocusIn(data, type, event);
338 return ECORE_CALLBACK_PASS_ON;
341 /// Called when the window loses focus
342 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
344 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
347 return windowBase->OnFocusOut(data, type, event);
350 return ECORE_CALLBACK_PASS_ON;
353 /// Called when the output is transformed
354 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
356 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
359 return windowBase->OnOutputTransform(data, type, event);
362 return ECORE_CALLBACK_PASS_ON;
365 /// Called when the output transform should be ignored
366 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
368 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
371 return windowBase->OnIgnoreOutputTransform(data, type, event);
374 return ECORE_CALLBACK_PASS_ON;
378 * Called when rotate event is recevied.
380 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
382 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
385 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
386 windowBase->OnRotation(data, type, event);
388 return ECORE_CALLBACK_PASS_ON;
392 * Called when configure event is recevied.
394 static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
396 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
399 windowBase->OnConfiguration(data, type, event);
401 return ECORE_CALLBACK_PASS_ON;
404 /////////////////////////////////////////////////////////////////////////////////////////////////
406 /////////////////////////////////////////////////////////////////////////////////////////////////
409 * Called when a touch down is received.
411 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
413 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
416 windowBase->OnMouseButtonDown(data, type, event);
418 return ECORE_CALLBACK_PASS_ON;
422 * Called when a touch up is received.
424 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
426 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
429 windowBase->OnMouseButtonUp(data, type, event);
431 return ECORE_CALLBACK_PASS_ON;
435 * Called when a touch motion is received.
437 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
439 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
442 windowBase->OnMouseButtonMove(data, type, event);
444 return ECORE_CALLBACK_PASS_ON;
448 * Called when a touch is canceled.
450 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
452 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
455 windowBase->OnMouseButtonCancel(data, type, event);
457 return ECORE_CALLBACK_PASS_ON;
461 * Called when a mouse wheel is received.
463 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
465 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
468 windowBase->OnMouseWheel(data, type, event);
470 return ECORE_CALLBACK_PASS_ON;
474 * Called when a mouse in is received.
476 static Eina_Bool EcoreEventMouseIn(void* data, int type, void* event)
478 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
481 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::IN);
483 return ECORE_CALLBACK_PASS_ON;
487 * Called when a mouse out is received.
489 static Eina_Bool EcoreEventMouseOut(void* data, int type, void* event)
491 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
494 // When the mouse is out, the previous mouse must be canceled.
495 windowBase->OnMouseButtonCancel(data, type, event);
496 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::OUT);
498 return ECORE_CALLBACK_PASS_ON;
502 * Called when a detent rotation event is recevied.
504 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
506 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
509 windowBase->OnDetentRotation(data, type, event);
511 return ECORE_CALLBACK_PASS_ON;
514 /////////////////////////////////////////////////////////////////////////////////////////////////
516 /////////////////////////////////////////////////////////////////////////////////////////////////
519 * Called when a key down is received.
521 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
523 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
526 windowBase->OnKeyDown(data, type, event);
528 return ECORE_CALLBACK_PASS_ON;
532 * Called when a key up is received.
534 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
536 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
539 windowBase->OnKeyUp(data, type, event);
541 return ECORE_CALLBACK_PASS_ON;
544 /////////////////////////////////////////////////////////////////////////////////////////////////
545 // Selection Callbacks
546 /////////////////////////////////////////////////////////////////////////////////////////////////
549 * Called when the source window notifies us the content in clipboard is selected.
551 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
553 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
556 windowBase->OnDataSend(data, type, event);
558 return ECORE_CALLBACK_PASS_ON;
562 * Called when the source window sends us about the selected content.
563 * For example, when item is selected in the clipboard.
565 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
567 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
570 windowBase->OnDataReceive(data, type, event);
572 return ECORE_CALLBACK_PASS_ON;
575 /////////////////////////////////////////////////////////////////////////////////////////////////
576 // Effect Start/End Callbacks
577 /////////////////////////////////////////////////////////////////////////////////////////////////
580 * Called when transition animation of the window's shown/hidden is started by window manager.
582 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
584 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
585 Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
586 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
589 if(effectStart->type < 3) // only under restack
591 windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
594 return ECORE_CALLBACK_PASS_ON;
598 * Called when transition animation of the window's shown/hidden is ended by window manager.
600 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
602 Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
603 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
604 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
607 if(effectEnd->type < 3) // only under restack
609 windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
612 return ECORE_CALLBACK_PASS_ON;
615 /////////////////////////////////////////////////////////////////////////////////////////////////
616 // Keyboard Repeat Settings Changed Callbacks
617 /////////////////////////////////////////////////////////////////////////////////////////////////
619 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
621 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
622 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event)->id);
625 windowBase->OnKeyboardRepeatSettingsChanged();
628 return ECORE_CALLBACK_RENEW;
631 /////////////////////////////////////////////////////////////////////////////////////////////////
632 // Keymap Changed Callbacks
633 /////////////////////////////////////////////////////////////////////////////////////////////////
635 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
637 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
640 windowBase->KeymapChanged(data, type, event);
643 return ECORE_CALLBACK_RENEW;
646 /////////////////////////////////////////////////////////////////////////////////////////////////
648 /////////////////////////////////////////////////////////////////////////////////////////////////
650 #if defined(VCONF_ENABLED)
652 * Called when a font name is changed.
654 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
656 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
659 windowBase->OnFontNameChanged();
664 * Called when a font size is changed.
666 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
668 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
671 windowBase->OnFontSizeChanged();
676 /////////////////////////////////////////////////////////////////////////////////////////////////
677 // Window Redraw Request Event Callbacks
678 /////////////////////////////////////////////////////////////////////////////////////////////////
680 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
682 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
683 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event)->win);
686 windowBase->OnEcoreEventWindowRedrawRequest();
689 return ECORE_CALLBACK_RENEW;
692 /////////////////////////////////////////////////////////////////////////////////////////////////
693 // Window Auxiliary Message Callbacks
694 /////////////////////////////////////////////////////////////////////////////////////////////////
695 static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* event)
697 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
700 windowBase->OnEcoreEventWindowAuxiliaryMessage(event);
702 return ECORE_CALLBACK_RENEW;
705 /////////////////////////////////////////////////////////////////////////////////////////////////
706 // Window is Moved/Resized By Server Callbacks
707 /////////////////////////////////////////////////////////////////////////////////////////////////
708 static Eina_Bool EcoreEventWindowMoveCompleted(void* data, int type, void* event)
710 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
713 windowBase->OnMoveCompleted(event);
715 return ECORE_CALLBACK_RENEW;
718 static Eina_Bool EcoreEventWindowResizeCompleted(void* data, int type, void* event)
720 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
723 windowBase->OnResizeCompleted(event);
725 return ECORE_CALLBACK_RENEW;
728 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
730 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
733 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
737 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
739 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
742 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
746 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
750 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)
754 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
756 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
759 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
763 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
767 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
769 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
772 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
776 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
780 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
784 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
788 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
792 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)
796 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
798 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
801 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
805 const struct wl_registry_listener registryListener =
807 RegistryGlobalCallback,
808 RegistryGlobalCallbackRemove};
810 const struct tizen_policy_listener tizenPolicyListener =
812 TizenPolicyConformant,
813 TizenPolicyConformantArea,
814 TizenPolicyNotificationChangeDone,
815 TizenPolicyTransientForDone,
816 TizenPolicyScreenModeChangeDone,
817 TizenPolicyIconifyStateChanged,
818 TizenPolicySupportedAuxiliaryHints,
819 TizenPolicyAllowedAuxiliaryHint,
820 TizenPolicyAuxiliaryMessage,
821 TizenPolicyConformantRegion};
823 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
825 DisplayPolicyBrightnessChangeDone};
827 } // unnamed namespace
829 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
830 : mEcoreEventHandler(),
831 mEcoreWindow(nullptr),
833 mWlInputPanel(nullptr),
835 mWlInputPanelSurface(nullptr),
838 mEventQueue(nullptr),
839 mTizenPolicy(nullptr),
840 mTizenDisplayPolicy(nullptr),
842 mSupportedAuxiliaryHints(),
843 mWindowPositionSize(positionSize),
845 mType(WindowType::NORMAL),
846 mNotificationLevel(-1),
849 mWindowRotationAngle(0),
850 mScreenRotationAngle(0),
851 mSupportedPreProtation(0),
852 mNotificationChangeState(0),
853 mScreenOffModeChangeState(0),
854 mBrightnessChangeState(0),
855 mLastSubmittedMoveResizeSerial(0),
856 mMoveResizeSerial(0),
857 mNotificationLevelChangeDone(true),
858 mScreenOffModeChangeDone(true),
861 mBrightnessChangeDone(true)
863 Initialize(positionSize, surface, isTransparent);
866 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
868 #if defined(VCONF_ENABLED)
869 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
870 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
873 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
875 ecore_event_handler_del(*iter);
877 mEcoreEventHandler.Clear();
881 wl_event_queue_destroy(mEventQueue);
884 mSupportedAuxiliaryHints.clear();
885 mAuxiliaryHints.clear();
887 if(mEglWindow != NULL)
889 wl_egl_window_destroy(mEglWindow);
895 ecore_wl2_window_free(mEcoreWindow);
899 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
901 if(surface.Empty() == false)
903 // check we have a valid type
904 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
906 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
910 // we own the surface about to created
912 CreateWindow(positionSize);
915 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
917 SetTransparency(isTransparent);
919 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
920 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
921 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
922 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
923 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
925 // Register Rotate event
926 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
928 // Register Configure event
929 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
931 // Register Touch events
932 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
933 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
934 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
935 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
937 // Register Mouse wheel events
938 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
940 // Register Mouse IO events
941 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
942 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
944 // Register Detent event
945 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
947 // Register Key events
948 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
949 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
951 // Register Selection event - clipboard selection
952 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
953 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
955 // Register Effect Start/End event
956 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
957 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
959 // Register Keyboard repeat event
960 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
962 // Register Window redraw request event
963 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
965 // Register Window auxiliary event
966 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
968 #if defined(VCONF_ENABLED)
969 // Register Vconf notify - font name and size
970 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
971 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
974 // Register Window is moved and resized done event.
975 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE, EcoreEventWindowMoveCompleted, this));
976 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE, EcoreEventWindowResizeCompleted, this));
978 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
979 mDisplay = ecore_wl2_display_get(display);
983 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
986 mEventQueue = wl_display_create_queue(mDisplay);
989 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
991 wl_registry* registry = wl_display_get_registry(displayWrapper);
992 wl_registry_add_listener(registry, ®istryListener, this);
995 wl_proxy_wrapper_destroy(displayWrapper);
999 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
1003 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1005 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
1008 // get auxiliary hint
1009 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
1012 Eina_List* l = NULL;
1015 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))))
1017 mSupportedAuxiliaryHints.push_back(hint);
1019 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
1024 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
1026 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
1027 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
1029 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1031 if(iconifyChangedEvent->iconified == EINA_TRUE)
1033 mIconifyChangedSignal.Emit(true);
1037 mIconifyChangedSignal.Emit(false);
1039 handled = ECORE_CALLBACK_DONE;
1045 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
1047 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
1049 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1051 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
1053 mFocusChangedSignal.Emit(true);
1056 return ECORE_CALLBACK_PASS_ON;
1059 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
1061 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
1063 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1065 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
1067 mFocusChangedSignal.Emit(false);
1070 return ECORE_CALLBACK_PASS_ON;
1073 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
1075 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
1077 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
1079 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
1081 mScreenRotationAngle = GetScreenRotationAngle();
1083 mOutputTransformedSignal.Emit();
1086 return ECORE_CALLBACK_PASS_ON;
1089 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
1091 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
1093 if(ignoreTransformEvent->win == mEcoreWindow)
1095 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
1097 mScreenRotationAngle = GetScreenRotationAngle();
1099 mOutputTransformedSignal.Emit();
1102 return ECORE_CALLBACK_PASS_ON;
1105 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
1107 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
1109 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1111 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
1113 RotationEvent rotationEvent;
1114 rotationEvent.angle = ev->angle;
1115 rotationEvent.winResize = 0;
1117 if(ev->w == 0 || ev->h == 0)
1119 // When rotation event does not have the window width or height,
1120 // previous DALi side window's size are used.
1121 ev->w = mWindowPositionSize.width;
1122 ev->h = mWindowPositionSize.height;
1125 mWindowRotationAngle = ev->angle;
1127 mWindowPositionSize.width = ev->w;
1128 mWindowPositionSize.height = ev->h;
1130 PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1132 rotationEvent.x = newPositionSize.x;
1133 rotationEvent.y = newPositionSize.y;
1134 rotationEvent.width = newPositionSize.width;
1135 rotationEvent.height = newPositionSize.height;
1137 mRotationSignal.Emit(rotationEvent);
1141 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1143 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1145 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1147 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1148 // by calling ecore_wl2_window_commit
1150 int tempWidth = ev->w;
1151 int tempHeight = ev->h;
1153 // Initialize with previous size for skip resize when new size is 0.
1154 // When window is just moved or window is resized by client application,
1155 // The configure notification event's size will be 0.
1156 // If new size is 0, the resized work should be skip.
1157 int newWidth = mWindowPositionSize.width;
1158 int newHeight = mWindowPositionSize.height;
1159 bool windowMoved = false, windowResized = false;
1161 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1166 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1168 windowResized = true;
1169 newWidth = tempWidth;
1170 newHeight = tempHeight;
1173 if(windowMoved || windowResized)
1175 mWindowPositionSize.x = ev->x;
1176 mWindowPositionSize.y = ev->y;
1177 mWindowPositionSize.width = newWidth;
1178 mWindowPositionSize.height = newHeight;
1179 DALI_LOG_RELEASE_INFO("Update position & resize signal by server, current angle [%d] x[%d] y[%d] w[%d] h[%d]\n", mWindowRotationAngle, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1181 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1183 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1184 mUpdatePositionSizeSignal.Emit(newPositionSize);
1187 mMaximizeChangedSignal.Emit(static_cast<bool>(ev->states & ECORE_WL2_WINDOW_STATE_MAXIMIZED));
1189 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1193 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1195 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1197 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1199 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
1201 Device::Class::Type deviceClass;
1202 Device::Subclass::Type deviceSubclass;
1204 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1205 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1207 PointState::Type state(PointState::DOWN);
1209 if(deviceClass != Device::Class::Type::MOUSE)
1211 // Check if the buttons field is set and ensure it's the primary touch button.
1212 // If this event was triggered by buttons other than the primary button (used for touch), then
1213 // just send an interrupted event to Core.
1214 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1216 state = PointState::INTERRUPTED;
1220 Integration::Point point;
1221 point.SetDeviceId(touchEvent->multi.device);
1222 point.SetState(state);
1223 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1224 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1225 point.SetPressure(touchEvent->multi.pressure);
1226 point.SetAngle(Degree(touchEvent->multi.angle));
1227 point.SetDeviceClass(deviceClass);
1228 point.SetDeviceSubclass(deviceSubclass);
1229 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1231 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1235 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1237 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1239 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1241 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
1243 Device::Class::Type deviceClass;
1244 Device::Subclass::Type deviceSubclass;
1246 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1247 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1249 Integration::Point point;
1250 point.SetDeviceId(touchEvent->multi.device);
1251 point.SetState(PointState::UP);
1252 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1253 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1254 point.SetPressure(touchEvent->multi.pressure);
1255 point.SetAngle(Degree(touchEvent->multi.angle));
1256 point.SetDeviceClass(deviceClass);
1257 point.SetDeviceSubclass(deviceSubclass);
1258 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1260 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1264 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1266 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1268 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1270 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
1272 Device::Class::Type deviceClass;
1273 Device::Subclass::Type deviceSubclass;
1275 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1276 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1278 Integration::Point point;
1279 point.SetDeviceId(touchEvent->multi.device);
1280 point.SetState(PointState::MOTION);
1281 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1282 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1283 point.SetPressure(touchEvent->multi.pressure);
1284 point.SetAngle(Degree(touchEvent->multi.angle));
1285 point.SetDeviceClass(deviceClass);
1286 point.SetDeviceSubclass(deviceSubclass);
1288 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1292 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1294 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1296 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1298 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
1300 Integration::Point point;
1301 point.SetDeviceId(touchEvent->multi.device);
1302 point.SetState(PointState::INTERRUPTED);
1303 point.SetScreenPosition(Vector2(0.0f, 0.0f));
1305 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1307 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1311 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1313 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1315 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1317 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
1319 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
1321 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1323 mWheelEventSignal.Emit(wheelEvent);
1327 void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
1329 Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
1331 if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1333 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
1335 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseInOut: timestamp: %d, modifiers: %d, x: %d, y: %d\n", mouseInOutEvent->timestamp, mouseInOutEvent->modifiers, mouseInOutEvent->x, mouseInOutEvent->y);
1337 Device::Class::Type deviceClass;
1338 Device::Subclass::Type deviceSubclass;
1340 GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
1341 GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
1343 Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
1345 mMouseInOutEventSignal.Emit(inOutEvent);
1349 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1351 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1353 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1355 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1357 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1359 mWheelEventSignal.Emit(wheelEvent);
1362 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1364 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1366 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1368 std::string keyName(keyEvent->keyname);
1369 std::string logicalKey("");
1370 std::string keyString("");
1371 std::string compose("");
1373 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_DOWN");
1375 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1376 if(keyEvent->compose)
1378 compose = keyEvent->compose;
1381 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1384 logicalKey = keyEvent->key;
1388 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1392 // Get a specific key code from dali key look up table.
1393 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1396 keyCode = (keyCode == -1) ? 0 : keyCode;
1397 int modifier(keyEvent->modifiers);
1398 unsigned long time = keyEvent->timestamp;
1399 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1401 keyCode = atoi(keyEvent->keyname + 8);
1404 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1405 if(keyEvent->string)
1407 keyString = keyEvent->string;
1410 std::string deviceName;
1411 Device::Class::Type deviceClass;
1412 Device::Subclass::Type deviceSubclass;
1414 GetDeviceName(keyEvent, deviceName);
1415 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1416 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1418 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1420 mKeyEventSignal.Emit(keyEvent);
1424 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1426 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1428 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1430 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1431 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1432 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1434 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1437 #endif // Since ecore 1.23 version
1439 std::string keyName(keyEvent->keyname);
1440 std::string logicalKey("");
1441 std::string keyString("");
1442 std::string compose("");
1444 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_UP");
1446 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1447 if(keyEvent->compose)
1449 compose = keyEvent->compose;
1452 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1455 logicalKey = keyEvent->key;
1459 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1463 // Get a specific key code from dali key look up table.
1464 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1467 keyCode = (keyCode == -1) ? 0 : keyCode;
1468 int modifier(keyEvent->modifiers);
1469 unsigned long time = keyEvent->timestamp;
1470 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1472 keyCode = atoi(keyEvent->keyname + 8);
1475 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1476 if(keyEvent->string)
1478 keyString = keyEvent->string;
1481 std::string deviceName;
1482 Device::Class::Type deviceClass;
1483 Device::Subclass::Type deviceSubclass;
1485 GetDeviceName(keyEvent, deviceName);
1486 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1487 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1489 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1491 mKeyEventSignal.Emit(keyEvent);
1495 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1497 mSelectionDataSendSignal.Emit(event);
1500 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1502 mSelectionDataReceivedSignal.Emit(event);
1505 void WindowBaseEcoreWl2::OnFontNameChanged()
1507 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1510 void WindowBaseEcoreWl2::OnFontSizeChanged()
1512 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1515 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1517 mTransitionEffectEventSignal.Emit(state, type);
1520 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1522 mKeyboardRepeatSettingsChangedSignal.Emit();
1525 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1527 mWindowRedrawRequestSignal.Emit();
1530 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1532 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1535 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
1536 std::string key(message->key);
1537 std::string value(message->val);
1538 Dali::Property::Array options;
1540 if(message->options)
1544 EINA_LIST_FOREACH(message->options, l, data)
1546 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
1547 std::string option(static_cast<char*>(data));
1548 options.Add(option);
1552 mAuxiliaryMessageSignal.Emit(key, value, options);
1556 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1558 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1559 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1560 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1563 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1567 void WindowBaseEcoreWl2::OnMoveCompleted(void* event)
1569 Ecore_Wl2_Event_Window_Interactive_Move_Done* movedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Move_Done*>(event);
1572 Dali::PositionSize orgPositionSize(movedDoneEvent->x, movedDoneEvent->y, movedDoneEvent->w, movedDoneEvent->h);
1573 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1574 Dali::Int32Pair newPosition(newPositionSize.x, newPositionSize.y);
1575 DALI_LOG_RELEASE_INFO("window(%p) has been moved by server[%d, %d]\n", mEcoreWindow, newPositionSize.x, newPositionSize.y);
1576 mMoveCompletedSignal.Emit(newPosition);
1580 void WindowBaseEcoreWl2::OnResizeCompleted(void* event)
1582 Ecore_Wl2_Event_Window_Interactive_Resize_Done* resizedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Resize_Done*>(event);
1583 if(resizedDoneEvent)
1585 Dali::PositionSize orgPositionSize(resizedDoneEvent->x, resizedDoneEvent->y, resizedDoneEvent->w, resizedDoneEvent->h);
1586 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1587 Dali::Uint16Pair newSize(newPositionSize.width, newPositionSize.height);
1588 DALI_LOG_RELEASE_INFO("window(%p) has been resized by server[%d, %d]\n", mEcoreWindow, newPositionSize.width, newPositionSize.height);
1589 mResizeCompletedSignal.Emit(newSize);
1593 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1595 if(strcmp(interface, tizen_policy_interface.name) == 0)
1597 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1599 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1602 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1606 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1608 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1610 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1612 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1613 if(!mTizenDisplayPolicy)
1615 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1619 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1621 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1625 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1627 mTizenPolicy = NULL;
1628 mTizenDisplayPolicy = NULL;
1631 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1633 mNotificationLevel = level;
1634 mNotificationChangeState = state;
1635 mNotificationLevelChangeDone = true;
1637 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1640 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1642 mScreenOffMode = mode;
1643 mScreenOffModeChangeState = state;
1644 mScreenOffModeChangeDone = true;
1646 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1649 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1651 mBrightness = brightness;
1652 mBrightnessChangeState = state;
1653 mBrightnessChangeDone = true;
1655 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1658 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1660 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1661 KeyCodeMap foundKeyCode;
1663 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1664 if(sym == XKB_KEY_NoSymbol)
1666 DALI_LOG_ERROR("Failed to get keysym in WindowBaseEcoreWl2\n");
1670 foundKeyCode.keySym = sym;
1671 foundKeyCode.isKeyCode = false;
1672 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1673 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1676 Any WindowBaseEcoreWl2::GetNativeWindow()
1678 return mEcoreWindow;
1681 int WindowBaseEcoreWl2::GetNativeWindowId()
1683 return ecore_wl2_window_id_get(mEcoreWindow);
1686 std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
1688 #ifdef OVER_TIZEN_VERSION_7
1689 return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
1691 return std::string();
1695 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1697 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1698 if(totalAngle == 90 || totalAngle == 270)
1700 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
1704 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1707 return static_cast<EGLNativeWindowType>(mEglWindow);
1710 void WindowBaseEcoreWl2::DestroyEglWindow()
1712 if(mEglWindow != NULL)
1714 wl_egl_window_destroy(mEglWindow);
1719 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
1721 wl_egl_window_tizen_rotation rotation;
1727 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1732 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1737 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1742 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1747 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1752 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
1755 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
1757 wl_output_transform bufferTransform;
1763 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1768 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1773 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1778 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1783 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1788 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_buffer_transform() with buffer Transform [%d]\n", bufferTransform);
1789 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
1792 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
1794 wl_output_transform windowTransform;
1800 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1805 windowTransform = WL_OUTPUT_TRANSFORM_90;
1810 windowTransform = WL_OUTPUT_TRANSFORM_180;
1815 windowTransform = WL_OUTPUT_TRANSFORM_270;
1820 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1825 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_window_transform() with window Transform [%d]\n", windowTransform);
1826 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
1829 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
1831 DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1832 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1834 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1835 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
1837 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
1838 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1842 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1845 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
1846 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
1848 mSupportedPreProtation = true;
1851 mSupportedPreProtation = false;
1855 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
1857 PositionSize newPositionSize;
1858 int32_t screenWidth, screenHeight;
1859 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1861 if(mWindowRotationAngle == 90)
1863 newPositionSize.x = positionSize.y;
1864 newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
1865 newPositionSize.width = positionSize.height;
1866 newPositionSize.height = positionSize.width;
1868 else if(mWindowRotationAngle == 180)
1870 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1871 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1872 newPositionSize.width = positionSize.width;
1873 newPositionSize.height = positionSize.height;
1875 else if(mWindowRotationAngle == 270)
1877 newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
1878 newPositionSize.y = positionSize.x;
1879 newPositionSize.width = positionSize.height;
1880 newPositionSize.height = positionSize.width;
1884 newPositionSize.x = positionSize.x;
1885 newPositionSize.y = positionSize.y;
1886 newPositionSize.width = positionSize.width;
1887 newPositionSize.height = positionSize.height;
1890 return newPositionSize;
1893 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
1895 PositionSize newPositionSize;
1896 int32_t screenWidth, screenHeight;
1897 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1899 if(mWindowRotationAngle == 90)
1901 newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
1902 newPositionSize.y = positionSize.x;
1903 newPositionSize.width = positionSize.height;
1904 newPositionSize.height = positionSize.width;
1906 else if(mWindowRotationAngle == 180)
1908 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1909 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1910 newPositionSize.width = positionSize.width;
1911 newPositionSize.height = positionSize.height;
1913 else if(mWindowRotationAngle == 270)
1915 newPositionSize.x = positionSize.y;
1916 newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
1917 newPositionSize.width = positionSize.height;
1918 newPositionSize.height = positionSize.width;
1922 newPositionSize.x = positionSize.x;
1923 newPositionSize.y = positionSize.y;
1924 newPositionSize.width = positionSize.width;
1925 newPositionSize.height = positionSize.height;
1928 return newPositionSize;
1931 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
1933 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1935 mWindowPositionSize = newPositionSize;
1936 DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
1937 ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
1940 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
1942 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1944 mWindowPositionSize = newPositionSize;
1945 DALI_LOG_RELEASE_INFO("ecore_wl2_window_sync_geometry_set, x[%d], y[%d], w{%d], h[%d]\n", newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1946 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1949 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
1951 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1953 mWindowPositionSize = newPositionSize;
1954 DALI_LOG_RELEASE_INFO("ecore_wl2_window_sync_geometry_set, x[%d], y[%d], w{%d], h[%d]\n", newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1955 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1958 void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
1960 DALI_LOG_RELEASE_INFO("ecore_wl2_window_layout_set, numCols[%d], numRows[%d], column[%d], row[%d], colSpan[%d], rowSpan[%d]\n", numCols, numRows, column, row, colSpan, rowSpan);
1961 ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
1964 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
1966 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
1967 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
1970 void WindowBaseEcoreWl2::Raise()
1972 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1973 ecore_wl2_window_activate(mEcoreWindow);
1976 void WindowBaseEcoreWl2::Lower()
1978 ecore_wl2_window_lower(mEcoreWindow);
1981 void WindowBaseEcoreWl2::Activate()
1983 ecore_wl2_window_activate(mEcoreWindow);
1986 void WindowBaseEcoreWl2::Maximize(bool maximize)
1988 ecore_wl2_window_maximized_set(mEcoreWindow, maximize);
1991 bool WindowBaseEcoreWl2::IsMaximized() const
1993 return ecore_wl2_window_maximized_get(mEcoreWindow);
1996 void WindowBaseEcoreWl2::SetMaximumSize(Dali::Window::WindowSize size)
1998 DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
1999 ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2000 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2003 void WindowBaseEcoreWl2::Minimize(bool minimize)
2005 ecore_wl2_window_iconified_set(mEcoreWindow, minimize);
2008 bool WindowBaseEcoreWl2::IsMinimized() const
2010 return ecore_wl2_window_iconified_get(mEcoreWindow);
2013 void WindowBaseEcoreWl2::SetMimimumSize(Dali::Window::WindowSize size)
2015 DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2016 ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2017 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2020 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
2022 int rotations[4] = {0};
2023 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
2024 for(std::size_t i = 0; i < angles.size(); ++i)
2026 rotations[i] = static_cast<int>(angles[i]);
2027 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
2029 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
2032 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
2034 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
2035 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
2038 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
2040 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
2043 void WindowBaseEcoreWl2::Show()
2047 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
2051 ecore_wl2_window_show(mEcoreWindow);
2054 void WindowBaseEcoreWl2::Hide()
2057 ecore_wl2_window_hide(mEcoreWindow);
2060 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
2062 return mSupportedAuxiliaryHints.size();
2065 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
2067 if(index >= GetSupportedAuxiliaryHintCount())
2069 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
2072 return mSupportedAuxiliaryHints[index];
2075 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
2077 bool supported = false;
2079 // Check if the hint is suppported
2080 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
2091 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
2095 // Check if the hint is already added
2096 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2098 if(mAuxiliaryHints[i].first == hint)
2100 // Just change the value
2101 mAuxiliaryHints[i].second = value;
2103 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
2105 return i + 1; // id is index + 1
2110 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
2112 unsigned int id = mAuxiliaryHints.size();
2114 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
2116 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
2121 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
2123 if(id == 0 || id > mAuxiliaryHints.size())
2125 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
2129 mAuxiliaryHints[id - 1].second = std::string();
2131 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
2133 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
2138 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
2140 if(id == 0 || id > mAuxiliaryHints.size())
2142 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
2146 mAuxiliaryHints[id - 1].second = value;
2148 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
2150 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
2155 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
2157 if(id == 0 || id > mAuxiliaryHints.size())
2159 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
2160 return std::string();
2163 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
2165 return mAuxiliaryHints[id - 1].second;
2168 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
2170 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2172 if(mAuxiliaryHints[i].first == hint)
2174 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
2179 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
2184 Rect<int> WindowBaseEcoreWl2::RecalculateInputRect(const Rect<int>& rect)
2188 if(mWindowRotationAngle == 90)
2191 newRect.y = mWindowPositionSize.height - (rect.x + rect.width);
2192 newRect.width = rect.height;
2193 newRect.height = rect.width;
2195 else if(mWindowRotationAngle == 180)
2197 newRect.x = mWindowPositionSize.width - (rect.x + rect.width);
2198 newRect.y = mWindowPositionSize.height - (rect.y + rect.height);
2199 newRect.width = rect.width;
2200 newRect.height = rect.height;
2202 else if(mWindowRotationAngle == 270)
2204 newRect.x = mWindowPositionSize.width - (rect.y + rect.height);
2206 newRect.width = rect.height;
2207 newRect.height = rect.width;
2213 newRect.width = rect.width;
2214 newRect.height = rect.height;
2219 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
2221 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
2223 Eina_Rectangle rect;
2224 rect.x = convertRegion.x;
2225 rect.y = convertRegion.y;
2226 rect.w = convertRegion.width;
2227 rect.h = convertRegion.height;
2229 DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2230 ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
2231 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2234 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
2239 Ecore_Wl2_Window_Type windowType;
2243 case Dali::WindowType::NORMAL:
2245 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2248 case Dali::WindowType::NOTIFICATION:
2250 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
2253 case Dali::WindowType::UTILITY:
2255 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
2258 case Dali::WindowType::DIALOG:
2260 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
2263 case Dali::WindowType::IME:
2265 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
2268 case Dali::WindowType::DESKTOP:
2270 windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
2275 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2279 ecore_wl2_window_type_set(mEcoreWindow, windowType);
2283 Dali::WindowType WindowBaseEcoreWl2::GetType() const
2288 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
2290 while(!mTizenPolicy)
2292 wl_display_dispatch_queue(mDisplay, mEventQueue);
2295 int notificationLevel;
2299 case Dali::WindowNotificationLevel::NONE:
2301 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
2304 case Dali::WindowNotificationLevel::BASE:
2306 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2309 case Dali::WindowNotificationLevel::MEDIUM:
2311 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
2314 case Dali::WindowNotificationLevel::HIGH:
2316 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
2319 case Dali::WindowNotificationLevel::TOP:
2321 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
2326 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
2327 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2332 mNotificationLevelChangeDone = false;
2333 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2335 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2339 while(!mNotificationLevelChangeDone && count < 3)
2341 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2342 wl_display_dispatch_queue(mDisplay, mEventQueue);
2346 if(!mNotificationLevelChangeDone)
2348 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2349 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2351 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2353 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2354 return Dali::WindowOperationResult::PERMISSION_DENIED;
2357 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2359 return Dali::WindowOperationResult::SUCCEED;
2362 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2364 while(!mTizenPolicy)
2366 wl_display_dispatch_queue(mDisplay, mEventQueue);
2371 while(!mNotificationLevelChangeDone && count < 3)
2373 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2374 wl_display_dispatch_queue(mDisplay, mEventQueue);
2378 if(!mNotificationLevelChangeDone)
2380 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2381 return Dali::WindowNotificationLevel::NONE;
2384 Dali::WindowNotificationLevel level;
2386 switch(mNotificationLevel)
2388 case TIZEN_POLICY_LEVEL_NONE:
2390 level = Dali::WindowNotificationLevel::NONE;
2393 case TIZEN_POLICY_LEVEL_DEFAULT:
2395 level = Dali::WindowNotificationLevel::BASE;
2398 case TIZEN_POLICY_LEVEL_MEDIUM:
2400 level = Dali::WindowNotificationLevel::MEDIUM;
2403 case TIZEN_POLICY_LEVEL_HIGH:
2405 level = Dali::WindowNotificationLevel::HIGH;
2408 case TIZEN_POLICY_LEVEL_TOP:
2410 level = Dali::WindowNotificationLevel::TOP;
2415 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2416 level = Dali::WindowNotificationLevel::NONE;
2421 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2426 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2428 while(!mTizenPolicy)
2430 wl_display_dispatch_queue(mDisplay, mEventQueue);
2433 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2436 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2438 while(!mTizenPolicy)
2440 wl_display_dispatch_queue(mDisplay, mEventQueue);
2443 mScreenOffModeChangeDone = false;
2444 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2446 unsigned int mode = 0;
2448 switch(screenOffMode)
2450 case WindowScreenOffMode::TIMEOUT:
2455 case WindowScreenOffMode::NEVER:
2462 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2466 while(!mScreenOffModeChangeDone && count < 3)
2468 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2469 wl_display_dispatch_queue(mDisplay, mEventQueue);
2473 if(!mScreenOffModeChangeDone)
2475 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2476 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2478 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2480 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2481 return Dali::WindowOperationResult::PERMISSION_DENIED;
2484 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2486 return Dali::WindowOperationResult::SUCCEED;
2489 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2491 while(!mTizenPolicy)
2493 wl_display_dispatch_queue(mDisplay, mEventQueue);
2498 while(!mScreenOffModeChangeDone && count < 3)
2500 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2501 wl_display_dispatch_queue(mDisplay, mEventQueue);
2505 if(!mScreenOffModeChangeDone)
2507 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2508 return WindowScreenOffMode::TIMEOUT;
2511 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2513 switch(mScreenOffMode)
2517 screenMode = WindowScreenOffMode::TIMEOUT;
2522 screenMode = WindowScreenOffMode::NEVER;
2527 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2532 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2534 while(!mTizenDisplayPolicy)
2536 wl_display_dispatch_queue(mDisplay, mEventQueue);
2539 mBrightnessChangeDone = false;
2540 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2542 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2546 while(!mBrightnessChangeDone && count < 3)
2548 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2549 wl_display_dispatch_queue(mDisplay, mEventQueue);
2553 if(!mBrightnessChangeDone)
2555 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2556 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2558 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2560 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2561 return Dali::WindowOperationResult::PERMISSION_DENIED;
2564 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2566 return Dali::WindowOperationResult::SUCCEED;
2569 int WindowBaseEcoreWl2::GetBrightness() const
2571 while(!mTizenDisplayPolicy)
2573 wl_display_dispatch_queue(mDisplay, mEventQueue);
2578 while(!mBrightnessChangeDone && count < 3)
2580 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2581 wl_display_dispatch_queue(mDisplay, mEventQueue);
2585 if(!mBrightnessChangeDone)
2587 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2591 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2596 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2598 Ecore_Wl2_Window_Keygrab_Mode mode;
2602 case KeyGrab::TOPMOST:
2604 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2607 case KeyGrab::SHARED:
2609 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2612 case KeyGrab::OVERRIDE_EXCLUSIVE:
2614 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2617 case KeyGrab::EXCLUSIVE:
2619 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2628 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2631 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2633 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2636 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2638 int keyCount = key.Count();
2639 int keyGrabModeCount = grabMode.Count();
2641 if(keyCount != keyGrabModeCount || keyCount == 0)
2648 Eina_List* keyList = NULL;
2649 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2651 for(int index = 0; index < keyCount; ++index)
2653 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2655 switch(grabMode[index])
2657 case KeyGrab::TOPMOST:
2659 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2662 case KeyGrab::SHARED:
2664 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2667 case KeyGrab::OVERRIDE_EXCLUSIVE:
2669 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2672 case KeyGrab::EXCLUSIVE:
2674 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2679 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2684 keyList = eina_list_append(keyList, &info);
2687 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
2689 result.Resize(keyCount, true);
2691 Eina_List* l = NULL;
2692 Eina_List* m = NULL;
2693 void* listData = NULL;
2695 if(grabList != NULL)
2697 EINA_LIST_FOREACH(grabList, m, data)
2700 EINA_LIST_FOREACH(keyList, l, listData)
2702 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
2704 DALI_LOG_ERROR("input key list has null data!");
2708 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2710 result[index] = false;
2719 eina_list_free(keyList);
2720 eina_list_free(grabList);
2726 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
2728 int keyCount = key.Count();
2736 Eina_List* keyList = NULL;
2737 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2739 for(int index = 0; index < keyCount; ++index)
2741 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2742 keyList = eina_list_append(keyList, &info);
2745 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
2747 result.Resize(keyCount, true);
2749 Eina_List* l = NULL;
2750 Eina_List* m = NULL;
2751 void* listData = NULL;
2754 if(ungrabList != NULL)
2756 EINA_LIST_FOREACH(ungrabList, m, data)
2759 EINA_LIST_FOREACH(keyList, l, listData)
2761 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2763 result[index] = false;
2772 eina_list_free(keyList);
2773 eina_list_free(ungrabList);
2779 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2784 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
2786 // 1 inch = 25.4 millimeters
2787 xres = ecore_wl2_output_dpi_get(output);
2788 yres = ecore_wl2_output_dpi_get(output);
2790 dpiHorizontal = int(xres + 0.5f); // rounding
2791 dpiVertical = int(yres + 0.5f);
2794 int WindowBaseEcoreWl2::GetWindowRotationAngle() const
2796 int orientation = mWindowRotationAngle;
2797 if(mSupportedPreProtation)
2804 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2806 if(mSupportedPreProtation)
2808 DALI_LOG_RELEASE_INFO("Support PreRotation and return 0\n");
2812 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
2818 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
2820 mScreenRotationAngle = transform * 90;
2821 return mScreenRotationAngle;
2824 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
2826 mWindowRotationAngle = degree;
2827 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
2830 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
2832 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
2835 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
2837 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
2840 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
2842 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
2845 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
2848 ecore_wl2_display_sync(display);
2850 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2852 if(mEcoreWindow == 0)
2854 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2858 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
2861 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
2863 Ecore_Wl2_Window* ecoreParent = NULL;
2866 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
2867 ecoreParent = winBaseEcore2->mEcoreWindow;
2869 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
2872 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2874 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
2877 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2879 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
2882 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2884 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPositionSizeWithAngle, angle: %d, x: %d, y: %d, w: %d, h: %d\n", angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2885 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2888 void WindowBaseEcoreWl2::InitializeIme()
2890 Eina_Iterator* globals;
2891 struct wl_registry* registry;
2892 Ecore_Wl2_Global* global;
2893 Ecore_Wl2_Display* ecoreWl2Display;
2895 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
2897 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
2901 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p\n", ecoreWl2Display, mEcoreWindow);
2903 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
2905 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
2909 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
2911 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
2915 EINA_ITERATOR_FOREACH(globals, global)
2917 #ifdef OVER_TIZEN_VERSION_7
2918 if(strcmp(global->interface, "zwp_input_panel_v1") == 0)
2920 mWlInputPanel = (zwp_input_panel_v1*)wl_registry_bind(registry, global->id, &zwp_input_panel_v1_interface, 1);
2923 if(strcmp(global->interface, "wl_input_panel") == 0)
2925 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
2928 else if(strcmp(global->interface, "wl_output") == 0)
2930 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
2936 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
2942 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
2945 #ifdef OVER_TIZEN_VERSION_7
2946 mWlInputPanelSurface = zwp_input_panel_v1_get_input_panel_surface(mWlInputPanel, mWlSurface);
2948 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
2950 if(!mWlInputPanelSurface)
2952 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
2955 #ifdef OVER_TIZEN_VERSION_7
2956 zwp_input_panel_surface_v1_set_toplevel(mWlInputPanelSurface, mWlOutput, ZWP_INPUT_PANEL_SURFACE_V1_POSITION_CENTER_BOTTOM);
2958 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
2962 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
2964 if(!mWlInputPanelSurface)
2966 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
2969 #ifdef OVER_TIZEN_VERSION_7
2970 zwp_input_panel_surface_v1_set_ready(mWlInputPanelSurface, 1);
2972 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
2976 void WindowBaseEcoreWl2::RequestMoveToServer()
2978 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
2981 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
2985 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
2988 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
2992 ecore_wl2_window_move(mEcoreWindow, input);
2993 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
2996 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
2998 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3001 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
3005 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3008 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
3012 ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
3014 ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
3015 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestResizeToServer, starts the window[%p] is resized by server, direction:%d oriention:%d mode:%d\n", mEcoreWindow, direction, mWindowRotationAngle, location);
3018 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
3020 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
3023 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
3027 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
3031 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
3033 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
3036 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
3038 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
3039 Eina_Rectangle rect;
3041 rect.x = convertRegion.x;
3042 rect.y = convertRegion.y;
3043 rect.w = convertRegion.width;
3044 rect.h = convertRegion.height;
3046 DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3047 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
3048 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3051 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
3053 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
3054 Eina_Rectangle rect;
3056 rect.x = convertRegion.x;
3057 rect.y = convertRegion.y;
3058 rect.w = convertRegion.width;
3059 rect.h = convertRegion.height;
3061 DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3062 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
3063 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3066 } // namespace Adaptor
3068 } // namespace Internal
3072 #pragma GCC diagnostic pop