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/system/common/time-service.h>
28 #include <dali/internal/window-system/common/window-impl.h>
29 #include <dali/internal/window-system/common/window-render-surface.h>
30 #include <dali/internal/window-system/common/window-system.h>
33 #include <Ecore_Input.h>
34 #include <dali/integration-api/debug.h>
35 #include <dali/integration-api/trace.h>
36 #include <dali/public-api/adaptor-framework/window-enumerations.h>
37 #include <dali/public-api/events/mouse-button.h>
38 #include <dali/public-api/object/any.h>
40 #if defined(VCONF_ENABLED)
41 #include <vconf-keys.h>
45 #define START_DURATION_CHECK() \
46 uint32_t durationMilliSeconds = static_cast<uint32_t>(-1); \
47 uint32_t startTime, endTime; \
48 startTime = TimeService::GetMilliSeconds();
50 #define FINISH_DURATION_CHECK(functionName) \
51 endTime = TimeService::GetMilliSeconds(); \
52 durationMilliSeconds = endTime - startTime; \
53 if(durationMilliSeconds > 0) \
55 DALI_LOG_DEBUG_INFO("%s : duration [%u ms]\n", functionName, durationMilliSeconds); \
58 #include <wayland-egl-tizen.h>
68 #if defined(DEBUG_ENABLED)
69 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
72 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
75 * @brief Enumeration of location for window resized by display server.
77 enum class ResizeLocation
79 INVALID = 0, ///< Invalid value
80 TOP_LEFT = 5, ///< Start resizing window to the top-left edge.
81 LEFT = 4, ///< Start resizing window to the left side.
82 BOTTOM_LEFT = 6, ///< Start resizing window to the bottom-left edge.
83 BOTTOM = 2, ///< Start resizing window to the bottom side.
84 BOTTOM_RIGHT = 10, ///< Start resizing window to the bottom-right edge.
85 RIGHT = 8, ///< Start resizing window to the right side.
86 TOP_RIGHT = 9, ///< Start resizing window to the top-right edge.
87 TOP = 1 ///< Start resizing window to the top side.
90 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
91 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
92 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};
94 #if defined(VCONF_ENABLED)
95 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
101 xkb_keycode_t keyCode;
106 * Get the device name from the provided ecore key event
108 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
110 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
114 result = ecoreDeviceName;
119 * Get the device class from the provided ecore event
121 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
123 switch(ecoreDeviceClass)
125 case ECORE_DEVICE_CLASS_SEAT:
127 deviceClass = Device::Class::USER;
130 case ECORE_DEVICE_CLASS_KEYBOARD:
132 deviceClass = Device::Class::KEYBOARD;
135 case ECORE_DEVICE_CLASS_MOUSE:
137 deviceClass = Device::Class::MOUSE;
140 case ECORE_DEVICE_CLASS_TOUCH:
142 deviceClass = Device::Class::TOUCH;
145 case ECORE_DEVICE_CLASS_PEN:
147 deviceClass = Device::Class::PEN;
150 case ECORE_DEVICE_CLASS_POINTER:
152 deviceClass = Device::Class::POINTER;
155 case ECORE_DEVICE_CLASS_GAMEPAD:
157 deviceClass = Device::Class::GAMEPAD;
162 deviceClass = Device::Class::NONE;
168 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
170 switch(ecoreDeviceSubclass)
172 case ECORE_DEVICE_SUBCLASS_FINGER:
174 deviceSubclass = Device::Subclass::FINGER;
177 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
179 deviceSubclass = Device::Subclass::FINGERNAIL;
182 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
184 deviceSubclass = Device::Subclass::KNUCKLE;
187 case ECORE_DEVICE_SUBCLASS_PALM:
189 deviceSubclass = Device::Subclass::PALM;
192 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
194 deviceSubclass = Device::Subclass::HAND_SIDE;
197 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
199 deviceSubclass = Device::Subclass::HAND_FLAT;
202 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
204 deviceSubclass = Device::Subclass::PEN_TIP;
207 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
209 deviceSubclass = Device::Subclass::TRACKPAD;
212 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
214 deviceSubclass = Device::Subclass::TRACKPOINT;
217 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
219 deviceSubclass = Device::Subclass::TRACKBALL;
222 case ECORE_DEVICE_SUBCLASS_REMOCON:
224 deviceSubclass = Device::Subclass::REMOCON;
227 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
229 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
234 deviceSubclass = Device::Subclass::NONE;
240 void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
242 KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
243 if(foundKeyCode->isKeyCode)
248 xkb_keysym_t keySym = foundKeyCode->keySym;
250 const xkb_keysym_t* symsOut = NULL;
252 nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
256 if(*symsOut == keySym)
258 foundKeyCode->keyCode = key;
259 foundKeyCode->isKeyCode = true;
265 * Return the recalculated window resizing location according to the current orientation.
267 ResizeLocation RecalculateLocationToCurrentOrientation(WindowResizeDirection direction, int windowRotationAngle)
272 case WindowResizeDirection::TOP_LEFT:
277 case WindowResizeDirection::LEFT:
282 case WindowResizeDirection::BOTTOM_LEFT:
287 case WindowResizeDirection::BOTTOM:
292 case WindowResizeDirection::BOTTOM_RIGHT:
297 case WindowResizeDirection::RIGHT:
302 case WindowResizeDirection::TOP_RIGHT:
307 case WindowResizeDirection::TOP:
319 if(index != 8 && windowRotationAngle != 0)
321 index = (index + (windowRotationAngle / 90) * 2) % 8;
324 return RESIZE_LOCATIONS[index];
327 /////////////////////////////////////////////////////////////////////////////////////////////////
329 /////////////////////////////////////////////////////////////////////////////////////////////////
331 /// Called when the window iconify state is changed.
332 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
334 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
337 return windowBase->OnIconifyStateChanged(data, type, event);
340 return ECORE_CALLBACK_PASS_ON;
343 /// Called when the window gains focus
344 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
346 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
349 return windowBase->OnFocusIn(data, type, event);
352 return ECORE_CALLBACK_PASS_ON;
355 /// Called when the window loses focus
356 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
358 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
361 return windowBase->OnFocusOut(data, type, event);
364 return ECORE_CALLBACK_PASS_ON;
367 /// Called when the output is transformed
368 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
370 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
373 return windowBase->OnOutputTransform(data, type, event);
376 return ECORE_CALLBACK_PASS_ON;
379 /// Called when the output transform should be ignored
380 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
382 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
385 return windowBase->OnIgnoreOutputTransform(data, type, event);
388 return ECORE_CALLBACK_PASS_ON;
392 * Called when rotate event is recevied.
394 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
396 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
399 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
400 windowBase->OnRotation(data, type, event);
402 return ECORE_CALLBACK_PASS_ON;
406 * Called when configure event is recevied.
408 static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
410 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
413 windowBase->OnConfiguration(data, type, event);
415 return ECORE_CALLBACK_PASS_ON;
418 /////////////////////////////////////////////////////////////////////////////////////////////////
420 /////////////////////////////////////////////////////////////////////////////////////////////////
423 * Called when a touch down is received.
425 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
427 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
430 windowBase->OnMouseButtonDown(data, type, event);
432 return ECORE_CALLBACK_PASS_ON;
436 * Called when a touch up is received.
438 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
440 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
443 windowBase->OnMouseButtonUp(data, type, event);
445 return ECORE_CALLBACK_PASS_ON;
449 * Called when a touch motion is received.
451 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
453 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
456 windowBase->OnMouseButtonMove(data, type, event);
458 return ECORE_CALLBACK_PASS_ON;
462 * Called when a touch motion is received.
464 static Eina_Bool EcoreEventMouseButtonRelativeMove(void* data, int type, void* event)
466 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
469 windowBase->OnMouseButtonRelativeMove(data, type, event);
471 return ECORE_CALLBACK_PASS_ON;
475 * Called when a touch is canceled.
477 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
479 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
482 windowBase->OnMouseButtonCancel(data, type, event);
484 return ECORE_CALLBACK_PASS_ON;
488 * Called when pointer constraints event is recevied.
490 static Eina_Bool EcoreEventPointerConstraints(void* data, int type, void* event)
492 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
495 windowBase->OnPointerConstraints(data, type, event);
497 return ECORE_CALLBACK_PASS_ON;
501 * Called when a mouse wheel is received.
503 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
505 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
508 windowBase->OnMouseWheel(data, type, event);
510 return ECORE_CALLBACK_PASS_ON;
514 * Called when a mouse in is received.
516 static Eina_Bool EcoreEventMouseIn(void* data, int type, void* event)
518 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
521 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::IN);
523 return ECORE_CALLBACK_PASS_ON;
527 * Called when a mouse out is received.
529 static Eina_Bool EcoreEventMouseOut(void* data, int type, void* event)
531 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
534 // When the mouse is out, the previous mouse must be canceled.
535 windowBase->OnMouseButtonCancel(data, type, event);
536 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::OUT);
538 return ECORE_CALLBACK_PASS_ON;
542 * Called when a detent rotation event is recevied.
544 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
546 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
549 windowBase->OnDetentRotation(data, type, event);
551 return ECORE_CALLBACK_PASS_ON;
554 /////////////////////////////////////////////////////////////////////////////////////////////////
556 /////////////////////////////////////////////////////////////////////////////////////////////////
559 * Called when a key down is received.
561 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
563 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
566 windowBase->OnKeyDown(data, type, event);
568 return ECORE_CALLBACK_PASS_ON;
572 * Called when a key up is received.
574 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
576 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
579 windowBase->OnKeyUp(data, type, event);
581 return ECORE_CALLBACK_PASS_ON;
584 /////////////////////////////////////////////////////////////////////////////////////////////////
585 // Selection Callbacks
586 /////////////////////////////////////////////////////////////////////////////////////////////////
589 * Called when the source window notifies us the content in clipboard is selected.
591 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
593 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
596 windowBase->OnDataSend(data, type, event);
598 return ECORE_CALLBACK_PASS_ON;
602 * Called when the source window sends us about the selected content.
603 * For example, when item is selected in the clipboard.
605 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
607 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
610 windowBase->OnDataReceive(data, type, event);
612 return ECORE_CALLBACK_PASS_ON;
615 /////////////////////////////////////////////////////////////////////////////////////////////////
616 // Effect Start/End Callbacks
617 /////////////////////////////////////////////////////////////////////////////////////////////////
620 * Called when transition animation of the window's shown/hidden is started by window manager.
622 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
624 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
625 Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
626 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
629 if(effectStart->type < 3) // only under restack
631 windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
634 return ECORE_CALLBACK_PASS_ON;
638 * Called when transition animation of the window's shown/hidden is ended by window manager.
640 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
642 Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
643 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
644 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
647 if(effectEnd->type < 3) // only under restack
649 windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
652 return ECORE_CALLBACK_PASS_ON;
655 /////////////////////////////////////////////////////////////////////////////////////////////////
656 // Keyboard Repeat Settings Changed Callbacks
657 /////////////////////////////////////////////////////////////////////////////////////////////////
659 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
661 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
662 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event)->id);
665 windowBase->OnKeyboardRepeatSettingsChanged();
668 return ECORE_CALLBACK_RENEW;
671 /////////////////////////////////////////////////////////////////////////////////////////////////
672 // Keymap Changed Callbacks
673 /////////////////////////////////////////////////////////////////////////////////////////////////
675 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
677 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
680 windowBase->KeymapChanged(data, type, event);
683 return ECORE_CALLBACK_RENEW;
686 /////////////////////////////////////////////////////////////////////////////////////////////////
688 /////////////////////////////////////////////////////////////////////////////////////////////////
690 #if defined(VCONF_ENABLED)
692 * Called when a font name is changed.
694 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
696 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
699 windowBase->OnFontNameChanged();
704 * Called when a font size is changed.
706 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
708 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
711 windowBase->OnFontSizeChanged();
716 /////////////////////////////////////////////////////////////////////////////////////////////////
717 // Window Redraw Request Event Callbacks
718 /////////////////////////////////////////////////////////////////////////////////////////////////
720 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
722 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
723 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event)->win);
726 windowBase->OnEcoreEventWindowRedrawRequest();
729 return ECORE_CALLBACK_RENEW;
732 /////////////////////////////////////////////////////////////////////////////////////////////////
733 // Window Auxiliary Message Callbacks
734 /////////////////////////////////////////////////////////////////////////////////////////////////
735 static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* event)
737 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
740 windowBase->OnEcoreEventWindowAuxiliaryMessage(event);
742 return ECORE_CALLBACK_RENEW;
745 /////////////////////////////////////////////////////////////////////////////////////////////////
746 // Window is Moved/Resized By Server Callbacks
747 /////////////////////////////////////////////////////////////////////////////////////////////////
748 static Eina_Bool EcoreEventWindowMoveCompleted(void* data, int type, void* event)
750 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
753 windowBase->OnMoveCompleted(event);
755 return ECORE_CALLBACK_RENEW;
758 static Eina_Bool EcoreEventWindowResizeCompleted(void* data, int type, void* event)
760 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
763 windowBase->OnResizeCompleted(event);
765 return ECORE_CALLBACK_RENEW;
768 /////////////////////////////////////////////////////////////////////////////////////////////////
769 // Conformant Change Callback
770 /////////////////////////////////////////////////////////////////////////////////////////////////
771 static Eina_Bool EcoreEventConformantChange(void* data, int type, void* event)
773 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
776 windowBase->OnEcoreEventConformantChange(event);
778 return ECORE_CALLBACK_RENEW;
781 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
783 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
786 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
790 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
792 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
795 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
799 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
803 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)
805 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
808 windowBase->TizenPolicyConformantArea(data, tizenPolicy, surface, conformantPart, state, x, y, w, h);
812 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
814 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
817 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
821 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
825 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
827 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
830 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
834 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
838 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
842 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
846 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
850 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)
854 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
856 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
859 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
863 const struct wl_registry_listener registryListener =
865 RegistryGlobalCallback,
866 RegistryGlobalCallbackRemove};
868 const struct tizen_policy_listener tizenPolicyListener =
870 TizenPolicyConformant,
871 TizenPolicyConformantArea,
872 TizenPolicyNotificationChangeDone,
873 TizenPolicyTransientForDone,
874 TizenPolicyScreenModeChangeDone,
875 TizenPolicyIconifyStateChanged,
876 TizenPolicySupportedAuxiliaryHints,
877 TizenPolicyAllowedAuxiliaryHint,
878 TizenPolicyAuxiliaryMessage,
879 TizenPolicyConformantRegion};
881 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
883 DisplayPolicyBrightnessChangeDone};
885 } // unnamed namespace
887 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
888 : mEcoreEventHandler(),
889 mEcoreWindow(nullptr),
891 mWlInputPanel(nullptr),
893 mWlInputPanelSurface(nullptr),
896 mEventQueue(nullptr),
897 mTizenPolicy(nullptr),
898 mTizenDisplayPolicy(nullptr),
900 mSupportedAuxiliaryHints(),
901 mWindowPositionSize(positionSize),
903 mType(WindowType::NORMAL),
904 mNotificationLevel(-1),
907 mWindowRotationAngle(0),
908 mScreenRotationAngle(0),
909 mSupportedPreProtation(0),
910 mNotificationChangeState(0),
911 mScreenOffModeChangeState(0),
912 mBrightnessChangeState(0),
913 mLastSubmittedMoveResizeSerial(0),
914 mMoveResizeSerial(0),
915 mNotificationLevelChangeDone(true),
916 mScreenOffModeChangeDone(true),
919 mBrightnessChangeDone(true)
921 Initialize(positionSize, surface, isTransparent);
924 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
926 #if defined(VCONF_ENABLED)
927 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
928 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
931 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
933 ecore_event_handler_del(*iter);
935 mEcoreEventHandler.Clear();
939 wl_event_queue_destroy(mEventQueue);
942 mSupportedAuxiliaryHints.clear();
943 mAuxiliaryHints.clear();
945 if(mEglWindow != NULL)
947 wl_egl_window_destroy(mEglWindow);
953 ecore_wl2_window_free(mEcoreWindow);
957 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
959 if(surface.Empty() == false)
961 // check we have a valid type
962 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
964 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
968 // we own the surface about to created
970 CreateWindow(positionSize);
973 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
975 SetTransparency(isTransparent);
977 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
978 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
982 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
984 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
987 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
988 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
989 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
990 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
991 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
993 // Register Rotate event
994 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
996 // Register Configure event
997 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
999 // Register Touch events
1000 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
1001 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
1002 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
1003 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
1004 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_RELATIVE_MOVE, EcoreEventMouseButtonRelativeMove, this));
1006 // Register pointer lock/unlock event
1007 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_POINTER_CONSTRAINTS, EcoreEventPointerConstraints, this));
1009 // Register Mouse wheel events
1010 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
1012 // Register Mouse IO events
1013 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
1014 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
1016 // Register Detent event
1017 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
1019 // Register Key events
1020 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
1021 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
1023 // Register Selection event - clipboard selection
1024 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
1025 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OFFER_DATA_READY, EcoreEventDataReceive, this));
1027 // Register Effect Start/End event
1028 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
1029 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
1031 // Register Keyboard repeat event
1032 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
1034 // Register Window redraw request event
1035 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
1037 // Register Window auxiliary event
1038 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
1040 // Register Conformant change event
1041 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_CONFORMANT_CHANGE, EcoreEventConformantChange, this));
1043 #if defined(VCONF_ENABLED)
1044 // Register Vconf notify - font name and size
1045 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
1046 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
1049 // Register Window is moved and resized done event.
1050 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE, EcoreEventWindowMoveCompleted, this));
1051 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE, EcoreEventWindowResizeCompleted, this));
1053 mDisplay = ecore_wl2_display_get(display);
1056 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
1059 mEventQueue = wl_display_create_queue(mDisplay);
1062 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
1064 wl_registry* registry = wl_display_get_registry(displayWrapper);
1065 wl_registry_add_listener(registry, ®istryListener, this);
1067 // To support ECORE_WL2_EVENT_CONFORMANT_CHANGE event handler
1068 ecore_wl2_window_conformant_set(mEcoreWindow, true);
1071 wl_proxy_wrapper_destroy(displayWrapper);
1075 // get auxiliary hint
1076 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
1079 Eina_List* l = NULL;
1082 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))))
1084 mSupportedAuxiliaryHints.push_back(hint);
1086 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
1091 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
1093 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
1094 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
1096 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1098 if(iconifyChangedEvent->iconified == EINA_TRUE)
1100 mIconifyChangedSignal.Emit(true);
1104 mIconifyChangedSignal.Emit(false);
1106 handled = ECORE_CALLBACK_DONE;
1112 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
1114 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
1116 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1118 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
1120 mFocusChangedSignal.Emit(true);
1123 return ECORE_CALLBACK_PASS_ON;
1126 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
1128 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
1130 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1132 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
1134 mFocusChangedSignal.Emit(false);
1137 return ECORE_CALLBACK_PASS_ON;
1140 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
1142 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
1144 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
1146 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
1148 mScreenRotationAngle = GetScreenRotationAngle();
1150 mOutputTransformedSignal.Emit();
1153 return ECORE_CALLBACK_PASS_ON;
1156 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
1158 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
1160 if(ignoreTransformEvent->win == mEcoreWindow)
1162 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
1164 mScreenRotationAngle = GetScreenRotationAngle();
1166 mOutputTransformedSignal.Emit();
1169 return ECORE_CALLBACK_PASS_ON;
1172 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
1174 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
1176 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1178 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
1180 RotationEvent rotationEvent;
1181 rotationEvent.angle = ev->angle;
1182 rotationEvent.winResize = 0;
1184 if(ev->w == 0 || ev->h == 0)
1186 // When rotation event does not have the window width or height,
1187 // previous DALi side window's size are used.
1188 ev->w = mWindowPositionSize.width;
1189 ev->h = mWindowPositionSize.height;
1192 mWindowRotationAngle = ev->angle;
1194 mWindowPositionSize.width = ev->w;
1195 mWindowPositionSize.height = ev->h;
1197 PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1199 rotationEvent.x = newPositionSize.x;
1200 rotationEvent.y = newPositionSize.y;
1201 rotationEvent.width = newPositionSize.width;
1202 rotationEvent.height = newPositionSize.height;
1204 mRotationSignal.Emit(rotationEvent);
1208 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1210 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1212 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1214 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1215 // by calling ecore_wl2_window_commit
1217 int tempWidth = ev->w;
1218 int tempHeight = ev->h;
1220 // Initialize with previous size for skip resize when new size is 0.
1221 // When window is just moved or window is resized by client application,
1222 // The configure notification event's size will be 0.
1223 // If new size is 0, the resized work should be skip.
1224 int newWidth = mWindowPositionSize.width;
1225 int newHeight = mWindowPositionSize.height;
1226 bool windowMoved = false, windowResized = false;
1228 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1233 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1235 windowResized = true;
1236 newWidth = tempWidth;
1237 newHeight = tempHeight;
1240 if(windowMoved || windowResized)
1242 mWindowPositionSize.x = ev->x;
1243 mWindowPositionSize.y = ev->y;
1244 mWindowPositionSize.width = newWidth;
1245 mWindowPositionSize.height = newHeight;
1246 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);
1248 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1250 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1251 mUpdatePositionSizeSignal.Emit(newPositionSize);
1254 mMaximizeChangedSignal.Emit(static_cast<bool>(ev->states & ECORE_WL2_WINDOW_STATE_MAXIMIZED));
1256 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1260 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1262 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1264 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1266 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
1268 Device::Class::Type deviceClass;
1269 Device::Subclass::Type deviceSubclass;
1271 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1272 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1274 PointState::Type state(PointState::DOWN);
1276 if(deviceClass != Device::Class::Type::MOUSE)
1278 // Check if the buttons field is set and ensure it's the primary touch button.
1279 // If this event was triggered by buttons other than the primary button (used for touch), then
1280 // just send an interrupted event to Core.
1281 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1283 state = PointState::INTERRUPTED;
1287 Integration::Point point;
1288 point.SetDeviceId(touchEvent->multi.device);
1289 point.SetState(state);
1290 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1291 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1292 point.SetPressure(touchEvent->multi.pressure);
1293 point.SetAngle(Degree(touchEvent->multi.angle));
1294 point.SetDeviceClass(deviceClass);
1295 point.SetDeviceSubclass(deviceSubclass);
1296 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1298 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1302 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1304 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1306 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1308 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
1310 Device::Class::Type deviceClass;
1311 Device::Subclass::Type deviceSubclass;
1313 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1314 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1316 Integration::Point point;
1317 point.SetDeviceId(touchEvent->multi.device);
1318 point.SetState(PointState::UP);
1319 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1320 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1321 point.SetPressure(touchEvent->multi.pressure);
1322 point.SetAngle(Degree(touchEvent->multi.angle));
1323 point.SetDeviceClass(deviceClass);
1324 point.SetDeviceSubclass(deviceSubclass);
1325 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1327 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1331 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1333 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1335 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1337 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
1339 Device::Class::Type deviceClass;
1340 Device::Subclass::Type deviceSubclass;
1342 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1343 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1345 Integration::Point point;
1346 point.SetDeviceId(touchEvent->multi.device);
1347 point.SetState(PointState::MOTION);
1348 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1349 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1350 point.SetPressure(touchEvent->multi.pressure);
1351 point.SetAngle(Degree(touchEvent->multi.angle));
1352 point.SetDeviceClass(deviceClass);
1353 point.SetDeviceSubclass(deviceSubclass);
1355 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1359 void WindowBaseEcoreWl2::OnMouseButtonRelativeMove(void* data, int type, void* event)
1361 Ecore_Event_Mouse_Relative_Move* relativeMoveEvent = static_cast<Ecore_Event_Mouse_Relative_Move*>(event);
1363 if(relativeMoveEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1365 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_RELATIVE_MOVE");
1367 Device::Class::Type deviceClass;
1368 Device::Subclass::Type deviceSubclass;
1370 GetDeviceClass(ecore_device_class_get(relativeMoveEvent->dev), deviceClass);
1371 GetDeviceSubclass(ecore_device_subclass_get(relativeMoveEvent->dev), deviceSubclass);
1373 Dali::DevelWindow::MouseRelativeEvent mouseRelativeEvent(Dali::DevelWindow::MouseRelativeEvent::Type::RELATIVE_MOVE, relativeMoveEvent->modifiers, relativeMoveEvent->timestamp, Vector2(relativeMoveEvent->dx, relativeMoveEvent->dy), Vector2(relativeMoveEvent->dx_unaccel, relativeMoveEvent->dy_unaccel), deviceClass, deviceSubclass);
1375 mMouseRelativeEventSignal.Emit(mouseRelativeEvent);
1379 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1381 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1383 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1385 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
1387 Integration::Point point;
1388 point.SetDeviceId(touchEvent->multi.device);
1389 point.SetState(PointState::INTERRUPTED);
1390 point.SetScreenPosition(Vector2(0.0f, 0.0f));
1392 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1394 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1398 void WindowBaseEcoreWl2::OnPointerConstraints(void* data, int type, void* event)
1400 Ecore_Wl2_Event_Pointer_Constraints* constraintsEvent = static_cast<Ecore_Wl2_Event_Pointer_Constraints*>(event);
1402 if(constraintsEvent && constraintsEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1404 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_POINTER_CONSTRAINTS");
1405 Dali::Int32Pair position(constraintsEvent->x, constraintsEvent->y);
1406 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnPointerConstraints[%d, %d]\n", position.GetX(), position.GetY());
1408 mPointerConstraintsSignal.Emit(position, constraintsEvent->locked, constraintsEvent->confined);
1412 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1414 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1416 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1418 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
1420 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);
1422 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1424 mWheelEventSignal.Emit(wheelEvent);
1428 void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
1430 Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
1432 if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1434 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
1436 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);
1438 Device::Class::Type deviceClass;
1439 Device::Subclass::Type deviceSubclass;
1441 GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
1442 GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
1444 Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
1446 mMouseInOutEventSignal.Emit(inOutEvent);
1450 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1452 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1454 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1456 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1458 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1460 mWheelEventSignal.Emit(wheelEvent);
1463 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1465 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1467 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1469 std::string keyName(keyEvent->keyname);
1470 std::string logicalKey("");
1471 std::string keyString("");
1472 std::string compose("");
1474 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_DOWN");
1476 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1477 if(keyEvent->compose)
1479 compose = keyEvent->compose;
1482 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1485 logicalKey = keyEvent->key;
1489 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1493 // Get a specific key code from dali key look up table.
1494 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1497 keyCode = (keyCode == -1) ? 0 : keyCode;
1498 int modifier(keyEvent->modifiers);
1499 unsigned long time = keyEvent->timestamp;
1500 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1502 keyCode = atoi(keyEvent->keyname + 8);
1505 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1506 if(keyEvent->string)
1508 keyString = keyEvent->string;
1511 std::string deviceName;
1512 Device::Class::Type deviceClass;
1513 Device::Subclass::Type deviceSubclass;
1515 GetDeviceName(keyEvent, deviceName);
1516 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1517 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1519 bool isRepeat = false;
1520 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 25)
1521 if(keyEvent->event_flags & ECORE_EVENT_FLAG_REPEAT)
1525 #endif // Since ecore 1.25 version
1527 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1528 keyEvent.isRepeat = isRepeat;
1530 mKeyEventSignal.Emit(keyEvent);
1534 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1536 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1538 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1540 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1541 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1542 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1544 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1547 #endif // Since ecore 1.23 version
1549 std::string keyName(keyEvent->keyname);
1550 std::string logicalKey("");
1551 std::string keyString("");
1552 std::string compose("");
1554 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_UP");
1556 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1557 if(keyEvent->compose)
1559 compose = keyEvent->compose;
1562 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1565 logicalKey = keyEvent->key;
1569 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1573 // Get a specific key code from dali key look up table.
1574 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1577 keyCode = (keyCode == -1) ? 0 : keyCode;
1578 int modifier(keyEvent->modifiers);
1579 unsigned long time = keyEvent->timestamp;
1580 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1582 keyCode = atoi(keyEvent->keyname + 8);
1585 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1586 if(keyEvent->string)
1588 keyString = keyEvent->string;
1591 std::string deviceName;
1592 Device::Class::Type deviceClass;
1593 Device::Subclass::Type deviceSubclass;
1595 GetDeviceName(keyEvent, deviceName);
1596 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1597 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1599 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1601 mKeyEventSignal.Emit(keyEvent);
1605 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1607 mSelectionDataSendSignal.Emit(event);
1610 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1612 mSelectionDataReceivedSignal.Emit(event);
1615 void WindowBaseEcoreWl2::OnFontNameChanged()
1617 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1620 void WindowBaseEcoreWl2::OnFontSizeChanged()
1622 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1625 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1627 mTransitionEffectEventSignal.Emit(state, type);
1630 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1632 mKeyboardRepeatSettingsChangedSignal.Emit();
1635 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1637 mWindowRedrawRequestSignal.Emit();
1640 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1642 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1645 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
1646 std::string key(message->key);
1647 std::string value(message->val);
1648 Dali::Property::Array options;
1650 if(message->options)
1654 EINA_LIST_FOREACH(message->options, l, data)
1656 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
1657 std::string option(static_cast<char*>(data));
1658 options.Add(option);
1662 mAuxiliaryMessageSignal.Emit(key, value, options);
1666 void WindowBaseEcoreWl2::OnEcoreEventConformantChange(void* event)
1668 Ecore_Wl2_Event_Conformant_Change* ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(event);
1669 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1671 WindowInsetsPartType partType = WindowInsetsPartType::STATUS_BAR;
1678 switch(ev->part_type)
1680 case ECORE_WL2_INDICATOR_PART:
1682 partType = WindowInsetsPartType::STATUS_BAR;
1683 ecore_wl2_window_indicator_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1686 case ECORE_WL2_KEYBOARD_PART:
1688 partType = WindowInsetsPartType::KEYBOARD;
1689 ecore_wl2_window_keyboard_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1692 case ECORE_WL2_CLIPBOARD_PART:
1694 partType = WindowInsetsPartType::CLIPBOARD;
1695 ecore_wl2_window_clipboard_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1704 WindowInsetsPartState partState = WindowInsetsPartState::INVISIBLE;
1711 // Insets are applied only if system UI(e.g. virtual keyboard) satisfies the following 2 conditions.
1712 // 1. System UI fits to the window width or height.
1713 // 2. System UI begins or ends from the edge of window.
1714 // Otherwise, we should not resize window content because there would be empty space around system UI.
1715 bool applyInsets = false;
1717 // Zero insets are applied if state is invisible
1724 partState = WindowInsetsPartState::VISIBLE;
1726 int winX = mWindowPositionSize.x;
1727 int winY = mWindowPositionSize.y;
1728 int winW = mWindowPositionSize.width;
1729 int winH = mWindowPositionSize.height;
1731 if((x <= winX) && (x + w >= winX + winW))
1733 if((y <= winY) && (y + h >= winY) && (y + h <= winY + winH))
1738 else if((y + h >= winY + winH) && (y >= winY) && (y <= winY + winH))
1740 bottom = winY + winH - y;
1744 else if((y <= winY) && (y + h >= winY + winH))
1746 if((x <= winX) && (x + w >= winX) && (x + w <= winX + winW))
1748 left = x + w - winX;
1751 else if((x + w >= winX + winW) && (x >= winX) && (x <= winX + winW))
1753 right = winX + winW - x;
1761 mInsetsChangedSignal.Emit(partType, partState, Extents(left, right, top, bottom));
1766 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1768 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1769 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1770 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1773 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1777 void WindowBaseEcoreWl2::OnMoveCompleted(void* event)
1779 Ecore_Wl2_Event_Window_Interactive_Move_Done* movedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Move_Done*>(event);
1780 if(movedDoneEvent && movedDoneEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1782 Dali::PositionSize orgPositionSize(movedDoneEvent->x, movedDoneEvent->y, movedDoneEvent->w, movedDoneEvent->h);
1783 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1784 Dali::Int32Pair newPosition(newPositionSize.x, newPositionSize.y);
1785 DALI_LOG_RELEASE_INFO("window(%p) has been moved by server[%d, %d]\n", mEcoreWindow, newPositionSize.x, newPositionSize.y);
1786 mMoveCompletedSignal.Emit(newPosition);
1790 void WindowBaseEcoreWl2::OnResizeCompleted(void* event)
1792 Ecore_Wl2_Event_Window_Interactive_Resize_Done* resizedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Resize_Done*>(event);
1793 if(resizedDoneEvent && resizedDoneEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1795 Dali::PositionSize orgPositionSize(resizedDoneEvent->x, resizedDoneEvent->y, resizedDoneEvent->w, resizedDoneEvent->h);
1796 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1797 Dali::Uint16Pair newSize(newPositionSize.width, newPositionSize.height);
1798 DALI_LOG_RELEASE_INFO("window(%p) has been resized by server[%d, %d]\n", mEcoreWindow, newPositionSize.width, newPositionSize.height);
1799 mResizeCompletedSignal.Emit(newSize);
1803 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1805 if(strcmp(interface, tizen_policy_interface.name) == 0)
1807 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1809 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1812 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1816 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1818 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1820 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1822 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1823 if(!mTizenDisplayPolicy)
1825 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1829 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1831 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1835 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1837 mTizenPolicy = NULL;
1838 mTizenDisplayPolicy = NULL;
1841 void WindowBaseEcoreWl2::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)
1843 int originalX, originalY, originalWidth, originalHeight;
1844 bool changed = false;
1848 DALI_LOG_ERROR("Failed to get wayland surface in WindowBaseEcoreWl2::TizenPolicyConformantArea()\n");
1852 if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_INDICATOR)
1854 ecore_wl2_window_indicator_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1855 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1857 ecore_wl2_window_indicator_geometry_set(mEcoreWindow, x, y, w, h);
1862 * The given state is based on the visibility value of indicator.
1863 * Thus we need to add 1 to it before comparing with indicator state.
1865 Ecore_Wl2_Indicator_State indState = ecore_wl2_window_indicator_state_get(mEcoreWindow);
1866 if((state + 1) != indState)
1868 ecore_wl2_window_indicator_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Indicator_State>(state + 1));
1872 else if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_KEYBOARD)
1874 ecore_wl2_window_keyboard_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1875 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1877 ecore_wl2_window_keyboard_geometry_set(mEcoreWindow, x, y, w, h);
1882 * The given state is based on the visibility value of virtual keyboard window.
1883 * Thus we need to add 1 to it before comparing with keyboard state.
1885 Ecore_Wl2_Virtual_Keyboard_State kbdState = ecore_wl2_window_keyboard_state_get(mEcoreWindow);
1886 if((state + 1) != (kbdState))
1888 ecore_wl2_window_keyboard_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Virtual_Keyboard_State>(state + 1));
1892 else if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD)
1894 ecore_wl2_window_clipboard_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1895 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1897 ecore_wl2_window_clipboard_geometry_set(mEcoreWindow, x, y, w, h);
1902 * The given state is based on the visibility value of clipboard window.
1903 * Thus we need to add 1 to it before comparing with clipboard state.
1905 Ecore_Wl2_Clipboard_State clipState = ecore_wl2_window_clipboard_state_get(mEcoreWindow);
1906 if((state + 1) != clipState)
1908 ecore_wl2_window_clipboard_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Clipboard_State>(state + 1));
1915 Ecore_Wl2_Event_Conformant_Change* ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(calloc(1, sizeof(Ecore_Wl2_Event_Conformant_Change)));
1921 ev->win = GetNativeWindowId();
1922 ev->part_type = static_cast<Ecore_Wl2_Conformant_Part_Type>(conformantPart);
1924 ecore_event_add(ECORE_WL2_EVENT_CONFORMANT_CHANGE, ev, NULL, NULL);
1927 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyConformantArea: conformantPart = %u, state = %u, position = (%d, %d), size = (%d, %d)\n", conformantPart, state, x, y, w, h);
1930 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1932 mNotificationLevel = level;
1933 mNotificationChangeState = state;
1934 mNotificationLevelChangeDone = true;
1936 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1939 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1941 mScreenOffMode = mode;
1942 mScreenOffModeChangeState = state;
1943 mScreenOffModeChangeDone = true;
1945 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1948 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1950 mBrightness = brightness;
1951 mBrightnessChangeState = state;
1952 mBrightnessChangeDone = true;
1954 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1957 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1959 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1960 KeyCodeMap foundKeyCode;
1962 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1963 if(sym == XKB_KEY_NoSymbol || !mKeyMap)
1965 DALI_LOG_ERROR("Failed to get keysym or keymap in WindowBaseEcoreWl2\n");
1969 foundKeyCode.keySym = sym;
1970 foundKeyCode.isKeyCode = false;
1971 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1972 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1975 Any WindowBaseEcoreWl2::GetNativeWindow()
1977 return mEcoreWindow;
1980 int WindowBaseEcoreWl2::GetNativeWindowId()
1982 return ecore_wl2_window_id_get(mEcoreWindow);
1985 std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
1987 #ifdef OVER_TIZEN_VERSION_7
1988 return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
1990 return std::string();
1994 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1996 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1998 START_DURATION_CHECK();
1999 if(totalAngle == 90 || totalAngle == 270)
2001 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
2005 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
2007 FINISH_DURATION_CHECK("wl_egl_window_create");
2009 return static_cast<EGLNativeWindowType>(mEglWindow);
2012 void WindowBaseEcoreWl2::DestroyEglWindow()
2014 if(mEglWindow != NULL)
2016 START_DURATION_CHECK();
2017 wl_egl_window_destroy(mEglWindow);
2018 FINISH_DURATION_CHECK("wl_egl_window_destroy");
2024 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
2026 wl_egl_window_tizen_rotation rotation;
2032 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
2037 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
2042 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
2047 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
2052 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
2057 START_DURATION_CHECK();
2058 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
2059 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_rotation");
2062 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
2064 wl_output_transform bufferTransform;
2070 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2075 bufferTransform = WL_OUTPUT_TRANSFORM_90;
2080 bufferTransform = WL_OUTPUT_TRANSFORM_180;
2085 bufferTransform = WL_OUTPUT_TRANSFORM_270;
2090 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2095 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_buffer_transform() with buffer Transform [%d]\n", bufferTransform);
2096 START_DURATION_CHECK();
2097 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
2098 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_buffer_transform");
2101 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
2103 wl_output_transform windowTransform;
2109 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2114 windowTransform = WL_OUTPUT_TRANSFORM_90;
2119 windowTransform = WL_OUTPUT_TRANSFORM_180;
2124 windowTransform = WL_OUTPUT_TRANSFORM_270;
2129 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2134 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_window_transform() with window Transform [%d]\n", windowTransform);
2135 START_DURATION_CHECK();
2136 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
2137 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_window_transform");
2140 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
2142 DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2143 START_DURATION_CHECK();
2144 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
2146 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
2147 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
2149 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
2150 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
2152 FINISH_DURATION_CHECK("wl_egl_window functions");
2155 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
2157 START_DURATION_CHECK();
2159 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
2160 FINISH_DURATION_CHECK("wl_egl_window_tizen_get_capabilities");
2162 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
2164 mSupportedPreProtation = true;
2167 mSupportedPreProtation = false;
2171 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
2173 PositionSize newPositionSize;
2174 int32_t screenWidth, screenHeight;
2175 WindowSystem::GetScreenSize(screenWidth, screenHeight);
2177 if(mWindowRotationAngle == 90)
2179 newPositionSize.x = positionSize.y;
2180 newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
2181 newPositionSize.width = positionSize.height;
2182 newPositionSize.height = positionSize.width;
2184 else if(mWindowRotationAngle == 180)
2186 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
2187 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
2188 newPositionSize.width = positionSize.width;
2189 newPositionSize.height = positionSize.height;
2191 else if(mWindowRotationAngle == 270)
2193 newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
2194 newPositionSize.y = positionSize.x;
2195 newPositionSize.width = positionSize.height;
2196 newPositionSize.height = positionSize.width;
2200 newPositionSize.x = positionSize.x;
2201 newPositionSize.y = positionSize.y;
2202 newPositionSize.width = positionSize.width;
2203 newPositionSize.height = positionSize.height;
2206 return newPositionSize;
2209 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
2211 PositionSize newPositionSize;
2212 int32_t screenWidth, screenHeight;
2213 WindowSystem::GetScreenSize(screenWidth, screenHeight);
2215 if(mWindowRotationAngle == 90)
2217 newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
2218 newPositionSize.y = positionSize.x;
2219 newPositionSize.width = positionSize.height;
2220 newPositionSize.height = positionSize.width;
2222 else if(mWindowRotationAngle == 180)
2224 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
2225 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
2226 newPositionSize.width = positionSize.width;
2227 newPositionSize.height = positionSize.height;
2229 else if(mWindowRotationAngle == 270)
2231 newPositionSize.x = positionSize.y;
2232 newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
2233 newPositionSize.width = positionSize.height;
2234 newPositionSize.height = positionSize.width;
2238 newPositionSize.x = positionSize.x;
2239 newPositionSize.y = positionSize.y;
2240 newPositionSize.width = positionSize.width;
2241 newPositionSize.height = positionSize.height;
2244 return newPositionSize;
2247 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
2249 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2251 mWindowPositionSize = newPositionSize;
2252 DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
2253 START_DURATION_CHECK();
2254 ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
2255 FINISH_DURATION_CHECK("ecore_wl2_window_position_set");
2258 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
2260 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2262 mWindowPositionSize = newPositionSize;
2263 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);
2264 START_DURATION_CHECK();
2265 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
2266 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
2269 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
2271 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2273 mWindowPositionSize = newPositionSize;
2274 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);
2275 START_DURATION_CHECK();
2276 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
2277 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
2280 void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
2282 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);
2283 START_DURATION_CHECK();
2284 ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
2285 FINISH_DURATION_CHECK("ecore_wl2_window_layout_set");
2288 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
2290 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
2291 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
2294 void WindowBaseEcoreWl2::Raise()
2296 START_DURATION_CHECK();
2297 // Use ecore_wl2_window_activate to prevent the window shown without rendering
2298 ecore_wl2_window_activate(mEcoreWindow);
2299 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
2302 void WindowBaseEcoreWl2::Lower()
2304 START_DURATION_CHECK();
2305 ecore_wl2_window_lower(mEcoreWindow);
2306 FINISH_DURATION_CHECK("ecore_wl2_window_lower");
2309 void WindowBaseEcoreWl2::Activate()
2311 START_DURATION_CHECK();
2312 ecore_wl2_window_activate(mEcoreWindow);
2313 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
2316 void WindowBaseEcoreWl2::Maximize(bool maximize)
2318 START_DURATION_CHECK();
2319 ecore_wl2_window_maximized_set(mEcoreWindow, maximize);
2320 FINISH_DURATION_CHECK("ecore_wl2_window_maximized_set");
2323 bool WindowBaseEcoreWl2::IsMaximized() const
2325 return ecore_wl2_window_maximized_get(mEcoreWindow);
2328 void WindowBaseEcoreWl2::SetMaximumSize(Dali::Window::WindowSize size)
2330 DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2331 START_DURATION_CHECK();
2332 ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2333 FINISH_DURATION_CHECK("ecore_wl2_window_maximum_size_set");
2334 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2337 void WindowBaseEcoreWl2::Minimize(bool minimize)
2339 START_DURATION_CHECK();
2340 ecore_wl2_window_iconified_set(mEcoreWindow, minimize);
2341 FINISH_DURATION_CHECK("ecore_wl2_window_iconified_set");
2344 bool WindowBaseEcoreWl2::IsMinimized() const
2346 return ecore_wl2_window_iconified_get(mEcoreWindow);
2349 void WindowBaseEcoreWl2::SetMimimumSize(Dali::Window::WindowSize size)
2351 DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2352 START_DURATION_CHECK();
2353 ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2354 FINISH_DURATION_CHECK("ecore_wl2_window_minimum_size_set");
2355 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2358 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
2360 int rotations[4] = {0};
2361 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
2362 for(std::size_t i = 0; i < angles.size(); ++i)
2364 rotations[i] = static_cast<int>(angles[i]);
2365 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
2368 START_DURATION_CHECK();
2369 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
2370 FINISH_DURATION_CHECK("ecore_wl2_window_available_rotations_set");
2373 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
2375 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
2376 START_DURATION_CHECK();
2377 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
2378 FINISH_DURATION_CHECK("ecore_wl2_window_preferred_rotation_set");
2381 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
2383 START_DURATION_CHECK();
2384 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
2385 FINISH_DURATION_CHECK("ecore_wl2_window_focus_skip_set");
2388 void WindowBaseEcoreWl2::Show()
2392 START_DURATION_CHECK();
2393 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
2394 FINISH_DURATION_CHECK("ecore_wl2_window_geometry_set");
2398 ecore_wl2_window_show(mEcoreWindow);
2401 void WindowBaseEcoreWl2::Hide()
2404 ecore_wl2_window_hide(mEcoreWindow);
2407 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
2409 return mSupportedAuxiliaryHints.size();
2412 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
2414 if(index >= GetSupportedAuxiliaryHintCount())
2416 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
2419 return mSupportedAuxiliaryHints[index];
2422 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
2424 bool supported = false;
2426 // Check if the hint is suppported
2427 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
2438 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
2442 // Check if the hint is already added
2443 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2445 if(mAuxiliaryHints[i].first == hint)
2447 // Just change the value
2448 mAuxiliaryHints[i].second = value;
2450 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
2452 return i + 1; // id is index + 1
2457 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
2459 unsigned int id = mAuxiliaryHints.size();
2461 START_DURATION_CHECK();
2462 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
2463 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_add");
2465 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
2470 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
2472 if(id == 0 || id > mAuxiliaryHints.size())
2474 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
2478 mAuxiliaryHints[id - 1].second = std::string();
2480 START_DURATION_CHECK();
2481 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
2482 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_del");
2484 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
2489 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
2491 if(id == 0 || id > mAuxiliaryHints.size())
2493 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
2497 mAuxiliaryHints[id - 1].second = value;
2499 START_DURATION_CHECK();
2500 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
2501 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_change");
2503 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());
2508 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
2510 if(id == 0 || id > mAuxiliaryHints.size())
2512 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
2513 return std::string();
2516 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());
2518 return mAuxiliaryHints[id - 1].second;
2521 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
2523 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2525 if(mAuxiliaryHints[i].first == hint)
2527 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
2532 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
2537 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
2539 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
2541 Eina_Rectangle rect;
2542 rect.x = convertRegion.x;
2543 rect.y = convertRegion.y;
2544 rect.w = convertRegion.width;
2545 rect.h = convertRegion.height;
2547 DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2548 START_DURATION_CHECK();
2549 ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
2550 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_set");
2551 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2554 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
2559 Ecore_Wl2_Window_Type windowType;
2563 case Dali::WindowType::NORMAL:
2565 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2568 case Dali::WindowType::NOTIFICATION:
2570 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
2573 case Dali::WindowType::UTILITY:
2575 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
2578 case Dali::WindowType::DIALOG:
2580 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
2583 case Dali::WindowType::IME:
2585 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
2588 case Dali::WindowType::DESKTOP:
2590 windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
2595 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2600 START_DURATION_CHECK();
2601 ecore_wl2_window_type_set(mEcoreWindow, windowType);
2602 FINISH_DURATION_CHECK("ecore_wl2_window_type_set");
2606 Dali::WindowType WindowBaseEcoreWl2::GetType() const
2611 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
2613 START_DURATION_CHECK();
2614 while(!mTizenPolicy)
2616 wl_display_dispatch_queue(mDisplay, mEventQueue);
2619 int notificationLevel;
2623 case Dali::WindowNotificationLevel::NONE:
2625 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
2628 case Dali::WindowNotificationLevel::BASE:
2630 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2633 case Dali::WindowNotificationLevel::MEDIUM:
2635 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
2638 case Dali::WindowNotificationLevel::HIGH:
2640 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
2643 case Dali::WindowNotificationLevel::TOP:
2645 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
2650 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
2651 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2656 mNotificationLevelChangeDone = false;
2657 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2659 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2663 while(!mNotificationLevelChangeDone && count < 3)
2665 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2666 wl_display_dispatch_queue(mDisplay, mEventQueue);
2669 FINISH_DURATION_CHECK("ecore_wl2 & wl_display");
2671 if(!mNotificationLevelChangeDone)
2673 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2674 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2676 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2678 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2679 return Dali::WindowOperationResult::PERMISSION_DENIED;
2682 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2684 return Dali::WindowOperationResult::SUCCEED;
2687 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2689 while(!mTizenPolicy)
2691 wl_display_dispatch_queue(mDisplay, mEventQueue);
2696 while(!mNotificationLevelChangeDone && count < 3)
2698 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2699 wl_display_dispatch_queue(mDisplay, mEventQueue);
2703 if(!mNotificationLevelChangeDone)
2705 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2706 return Dali::WindowNotificationLevel::NONE;
2709 Dali::WindowNotificationLevel level;
2711 switch(mNotificationLevel)
2713 case TIZEN_POLICY_LEVEL_NONE:
2715 level = Dali::WindowNotificationLevel::NONE;
2718 case TIZEN_POLICY_LEVEL_DEFAULT:
2720 level = Dali::WindowNotificationLevel::BASE;
2723 case TIZEN_POLICY_LEVEL_MEDIUM:
2725 level = Dali::WindowNotificationLevel::MEDIUM;
2728 case TIZEN_POLICY_LEVEL_HIGH:
2730 level = Dali::WindowNotificationLevel::HIGH;
2733 case TIZEN_POLICY_LEVEL_TOP:
2735 level = Dali::WindowNotificationLevel::TOP;
2740 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2741 level = Dali::WindowNotificationLevel::NONE;
2746 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2751 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2753 while(!mTizenPolicy)
2755 wl_display_dispatch_queue(mDisplay, mEventQueue);
2758 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2761 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2763 while(!mTizenPolicy)
2765 wl_display_dispatch_queue(mDisplay, mEventQueue);
2768 mScreenOffModeChangeDone = false;
2769 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2771 unsigned int mode = 0;
2773 switch(screenOffMode)
2775 case WindowScreenOffMode::TIMEOUT:
2780 case WindowScreenOffMode::NEVER:
2787 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2791 while(!mScreenOffModeChangeDone && count < 3)
2793 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2794 wl_display_dispatch_queue(mDisplay, mEventQueue);
2798 if(!mScreenOffModeChangeDone)
2800 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2801 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2803 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2805 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2806 return Dali::WindowOperationResult::PERMISSION_DENIED;
2809 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2811 return Dali::WindowOperationResult::SUCCEED;
2814 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2816 while(!mTizenPolicy)
2818 wl_display_dispatch_queue(mDisplay, mEventQueue);
2823 while(!mScreenOffModeChangeDone && count < 3)
2825 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2826 wl_display_dispatch_queue(mDisplay, mEventQueue);
2830 if(!mScreenOffModeChangeDone)
2832 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2833 return WindowScreenOffMode::TIMEOUT;
2836 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2838 switch(mScreenOffMode)
2842 screenMode = WindowScreenOffMode::TIMEOUT;
2847 screenMode = WindowScreenOffMode::NEVER;
2852 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2857 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2859 START_DURATION_CHECK();
2860 while(!mTizenDisplayPolicy)
2862 wl_display_dispatch_queue(mDisplay, mEventQueue);
2865 mBrightnessChangeDone = false;
2866 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2868 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2872 while(!mBrightnessChangeDone && count < 3)
2874 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2875 wl_display_dispatch_queue(mDisplay, mEventQueue);
2878 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2880 if(!mBrightnessChangeDone)
2882 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2883 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2885 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2887 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2888 return Dali::WindowOperationResult::PERMISSION_DENIED;
2891 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2893 return Dali::WindowOperationResult::SUCCEED;
2896 int WindowBaseEcoreWl2::GetBrightness() const
2898 START_DURATION_CHECK();
2899 while(!mTizenDisplayPolicy)
2901 wl_display_dispatch_queue(mDisplay, mEventQueue);
2906 while(!mBrightnessChangeDone && count < 3)
2908 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2909 wl_display_dispatch_queue(mDisplay, mEventQueue);
2912 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2914 if(!mBrightnessChangeDone)
2916 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2920 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2925 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2927 Ecore_Wl2_Window_Keygrab_Mode mode;
2931 case KeyGrab::TOPMOST:
2933 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2936 case KeyGrab::SHARED:
2938 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2941 case KeyGrab::OVERRIDE_EXCLUSIVE:
2943 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2946 case KeyGrab::EXCLUSIVE:
2948 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2957 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2960 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2962 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2965 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2967 int keyCount = key.Count();
2968 int keyGrabModeCount = grabMode.Count();
2970 if(keyCount != keyGrabModeCount || keyCount == 0)
2977 Eina_List* keyList = NULL;
2978 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2980 for(int index = 0; index < keyCount; ++index)
2982 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2984 switch(grabMode[index])
2986 case KeyGrab::TOPMOST:
2988 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2991 case KeyGrab::SHARED:
2993 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2996 case KeyGrab::OVERRIDE_EXCLUSIVE:
2998 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
3001 case KeyGrab::EXCLUSIVE:
3003 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
3008 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
3013 keyList = eina_list_append(keyList, &info);
3016 START_DURATION_CHECK();
3017 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
3018 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_set");
3020 result.Resize(keyCount, true);
3022 Eina_List* l = NULL;
3023 Eina_List* m = NULL;
3024 void* listData = NULL;
3026 if(grabList != NULL)
3028 EINA_LIST_FOREACH(grabList, m, data)
3031 EINA_LIST_FOREACH(keyList, l, listData)
3033 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
3035 DALI_LOG_ERROR("input key list has null data!");
3039 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
3041 result[index] = false;
3050 eina_list_free(keyList);
3051 eina_list_free(grabList);
3057 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
3059 int keyCount = key.Count();
3067 Eina_List* keyList = NULL;
3068 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
3070 for(int index = 0; index < keyCount; ++index)
3072 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
3073 keyList = eina_list_append(keyList, &info);
3076 START_DURATION_CHECK();
3077 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
3078 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_unset");
3080 result.Resize(keyCount, true);
3082 Eina_List* l = NULL;
3083 Eina_List* m = NULL;
3084 void* listData = NULL;
3087 if(ungrabList != NULL)
3089 EINA_LIST_FOREACH(ungrabList, m, data)
3092 EINA_LIST_FOREACH(keyList, l, listData)
3094 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
3096 result[index] = false;
3105 eina_list_free(keyList);
3106 eina_list_free(ungrabList);
3112 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
3117 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
3119 // 1 inch = 25.4 millimeters
3120 xres = ecore_wl2_output_dpi_get(output);
3121 yres = ecore_wl2_output_dpi_get(output);
3123 dpiHorizontal = int(xres + 0.5f); // rounding
3124 dpiVertical = int(yres + 0.5f);
3127 int WindowBaseEcoreWl2::GetWindowRotationAngle() const
3129 int orientation = mWindowRotationAngle;
3130 if(mSupportedPreProtation)
3137 int WindowBaseEcoreWl2::GetScreenRotationAngle()
3139 if(mSupportedPreProtation)
3141 DALI_LOG_RELEASE_INFO("Support PreRotation and return 0\n");
3145 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
3151 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
3153 mScreenRotationAngle = transform * 90;
3154 return mScreenRotationAngle;
3157 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
3159 mWindowRotationAngle = degree;
3160 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
3163 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
3165 START_DURATION_CHECK();
3166 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
3167 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_change_done_send");
3170 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
3172 START_DURATION_CHECK();
3173 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
3174 FINISH_DURATION_CHECK("ecore_wl2_window_alpha_set");
3177 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
3179 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
3182 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
3185 START_DURATION_CHECK();
3186 ecore_wl2_display_sync(display);
3188 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
3190 if(mEcoreWindow == 0)
3192 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
3196 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
3197 FINISH_DURATION_CHECK("ecore_wl2 functions");
3200 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
3202 Ecore_Wl2_Window* ecoreParent = NULL;
3205 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
3206 ecoreParent = winBaseEcore2->mEcoreWindow;
3209 START_DURATION_CHECK();
3210 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
3211 FINISH_DURATION_CHECK("ecore_wl2_window_transient_parent_set");
3214 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
3216 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
3219 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
3221 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
3224 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
3226 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);
3227 START_DURATION_CHECK();
3228 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
3229 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_geometry_set");
3232 void WindowBaseEcoreWl2::InitializeIme()
3234 Eina_Iterator* globals;
3235 struct wl_registry* registry;
3236 Ecore_Wl2_Global* global;
3237 Ecore_Wl2_Display* ecoreWl2Display;
3239 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
3241 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
3245 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p\n", ecoreWl2Display, mEcoreWindow);
3247 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
3249 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
3253 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
3255 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
3259 START_DURATION_CHECK();
3260 EINA_ITERATOR_FOREACH(globals, global)
3262 #ifdef OVER_TIZEN_VERSION_7
3263 if(strcmp(global->interface, "zwp_input_panel_v1") == 0)
3265 mWlInputPanel = (zwp_input_panel_v1*)wl_registry_bind(registry, global->id, &zwp_input_panel_v1_interface, 1);
3268 if(strcmp(global->interface, "wl_input_panel") == 0)
3270 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
3273 else if(strcmp(global->interface, "wl_output") == 0)
3275 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
3281 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
3287 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
3290 #ifdef OVER_TIZEN_VERSION_7
3291 mWlInputPanelSurface = zwp_input_panel_v1_get_input_panel_surface(mWlInputPanel, mWlSurface);
3293 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
3295 if(!mWlInputPanelSurface)
3297 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
3300 #ifdef OVER_TIZEN_VERSION_7
3301 zwp_input_panel_surface_v1_set_toplevel(mWlInputPanelSurface, mWlOutput, ZWP_INPUT_PANEL_SURFACE_V1_POSITION_CENTER_BOTTOM);
3303 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
3305 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_toplevel");
3308 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
3310 if(!mWlInputPanelSurface)
3312 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
3316 START_DURATION_CHECK();
3317 #ifdef OVER_TIZEN_VERSION_7
3318 zwp_input_panel_surface_v1_set_ready(mWlInputPanelSurface, 1);
3320 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
3322 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_ready");
3325 void WindowBaseEcoreWl2::RequestMoveToServer()
3327 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3330 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
3334 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3337 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
3341 START_DURATION_CHECK();
3342 ecore_wl2_window_move(mEcoreWindow, input);
3343 FINISH_DURATION_CHECK("ecore_wl2_window_move");
3344 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
3347 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
3349 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3352 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
3356 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3359 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
3363 ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
3365 START_DURATION_CHECK();
3366 ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
3367 FINISH_DURATION_CHECK("ecore_wl2_window_resize");
3368 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);
3371 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
3373 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
3374 START_DURATION_CHECK();
3377 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
3381 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
3383 FINISH_DURATION_CHECK("ecore_wl2_window_floating_mode_set");
3386 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
3388 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
3391 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
3393 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
3394 Eina_Rectangle rect;
3396 rect.x = convertRegion.x;
3397 rect.y = convertRegion.y;
3398 rect.w = convertRegion.width;
3399 rect.h = convertRegion.height;
3401 DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3402 START_DURATION_CHECK();
3403 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
3404 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_add");
3405 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3408 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
3410 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
3411 Eina_Rectangle rect;
3413 rect.x = convertRegion.x;
3414 rect.y = convertRegion.y;
3415 rect.w = convertRegion.width;
3416 rect.h = convertRegion.height;
3418 DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3419 START_DURATION_CHECK();
3420 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
3421 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_subtract");
3422 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3425 bool WindowBaseEcoreWl2::PointerConstraintsLock()
3427 return ecore_wl2_window_pointer_constraints_lock_pointer(mEcoreWindow);
3430 bool WindowBaseEcoreWl2::PointerConstraintsUnlock()
3432 return ecore_wl2_window_pointer_constraints_unlock_pointer(mEcoreWindow);
3435 void WindowBaseEcoreWl2::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
3437 ecore_wl2_window_locked_pointer_region_set(mEcoreWindow, x, y, width, height);
3438 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3441 void WindowBaseEcoreWl2::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
3443 ecore_wl2_window_locked_pointer_cursor_position_hint_set(mEcoreWindow, x, y);
3444 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3447 bool WindowBaseEcoreWl2::PointerWarp(int32_t x, int32_t y)
3449 return ecore_wl2_window_pointer_warp(mEcoreWindow, x, y);
3452 void WindowBaseEcoreWl2::CursorVisibleSet(bool visible)
3454 ecore_wl2_window_cursor_visible_set(mEcoreWindow, visible);
3457 // Request grab key events according to the requested device subtype
3458 //(For now, subtype could be '0'/'11'/'12' which equals to ECORE_DEVICE_SUBCLASS_NONE/REMOCON/VIRTUAL_KEYBOARD)
3459 bool WindowBaseEcoreWl2::KeyboardGrab(Device::Subclass::Type deviceSubclass)
3461 Ecore_Device_Subclass ecoreDeviceSubclass;
3462 switch(deviceSubclass)
3464 case Device::Subclass::NONE:
3466 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_NONE;
3469 case Device::Subclass::REMOCON:
3471 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_REMOCON;
3474 case Device::Subclass::VIRTUAL_KEYBOARD:
3476 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD;
3481 DALI_LOG_ERROR("deviceSubclass : %d type is not support, subtype could be 'NONE', 'REMOCON', 'VIRTUAL_KEYBOARD'\n");
3485 return ecore_wl2_window_keyboard_grab(mEcoreWindow, ecoreDeviceSubclass);
3488 // Request ungrab key events
3489 bool WindowBaseEcoreWl2::KeyboardUnGrab()
3491 return ecore_wl2_window_keyboard_ungrab(mEcoreWindow);
3494 } // namespace Adaptor
3496 } // namespace Internal
3500 #pragma GCC diagnostic pop