2 * Copyright (c) 2024 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;
461 #ifdef OVER_TIZEN_VERSION_8
463 * Called when a touch motion is received.
465 static Eina_Bool EcoreEventMouseButtonRelativeMove(void* data, int type, void* event)
467 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
470 windowBase->OnMouseButtonRelativeMove(data, type, event);
472 return ECORE_CALLBACK_PASS_ON;
477 * Called when a touch is canceled.
479 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
481 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
484 windowBase->OnMouseButtonCancel(data, type, event);
486 return ECORE_CALLBACK_PASS_ON;
489 #ifdef OVER_TIZEN_VERSION_8
491 * Called when pointer constraints event is recevied.
493 static Eina_Bool EcoreEventPointerConstraints(void* data, int type, void* event)
495 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
498 windowBase->OnPointerConstraints(data, type, event);
500 return ECORE_CALLBACK_PASS_ON;
505 * Called when a mouse wheel is received.
507 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
509 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
512 windowBase->OnMouseWheel(data, type, event);
514 return ECORE_CALLBACK_PASS_ON;
518 * Called when a mouse in is received.
520 static Eina_Bool EcoreEventMouseIn(void* data, int type, void* event)
522 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
525 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::IN);
527 return ECORE_CALLBACK_PASS_ON;
531 * Called when a mouse out is received.
533 static Eina_Bool EcoreEventMouseOut(void* data, int type, void* event)
535 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
538 // When the mouse is out, the previous mouse must be canceled.
539 windowBase->OnMouseButtonCancel(data, type, event);
540 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::OUT);
542 return ECORE_CALLBACK_PASS_ON;
546 * Called when a detent rotation event is recevied.
548 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
550 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
553 windowBase->OnDetentRotation(data, type, event);
555 return ECORE_CALLBACK_PASS_ON;
558 /////////////////////////////////////////////////////////////////////////////////////////////////
560 /////////////////////////////////////////////////////////////////////////////////////////////////
563 * Called when a key down is received.
565 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
567 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
570 windowBase->OnKeyDown(data, type, event);
572 return ECORE_CALLBACK_PASS_ON;
576 * Called when a key up is received.
578 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
580 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
583 windowBase->OnKeyUp(data, type, event);
585 return ECORE_CALLBACK_PASS_ON;
588 /////////////////////////////////////////////////////////////////////////////////////////////////
589 // Selection Callbacks
590 /////////////////////////////////////////////////////////////////////////////////////////////////
593 * Called when the source window notifies us the content in clipboard is selected.
595 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
597 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
600 windowBase->OnDataSend(data, type, event);
602 return ECORE_CALLBACK_PASS_ON;
606 * Called when the source window sends us about the selected content.
607 * For example, when item is selected in the clipboard.
609 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
611 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
614 windowBase->OnDataReceive(data, type, event);
616 return ECORE_CALLBACK_PASS_ON;
619 /////////////////////////////////////////////////////////////////////////////////////////////////
620 // Effect Start/End Callbacks
621 /////////////////////////////////////////////////////////////////////////////////////////////////
624 * Called when transition animation of the window's shown/hidden is started by window manager.
626 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
628 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
629 Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
630 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
633 if(effectStart->type < 3) // only under restack
635 windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
638 return ECORE_CALLBACK_PASS_ON;
642 * Called when transition animation of the window's shown/hidden is ended by window manager.
644 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
646 Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
647 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
648 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
651 if(effectEnd->type < 3) // only under restack
653 windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
656 return ECORE_CALLBACK_PASS_ON;
659 /////////////////////////////////////////////////////////////////////////////////////////////////
660 // Keyboard Repeat Settings Changed Callbacks
661 /////////////////////////////////////////////////////////////////////////////////////////////////
663 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
665 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
666 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event)->id);
669 windowBase->OnKeyboardRepeatSettingsChanged();
672 return ECORE_CALLBACK_RENEW;
675 /////////////////////////////////////////////////////////////////////////////////////////////////
676 // Keymap Changed Callbacks
677 /////////////////////////////////////////////////////////////////////////////////////////////////
679 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
681 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
684 windowBase->KeymapChanged(data, type, event);
687 return ECORE_CALLBACK_RENEW;
690 /////////////////////////////////////////////////////////////////////////////////////////////////
692 /////////////////////////////////////////////////////////////////////////////////////////////////
694 #if defined(VCONF_ENABLED)
696 * Called when a font name is changed.
698 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
700 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
703 windowBase->OnFontNameChanged();
708 * Called when a font size is changed.
710 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
712 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
715 windowBase->OnFontSizeChanged();
720 /////////////////////////////////////////////////////////////////////////////////////////////////
721 // Window Redraw Request Event Callbacks
722 /////////////////////////////////////////////////////////////////////////////////////////////////
724 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
726 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
727 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event)->win);
730 windowBase->OnEcoreEventWindowRedrawRequest();
733 return ECORE_CALLBACK_RENEW;
736 /////////////////////////////////////////////////////////////////////////////////////////////////
737 // Window Auxiliary Message Callbacks
738 /////////////////////////////////////////////////////////////////////////////////////////////////
739 static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* event)
741 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
744 windowBase->OnEcoreEventWindowAuxiliaryMessage(event);
746 return ECORE_CALLBACK_RENEW;
749 /////////////////////////////////////////////////////////////////////////////////////////////////
750 // Window is Moved/Resized By Server Callbacks
751 /////////////////////////////////////////////////////////////////////////////////////////////////
752 static Eina_Bool EcoreEventWindowMoveCompleted(void* data, int type, void* event)
754 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
757 windowBase->OnMoveCompleted(event);
759 return ECORE_CALLBACK_RENEW;
762 static Eina_Bool EcoreEventWindowResizeCompleted(void* data, int type, void* event)
764 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
767 windowBase->OnResizeCompleted(event);
769 return ECORE_CALLBACK_RENEW;
772 /////////////////////////////////////////////////////////////////////////////////////////////////
773 // Conformant Change Callback
774 /////////////////////////////////////////////////////////////////////////////////////////////////
775 static Eina_Bool EcoreEventConformantChange(void* data, int type, void* event)
777 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
780 windowBase->OnEcoreEventConformantChange(event);
782 return ECORE_CALLBACK_RENEW;
785 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
787 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
790 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
794 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
796 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
799 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
803 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
807 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)
809 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
812 windowBase->TizenPolicyConformantArea(data, tizenPolicy, surface, conformantPart, state, x, y, w, h);
816 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
818 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
821 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
825 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
829 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
831 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
834 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
838 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
842 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
846 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
850 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
854 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)
858 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
860 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
863 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
867 const struct wl_registry_listener registryListener =
869 RegistryGlobalCallback,
870 RegistryGlobalCallbackRemove};
872 const struct tizen_policy_listener tizenPolicyListener =
874 TizenPolicyConformant,
875 TizenPolicyConformantArea,
876 TizenPolicyNotificationChangeDone,
877 TizenPolicyTransientForDone,
878 TizenPolicyScreenModeChangeDone,
879 TizenPolicyIconifyStateChanged,
880 TizenPolicySupportedAuxiliaryHints,
881 TizenPolicyAllowedAuxiliaryHint,
882 TizenPolicyAuxiliaryMessage,
883 TizenPolicyConformantRegion};
885 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
887 DisplayPolicyBrightnessChangeDone};
889 } // unnamed namespace
891 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
892 : mEcoreEventHandler(),
893 mEcoreWindow(nullptr),
895 mWlInputPanel(nullptr),
897 mWlInputPanelSurface(nullptr),
900 mEventQueue(nullptr),
901 mTizenPolicy(nullptr),
902 mTizenDisplayPolicy(nullptr),
904 mSupportedAuxiliaryHints(),
905 mWindowPositionSize(positionSize),
907 mType(WindowType::NORMAL),
908 mNotificationLevel(-1),
911 mWindowRotationAngle(0),
912 mScreenRotationAngle(0),
913 mSupportedPreProtation(0),
914 mNotificationChangeState(0),
915 mScreenOffModeChangeState(0),
916 mBrightnessChangeState(0),
917 mLastSubmittedMoveResizeSerial(0),
918 mMoveResizeSerial(0),
919 mNotificationLevelChangeDone(true),
920 mScreenOffModeChangeDone(true),
923 mBrightnessChangeDone(true),
924 mIsFrontBufferRendering(false),
925 mIsIMEWindowInitialized(false)
927 Initialize(positionSize, surface, isTransparent);
930 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
932 #if defined(VCONF_ENABLED)
933 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
934 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
937 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
939 ecore_event_handler_del(*iter);
941 mEcoreEventHandler.Clear();
945 wl_event_queue_destroy(mEventQueue);
948 mSupportedAuxiliaryHints.clear();
949 mAuxiliaryHints.clear();
951 if(mEglWindow != NULL)
953 wl_egl_window_destroy(mEglWindow);
961 ecore_wl2_window_free(mEcoreWindow);
963 catch(std::bad_weak_ptr const& ex)
965 DALI_LOG_ERROR("WindowBaseEcoreWl2::~WindowBaseEcoreWl2() - window (%p) std::bad_weak_ptr caught: %s\n", mEcoreWindow, ex.what());
970 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
972 if(surface.Empty() == false)
974 // check we have a valid type
975 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
977 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
981 // we own the surface about to created
983 CreateWindow(positionSize);
986 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
988 SetTransparency(isTransparent);
990 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
991 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
995 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
997 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
1000 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
1001 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
1002 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
1003 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
1004 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
1006 // Register Rotate event
1007 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
1009 // Register Configure event
1010 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
1012 // Register Touch events
1013 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
1014 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
1015 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
1016 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
1017 #ifdef OVER_TIZEN_VERSION_8
1018 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_RELATIVE_MOVE, EcoreEventMouseButtonRelativeMove, this));
1020 // Register pointer lock/unlock event
1021 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_POINTER_CONSTRAINTS, EcoreEventPointerConstraints, this));
1024 // Register Mouse wheel events
1025 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
1027 // Register Mouse IO events
1028 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
1029 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
1031 // Register Detent event
1032 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
1034 // Register Key events
1035 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
1036 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
1038 // Register Selection event - clipboard selection
1039 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
1040 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OFFER_DATA_READY, EcoreEventDataReceive, this));
1042 // Register Effect Start/End event
1043 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
1044 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
1046 // Register Keyboard repeat event
1047 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
1049 // Register Window redraw request event
1050 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
1052 // Register Window auxiliary event
1053 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
1055 // Register Conformant change event
1056 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_CONFORMANT_CHANGE, EcoreEventConformantChange, this));
1058 #if defined(VCONF_ENABLED)
1059 // Register Vconf notify - font name and size
1060 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
1061 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
1064 // Register Window is moved and resized done event.
1065 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE, EcoreEventWindowMoveCompleted, this));
1066 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE, EcoreEventWindowResizeCompleted, this));
1068 mDisplay = ecore_wl2_display_get(display);
1071 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
1074 mEventQueue = wl_display_create_queue(mDisplay);
1077 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
1079 wl_registry* registry = wl_display_get_registry(displayWrapper);
1080 wl_registry_add_listener(registry, ®istryListener, this);
1082 // To support ECORE_WL2_EVENT_CONFORMANT_CHANGE event handler
1083 ecore_wl2_window_conformant_set(mEcoreWindow, true);
1086 wl_proxy_wrapper_destroy(displayWrapper);
1090 // get auxiliary hint
1091 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
1094 Eina_List* l = NULL;
1097 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))))
1099 mSupportedAuxiliaryHints.push_back(hint);
1101 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
1106 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
1108 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
1109 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
1111 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1113 if(iconifyChangedEvent->iconified == EINA_TRUE)
1115 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnIconifyStateChanged, the window (%p) is iconified\n", mEcoreWindow);
1116 mIconifyChangedSignal.Emit(true);
1120 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnIconifyStateChanged, the window (%p) is not iconified\n", mEcoreWindow);
1121 mIconifyChangedSignal.Emit(false);
1123 handled = ECORE_CALLBACK_DONE;
1129 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
1131 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
1133 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1135 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnFocusIn, Window (%p) EcoreEventWindowFocusIn\n", mEcoreWindow);
1137 mFocusChangedSignal.Emit(true);
1140 return ECORE_CALLBACK_PASS_ON;
1143 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
1145 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
1147 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1149 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnFocusOut, Window (%p) EcoreEventWindowFocusOut\n", mEcoreWindow);
1151 mFocusChangedSignal.Emit(false);
1154 return ECORE_CALLBACK_PASS_ON;
1157 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
1159 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
1161 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
1163 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnOutputTransform, Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
1165 mScreenRotationAngle = GetScreenRotationAngle();
1167 mOutputTransformedSignal.Emit();
1170 return ECORE_CALLBACK_PASS_ON;
1173 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
1175 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
1177 if(ignoreTransformEvent->win == mEcoreWindow)
1179 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnIgnoreOutputTransform, Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
1181 mScreenRotationAngle = GetScreenRotationAngle();
1183 mOutputTransformedSignal.Emit();
1186 return ECORE_CALLBACK_PASS_ON;
1189 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
1191 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
1193 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1195 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, Window (%p), angle: %d, width: %d, height: %d\n", mEcoreWindow, ev->angle, ev->w, ev->h);
1197 RotationEvent rotationEvent;
1198 rotationEvent.angle = ev->angle;
1199 rotationEvent.winResize = 0;
1201 if(ev->w == 0 || ev->h == 0)
1203 // When rotation event does not have the window width or height,
1204 // previous DALi side window's size are used.
1205 ev->w = mWindowPositionSize.width;
1206 ev->h = mWindowPositionSize.height;
1209 mWindowRotationAngle = ev->angle;
1211 mWindowPositionSize.width = ev->w;
1212 mWindowPositionSize.height = ev->h;
1214 PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1216 rotationEvent.x = newPositionSize.x;
1217 rotationEvent.y = newPositionSize.y;
1218 rotationEvent.width = newPositionSize.width;
1219 rotationEvent.height = newPositionSize.height;
1221 mRotationSignal.Emit(rotationEvent);
1225 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1227 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1229 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1231 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1232 // by calling ecore_wl2_window_commit
1234 int tempWidth = ev->w;
1235 int tempHeight = ev->h;
1237 // Initialize with previous size for skip resize when new size is 0.
1238 // When window is just moved or window is resized by client application,
1239 // The configure notification event's size will be 0.
1240 // If new size is 0, the resized work should be skip.
1241 int newWidth = mWindowPositionSize.width;
1242 int newHeight = mWindowPositionSize.height;
1243 bool windowMoved = false, windowResized = false;
1245 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1250 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1252 windowResized = true;
1253 newWidth = tempWidth;
1254 newHeight = tempHeight;
1257 if(windowMoved || windowResized)
1259 mWindowPositionSize.x = ev->x;
1260 mWindowPositionSize.y = ev->y;
1261 mWindowPositionSize.width = newWidth;
1262 mWindowPositionSize.height = newHeight;
1263 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnConfiguration, Window (%p), Update position & resize signal by Ecore, current angle [%d] x[%d] y[%d] w[%d] h[%d]\n", mEcoreWindow, mWindowRotationAngle, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1265 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1267 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1268 mUpdatePositionSizeSignal.Emit(newPositionSize);
1271 mMaximizeChangedSignal.Emit(static_cast<bool>(ev->states & ECORE_WL2_WINDOW_STATE_MAXIMIZED));
1273 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1277 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1279 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1281 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1283 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
1285 Device::Class::Type deviceClass;
1286 Device::Subclass::Type deviceSubclass;
1288 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1289 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1291 PointState::Type state(PointState::DOWN);
1293 if(deviceClass != Device::Class::Type::MOUSE)
1295 // Check if the buttons field is set and ensure it's the primary touch button.
1296 // If this event was triggered by buttons other than the primary button (used for touch), then
1297 // just send an interrupted event to Core.
1298 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1300 state = PointState::INTERRUPTED;
1304 Integration::Point point;
1305 point.SetDeviceId(touchEvent->multi.device);
1306 point.SetState(state);
1307 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1308 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1309 point.SetPressure(touchEvent->multi.pressure);
1310 point.SetAngle(Degree(touchEvent->multi.angle));
1311 point.SetDeviceClass(deviceClass);
1312 point.SetDeviceSubclass(deviceSubclass);
1313 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1315 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1319 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1321 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1323 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1325 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
1327 Device::Class::Type deviceClass;
1328 Device::Subclass::Type deviceSubclass;
1330 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1331 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1333 Integration::Point point;
1334 point.SetDeviceId(touchEvent->multi.device);
1335 point.SetState(PointState::UP);
1336 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1337 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1338 point.SetPressure(touchEvent->multi.pressure);
1339 point.SetAngle(Degree(touchEvent->multi.angle));
1340 point.SetDeviceClass(deviceClass);
1341 point.SetDeviceSubclass(deviceSubclass);
1342 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1344 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1348 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1350 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1352 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1354 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
1356 Device::Class::Type deviceClass;
1357 Device::Subclass::Type deviceSubclass;
1359 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1360 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1362 Integration::Point point;
1363 point.SetDeviceId(touchEvent->multi.device);
1364 point.SetState(PointState::MOTION);
1365 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1366 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1367 point.SetPressure(touchEvent->multi.pressure);
1368 point.SetAngle(Degree(touchEvent->multi.angle));
1369 point.SetDeviceClass(deviceClass);
1370 point.SetDeviceSubclass(deviceSubclass);
1372 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1376 #ifdef OVER_TIZEN_VERSION_8
1377 void WindowBaseEcoreWl2::OnMouseButtonRelativeMove(void* data, int type, void* event)
1379 Ecore_Event_Mouse_Relative_Move* relativeMoveEvent = static_cast<Ecore_Event_Mouse_Relative_Move*>(event);
1381 if(relativeMoveEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1383 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_RELATIVE_MOVE");
1385 Device::Class::Type deviceClass;
1386 Device::Subclass::Type deviceSubclass;
1388 GetDeviceClass(ecore_device_class_get(relativeMoveEvent->dev), deviceClass);
1389 GetDeviceSubclass(ecore_device_subclass_get(relativeMoveEvent->dev), deviceSubclass);
1391 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);
1393 mMouseRelativeEventSignal.Emit(mouseRelativeEvent);
1398 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1400 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1402 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1404 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
1406 Device::Class::Type deviceClass;
1407 Device::Subclass::Type deviceSubclass;
1409 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1410 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1412 Integration::Point point;
1413 point.SetDeviceId(touchEvent->multi.device);
1414 point.SetState(PointState::INTERRUPTED);
1415 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1416 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1417 point.SetPressure(touchEvent->multi.pressure);
1418 point.SetAngle(Degree(touchEvent->multi.angle));
1419 point.SetDeviceClass(deviceClass);
1420 point.SetDeviceSubclass(deviceSubclass);
1422 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1424 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1428 #ifdef OVER_TIZEN_VERSION_8
1429 void WindowBaseEcoreWl2::OnPointerConstraints(void* data, int type, void* event)
1431 Ecore_Wl2_Event_Pointer_Constraints* constraintsEvent = static_cast<Ecore_Wl2_Event_Pointer_Constraints*>(event);
1433 if(constraintsEvent && constraintsEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1435 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_POINTER_CONSTRAINTS");
1436 Dali::Int32Pair position(constraintsEvent->x, constraintsEvent->y);
1437 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnPointerConstraints[%d, %d]\n", position.GetX(), position.GetY());
1439 mPointerConstraintsSignal.Emit(position, constraintsEvent->locked, constraintsEvent->confined);
1444 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1446 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1448 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1450 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
1452 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);
1454 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1456 mWheelEventSignal.Emit(wheelEvent);
1460 void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
1462 Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
1464 if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1466 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
1468 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);
1470 Device::Class::Type deviceClass;
1471 Device::Subclass::Type deviceSubclass;
1473 GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
1474 GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
1476 Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
1478 mMouseInOutEventSignal.Emit(inOutEvent);
1482 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1484 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1486 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnDetentRotation, Window (%p)\n", mEcoreWindow);
1488 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1490 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1492 mWheelEventSignal.Emit(wheelEvent);
1495 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1497 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1499 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1501 std::string keyName(keyEvent->keyname);
1502 std::string logicalKey("");
1503 std::string keyString("");
1504 std::string compose("");
1506 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_DOWN");
1508 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1509 if(keyEvent->compose)
1511 compose = keyEvent->compose;
1514 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1517 logicalKey = keyEvent->key;
1521 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1525 // Get a specific key code from dali key look up table.
1526 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1529 keyCode = (keyCode == -1) ? 0 : keyCode;
1530 int modifier(keyEvent->modifiers);
1531 unsigned long time = keyEvent->timestamp;
1532 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1534 keyCode = atoi(keyEvent->keyname + 8);
1537 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1538 if(keyEvent->string)
1540 keyString = keyEvent->string;
1543 std::string deviceName;
1544 Device::Class::Type deviceClass;
1545 Device::Subclass::Type deviceSubclass;
1547 GetDeviceName(keyEvent, deviceName);
1548 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1549 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1551 bool isRepeat = false;
1552 #ifdef OVER_TIZEN_VERSION_8
1553 if(keyEvent->event_flags & ECORE_EVENT_FLAG_REPEAT)
1559 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1560 keyEvent.isRepeat = isRepeat;
1561 keyEvent.windowId = GetNativeWindowId();
1563 mKeyEventSignal.Emit(keyEvent);
1567 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1569 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1571 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1573 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1574 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1575 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1577 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1580 #endif // Since ecore 1.23 version
1582 std::string keyName(keyEvent->keyname);
1583 std::string logicalKey("");
1584 std::string keyString("");
1585 std::string compose("");
1587 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_UP");
1589 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1590 if(keyEvent->compose)
1592 compose = keyEvent->compose;
1595 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1598 logicalKey = keyEvent->key;
1602 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1606 // Get a specific key code from dali key look up table.
1607 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1610 keyCode = (keyCode == -1) ? 0 : keyCode;
1611 int modifier(keyEvent->modifiers);
1612 unsigned long time = keyEvent->timestamp;
1613 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1615 keyCode = atoi(keyEvent->keyname + 8);
1618 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1619 if(keyEvent->string)
1621 keyString = keyEvent->string;
1624 std::string deviceName;
1625 Device::Class::Type deviceClass;
1626 Device::Subclass::Type deviceSubclass;
1628 GetDeviceName(keyEvent, deviceName);
1629 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1630 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1632 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1633 keyEvent.windowId = GetNativeWindowId();
1635 mKeyEventSignal.Emit(keyEvent);
1639 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1641 mSelectionDataSendSignal.Emit(event);
1644 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1646 mSelectionDataReceivedSignal.Emit(event);
1649 void WindowBaseEcoreWl2::OnFontNameChanged()
1651 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1654 void WindowBaseEcoreWl2::OnFontSizeChanged()
1656 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1659 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1661 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnTransitionEffectEvent, Window (%p)\n", mEcoreWindow);
1662 mTransitionEffectEventSignal.Emit(state, type);
1665 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1667 mKeyboardRepeatSettingsChangedSignal.Emit();
1670 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1672 mWindowRedrawRequestSignal.Emit();
1675 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1677 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1680 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, Window (%p), key:%s, value:%s \n", mEcoreWindow, message->key, message->val);
1681 std::string key(message->key);
1682 std::string value(message->val);
1683 Dali::Property::Array options;
1685 if(message->options)
1689 EINA_LIST_FOREACH(message->options, l, data)
1691 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, Window (%p), option: %s\n", mEcoreWindow, (char*)data);
1692 std::string option(static_cast<char*>(data));
1693 options.Add(option);
1697 mAuxiliaryMessageSignal.Emit(key, value, options);
1701 void WindowBaseEcoreWl2::OnEcoreEventConformantChange(void* event)
1703 Ecore_Wl2_Event_Conformant_Change* ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(event);
1704 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1706 WindowInsetsPartType partType = WindowInsetsPartType::STATUS_BAR;
1713 switch(ev->part_type)
1715 case ECORE_WL2_INDICATOR_PART:
1717 partType = WindowInsetsPartType::STATUS_BAR;
1718 ecore_wl2_window_indicator_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1721 case ECORE_WL2_KEYBOARD_PART:
1723 partType = WindowInsetsPartType::KEYBOARD;
1724 ecore_wl2_window_keyboard_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1727 case ECORE_WL2_CLIPBOARD_PART:
1729 partType = WindowInsetsPartType::CLIPBOARD;
1730 ecore_wl2_window_clipboard_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1739 WindowInsetsPartState partState = WindowInsetsPartState::INVISIBLE;
1746 // Insets are applied only if system UI(e.g. virtual keyboard) satisfies the following 2 conditions.
1747 // 1. System UI fits to the window width or height.
1748 // 2. System UI begins or ends from the edge of window.
1749 // Otherwise, we should not resize window content because there would be empty space around system UI.
1750 bool applyInsets = false;
1752 // Zero insets are applied if state is invisible
1759 partState = WindowInsetsPartState::VISIBLE;
1761 int winX = mWindowPositionSize.x;
1762 int winY = mWindowPositionSize.y;
1763 int winW = mWindowPositionSize.width;
1764 int winH = mWindowPositionSize.height;
1766 if((x <= winX) && (x + w >= winX + winW))
1768 if((y <= winY) && (y + h >= winY) && (y + h <= winY + winH))
1773 else if((y + h >= winY + winH) && (y >= winY) && (y <= winY + winH))
1775 bottom = winY + winH - y;
1779 else if((y <= winY) && (y + h >= winY + winH))
1781 if((x <= winX) && (x + w >= winX) && (x + w <= winX + winW))
1783 left = x + w - winX;
1786 else if((x + w >= winX + winW) && (x >= winX) && (x <= winX + winW))
1788 right = winX + winW - x;
1796 mInsetsChangedSignal.Emit(partType, partState, Extents(left, right, top, bottom));
1801 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1803 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1804 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1805 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1808 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1812 void WindowBaseEcoreWl2::OnMoveCompleted(void* event)
1814 Ecore_Wl2_Event_Window_Interactive_Move_Done* movedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Move_Done*>(event);
1815 if(movedDoneEvent && movedDoneEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1817 Dali::PositionSize orgPositionSize(movedDoneEvent->x, movedDoneEvent->y, movedDoneEvent->w, movedDoneEvent->h);
1818 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1819 Dali::Int32Pair newPosition(newPositionSize.x, newPositionSize.y);
1820 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnMoveCompleted, window(%p) has been moved by server[%d, %d]\n", mEcoreWindow, newPositionSize.x, newPositionSize.y);
1821 mMoveCompletedSignal.Emit(newPosition);
1825 void WindowBaseEcoreWl2::OnResizeCompleted(void* event)
1827 Ecore_Wl2_Event_Window_Interactive_Resize_Done* resizedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Resize_Done*>(event);
1828 if(resizedDoneEvent && resizedDoneEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1830 Dali::PositionSize orgPositionSize(resizedDoneEvent->x, resizedDoneEvent->y, resizedDoneEvent->w, resizedDoneEvent->h);
1831 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1832 Dali::Uint16Pair newSize(newPositionSize.width, newPositionSize.height);
1833 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnResizeCompleted, window(%p) has been resized by server[%d, %d]\n", mEcoreWindow, newPositionSize.width, newPositionSize.height);
1834 mResizeCompletedSignal.Emit(newSize);
1838 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1840 if(strcmp(interface, tizen_policy_interface.name) == 0)
1842 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1844 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1847 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1851 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1853 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1855 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1857 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1858 if(!mTizenDisplayPolicy)
1860 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1864 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1866 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1870 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1872 mTizenPolicy = NULL;
1873 mTizenDisplayPolicy = NULL;
1876 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)
1878 int originalX, originalY, originalWidth, originalHeight;
1879 bool changed = false;
1883 DALI_LOG_ERROR("Failed to get wayland surface in WindowBaseEcoreWl2::TizenPolicyConformantArea()\n");
1887 if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_INDICATOR)
1889 ecore_wl2_window_indicator_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1890 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1892 ecore_wl2_window_indicator_geometry_set(mEcoreWindow, x, y, w, h);
1897 * The given state is based on the visibility value of indicator.
1898 * Thus we need to add 1 to it before comparing with indicator state.
1900 Ecore_Wl2_Indicator_State indState = ecore_wl2_window_indicator_state_get(mEcoreWindow);
1901 if((state + 1) != indState)
1903 ecore_wl2_window_indicator_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Indicator_State>(state + 1));
1907 else if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_KEYBOARD)
1909 ecore_wl2_window_keyboard_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1910 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1912 ecore_wl2_window_keyboard_geometry_set(mEcoreWindow, x, y, w, h);
1917 * The given state is based on the visibility value of virtual keyboard window.
1918 * Thus we need to add 1 to it before comparing with keyboard state.
1920 Ecore_Wl2_Virtual_Keyboard_State kbdState = ecore_wl2_window_keyboard_state_get(mEcoreWindow);
1921 if((state + 1) != (kbdState))
1923 ecore_wl2_window_keyboard_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Virtual_Keyboard_State>(state + 1));
1927 else if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD)
1929 ecore_wl2_window_clipboard_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1930 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1932 ecore_wl2_window_clipboard_geometry_set(mEcoreWindow, x, y, w, h);
1937 * The given state is based on the visibility value of clipboard window.
1938 * Thus we need to add 1 to it before comparing with clipboard state.
1940 Ecore_Wl2_Clipboard_State clipState = ecore_wl2_window_clipboard_state_get(mEcoreWindow);
1941 if((state + 1) != clipState)
1943 ecore_wl2_window_clipboard_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Clipboard_State>(state + 1));
1950 Ecore_Wl2_Event_Conformant_Change* ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(calloc(1, sizeof(Ecore_Wl2_Event_Conformant_Change)));
1956 ev->win = GetNativeWindowId();
1957 ev->part_type = static_cast<Ecore_Wl2_Conformant_Part_Type>(conformantPart);
1959 ecore_event_add(ECORE_WL2_EVENT_CONFORMANT_CHANGE, ev, NULL, NULL);
1962 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);
1965 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1967 mNotificationLevel = level;
1968 mNotificationChangeState = state;
1969 mNotificationLevelChangeDone = true;
1971 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1974 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1976 mScreenOffMode = mode;
1977 mScreenOffModeChangeState = state;
1978 mScreenOffModeChangeDone = true;
1980 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1983 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1985 mBrightness = brightness;
1986 mBrightnessChangeState = state;
1987 mBrightnessChangeDone = true;
1989 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1992 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1994 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1995 KeyCodeMap foundKeyCode;
1997 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1998 if(sym == XKB_KEY_NoSymbol || !mKeyMap)
2000 DALI_LOG_ERROR("Failed to get keysym or keymap in WindowBaseEcoreWl2\n");
2004 foundKeyCode.keySym = sym;
2005 foundKeyCode.isKeyCode = false;
2006 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
2007 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
2010 Any WindowBaseEcoreWl2::GetNativeWindow()
2012 return mEcoreWindow;
2015 int WindowBaseEcoreWl2::GetNativeWindowId()
2017 return ecore_wl2_window_id_get(mEcoreWindow);
2020 std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
2022 #ifdef OVER_TIZEN_VERSION_7
2023 return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
2025 return std::string();
2029 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
2031 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
2033 START_DURATION_CHECK();
2034 if(totalAngle == 90 || totalAngle == 270)
2036 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
2040 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
2042 FINISH_DURATION_CHECK("wl_egl_window_create");
2044 return static_cast<EGLNativeWindowType>(mEglWindow);
2047 void WindowBaseEcoreWl2::DestroyEglWindow()
2049 if(mEglWindow != NULL)
2051 START_DURATION_CHECK();
2052 wl_egl_window_destroy(mEglWindow);
2053 FINISH_DURATION_CHECK("wl_egl_window_destroy");
2059 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
2061 wl_egl_window_tizen_rotation rotation;
2067 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
2072 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
2077 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
2082 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
2087 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
2092 START_DURATION_CHECK();
2093 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
2094 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_rotation");
2097 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
2099 wl_output_transform bufferTransform;
2105 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2110 bufferTransform = WL_OUTPUT_TRANSFORM_90;
2115 bufferTransform = WL_OUTPUT_TRANSFORM_180;
2120 bufferTransform = WL_OUTPUT_TRANSFORM_270;
2125 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2130 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_buffer_transform() with buffer Transform [%d]\n", bufferTransform);
2131 START_DURATION_CHECK();
2132 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
2133 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_buffer_transform");
2136 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
2138 wl_output_transform windowTransform;
2144 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2149 windowTransform = WL_OUTPUT_TRANSFORM_90;
2154 windowTransform = WL_OUTPUT_TRANSFORM_180;
2159 windowTransform = WL_OUTPUT_TRANSFORM_270;
2164 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2169 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_window_transform() with window Transform [%d]\n", windowTransform);
2170 START_DURATION_CHECK();
2171 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
2172 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_window_transform");
2175 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
2177 DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2178 START_DURATION_CHECK();
2179 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
2181 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
2182 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
2184 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
2185 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
2187 FINISH_DURATION_CHECK("wl_egl_window functions");
2190 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
2192 START_DURATION_CHECK();
2194 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
2195 FINISH_DURATION_CHECK("wl_egl_window_tizen_get_capabilities");
2197 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
2199 mSupportedPreProtation = true;
2202 mSupportedPreProtation = false;
2206 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
2208 PositionSize newPositionSize;
2209 int32_t screenWidth, screenHeight;
2210 WindowSystem::GetScreenSize(screenWidth, screenHeight);
2212 if(mWindowRotationAngle == 90)
2214 newPositionSize.x = positionSize.y;
2215 newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
2216 newPositionSize.width = positionSize.height;
2217 newPositionSize.height = positionSize.width;
2219 else if(mWindowRotationAngle == 180)
2221 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
2222 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
2223 newPositionSize.width = positionSize.width;
2224 newPositionSize.height = positionSize.height;
2226 else if(mWindowRotationAngle == 270)
2228 newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
2229 newPositionSize.y = positionSize.x;
2230 newPositionSize.width = positionSize.height;
2231 newPositionSize.height = positionSize.width;
2235 newPositionSize.x = positionSize.x;
2236 newPositionSize.y = positionSize.y;
2237 newPositionSize.width = positionSize.width;
2238 newPositionSize.height = positionSize.height;
2241 return newPositionSize;
2244 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
2246 PositionSize newPositionSize;
2247 int32_t screenWidth, screenHeight;
2248 WindowSystem::GetScreenSize(screenWidth, screenHeight);
2250 if(mWindowRotationAngle == 90)
2252 newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
2253 newPositionSize.y = positionSize.x;
2254 newPositionSize.width = positionSize.height;
2255 newPositionSize.height = positionSize.width;
2257 else if(mWindowRotationAngle == 180)
2259 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
2260 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
2261 newPositionSize.width = positionSize.width;
2262 newPositionSize.height = positionSize.height;
2264 else if(mWindowRotationAngle == 270)
2266 newPositionSize.x = positionSize.y;
2267 newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
2268 newPositionSize.width = positionSize.height;
2269 newPositionSize.height = positionSize.width;
2273 newPositionSize.x = positionSize.x;
2274 newPositionSize.y = positionSize.y;
2275 newPositionSize.width = positionSize.width;
2276 newPositionSize.height = positionSize.height;
2279 return newPositionSize;
2282 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
2284 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2286 mWindowPositionSize = newPositionSize;
2287 DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
2288 START_DURATION_CHECK();
2289 ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
2290 FINISH_DURATION_CHECK("ecore_wl2_window_position_set");
2293 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
2295 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2297 mWindowPositionSize = newPositionSize;
2298 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);
2299 START_DURATION_CHECK();
2300 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
2301 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
2304 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
2306 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2308 mWindowPositionSize = newPositionSize;
2309 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);
2310 START_DURATION_CHECK();
2311 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
2312 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
2315 void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
2317 #ifdef OVER_TIZEN_VERSION_8
2318 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);
2319 START_DURATION_CHECK();
2320 ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
2321 FINISH_DURATION_CHECK("ecore_wl2_window_layout_set");
2325 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
2327 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
2328 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
2331 void WindowBaseEcoreWl2::Raise()
2333 START_DURATION_CHECK();
2334 // Use ecore_wl2_window_activate to prevent the window shown without rendering
2335 ecore_wl2_window_activate(mEcoreWindow);
2336 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
2339 void WindowBaseEcoreWl2::Lower()
2341 START_DURATION_CHECK();
2342 ecore_wl2_window_lower(mEcoreWindow);
2343 FINISH_DURATION_CHECK("ecore_wl2_window_lower");
2346 void WindowBaseEcoreWl2::Activate()
2348 START_DURATION_CHECK();
2349 ecore_wl2_window_activate(mEcoreWindow);
2350 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
2353 void WindowBaseEcoreWl2::Maximize(bool maximize)
2355 START_DURATION_CHECK();
2356 ecore_wl2_window_maximized_set(mEcoreWindow, maximize);
2357 FINISH_DURATION_CHECK("ecore_wl2_window_maximized_set");
2360 bool WindowBaseEcoreWl2::IsMaximized() const
2362 return ecore_wl2_window_maximized_get(mEcoreWindow);
2365 void WindowBaseEcoreWl2::SetMaximumSize(Dali::Window::WindowSize size)
2367 DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2368 START_DURATION_CHECK();
2369 ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2370 FINISH_DURATION_CHECK("ecore_wl2_window_maximum_size_set");
2371 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2374 void WindowBaseEcoreWl2::Minimize(bool minimize)
2376 START_DURATION_CHECK();
2377 ecore_wl2_window_iconified_set(mEcoreWindow, minimize);
2378 FINISH_DURATION_CHECK("ecore_wl2_window_iconified_set");
2381 bool WindowBaseEcoreWl2::IsMinimized() const
2383 return ecore_wl2_window_iconified_get(mEcoreWindow);
2386 void WindowBaseEcoreWl2::SetMimimumSize(Dali::Window::WindowSize size)
2388 DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2389 START_DURATION_CHECK();
2390 ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2391 FINISH_DURATION_CHECK("ecore_wl2_window_minimum_size_set");
2392 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2395 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
2397 int rotations[4] = {0};
2398 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
2399 for(std::size_t i = 0; i < angles.size(); ++i)
2401 rotations[i] = static_cast<int>(angles[i]);
2402 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
2405 START_DURATION_CHECK();
2406 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
2407 FINISH_DURATION_CHECK("ecore_wl2_window_available_rotations_set");
2410 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
2412 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
2413 START_DURATION_CHECK();
2414 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
2415 FINISH_DURATION_CHECK("ecore_wl2_window_preferred_rotation_set");
2418 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
2420 START_DURATION_CHECK();
2421 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
2422 FINISH_DURATION_CHECK("ecore_wl2_window_focus_skip_set");
2425 void WindowBaseEcoreWl2::Show()
2429 START_DURATION_CHECK();
2430 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
2431 FINISH_DURATION_CHECK("ecore_wl2_window_geometry_set");
2435 ecore_wl2_window_show(mEcoreWindow);
2438 void WindowBaseEcoreWl2::Hide()
2441 ecore_wl2_window_hide(mEcoreWindow);
2444 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
2446 return mSupportedAuxiliaryHints.size();
2449 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
2451 if(index >= GetSupportedAuxiliaryHintCount())
2453 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
2456 return mSupportedAuxiliaryHints[index];
2459 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
2461 bool supported = false;
2463 // Check if the hint is suppported
2464 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
2475 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
2479 // Check if the hint is already added
2480 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2482 if(mAuxiliaryHints[i].first == hint)
2484 // Just change the value
2485 mAuxiliaryHints[i].second = value;
2487 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
2489 return i + 1; // id is index + 1
2494 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
2496 unsigned int id = mAuxiliaryHints.size();
2498 START_DURATION_CHECK();
2499 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
2500 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_add");
2502 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
2507 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
2509 if(id == 0 || id > mAuxiliaryHints.size())
2511 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
2515 mAuxiliaryHints[id - 1].second = std::string();
2517 START_DURATION_CHECK();
2518 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
2519 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_del");
2521 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
2526 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
2528 if(id == 0 || id > mAuxiliaryHints.size())
2530 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
2534 mAuxiliaryHints[id - 1].second = value;
2536 START_DURATION_CHECK();
2537 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
2538 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_change");
2540 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());
2545 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
2547 if(id == 0 || id > mAuxiliaryHints.size())
2549 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
2550 return std::string();
2553 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());
2555 return mAuxiliaryHints[id - 1].second;
2558 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
2560 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2562 if(mAuxiliaryHints[i].first == hint)
2564 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
2569 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
2574 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
2576 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
2578 Eina_Rectangle rect;
2579 rect.x = convertRegion.x;
2580 rect.y = convertRegion.y;
2581 rect.w = convertRegion.width;
2582 rect.h = convertRegion.height;
2584 DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2585 START_DURATION_CHECK();
2586 ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
2587 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_set");
2588 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2591 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
2596 Ecore_Wl2_Window_Type windowType;
2600 case Dali::WindowType::NORMAL:
2602 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::NORMAL\n");
2603 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2606 case Dali::WindowType::NOTIFICATION:
2608 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::NOTIFICATION\n");
2609 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
2612 case Dali::WindowType::UTILITY:
2614 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::UTILITY\n");
2615 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
2618 case Dali::WindowType::DIALOG:
2620 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::DIALOG\n");
2621 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
2624 case Dali::WindowType::IME:
2626 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::IME\n");
2627 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
2630 case Dali::WindowType::DESKTOP:
2632 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::DESKTOP\n");
2633 windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
2638 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, default window type\n");
2639 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2644 START_DURATION_CHECK();
2645 ecore_wl2_window_type_set(mEcoreWindow, windowType);
2646 FINISH_DURATION_CHECK("ecore_wl2_window_type_set");
2650 Dali::WindowType WindowBaseEcoreWl2::GetType() const
2652 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::GetType(), Window (%p), DALI WindType: %d, mIsIMEWindowInitialized: %d\n", mEcoreWindow, mType, mIsIMEWindowInitialized);
2656 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
2658 START_DURATION_CHECK();
2659 while(!mTizenPolicy)
2661 wl_display_dispatch_queue(mDisplay, mEventQueue);
2664 int notificationLevel;
2666 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetNotificationLevel(), Window (%p), level [%d]\n", mEcoreWindow, level);
2669 case Dali::WindowNotificationLevel::NONE:
2671 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
2674 case Dali::WindowNotificationLevel::BASE:
2676 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2679 case Dali::WindowNotificationLevel::MEDIUM:
2681 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
2684 case Dali::WindowNotificationLevel::HIGH:
2686 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
2689 case Dali::WindowNotificationLevel::TOP:
2691 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
2696 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetNotificationLevel(), invalid level [%d]\n", level);
2697 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2702 mNotificationLevelChangeDone = false;
2703 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2705 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2709 while(!mNotificationLevelChangeDone && count < 3)
2711 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2712 wl_display_dispatch_queue(mDisplay, mEventQueue);
2715 FINISH_DURATION_CHECK("ecore_wl2 & wl_display");
2717 if(!mNotificationLevelChangeDone)
2719 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2720 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2722 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2724 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2725 return Dali::WindowOperationResult::PERMISSION_DENIED;
2728 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2730 return Dali::WindowOperationResult::SUCCEED;
2733 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2735 while(!mTizenPolicy)
2737 wl_display_dispatch_queue(mDisplay, mEventQueue);
2742 while(!mNotificationLevelChangeDone && count < 3)
2744 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2745 wl_display_dispatch_queue(mDisplay, mEventQueue);
2749 if(!mNotificationLevelChangeDone)
2751 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2752 return Dali::WindowNotificationLevel::NONE;
2755 Dali::WindowNotificationLevel level;
2757 switch(mNotificationLevel)
2759 case TIZEN_POLICY_LEVEL_NONE:
2761 level = Dali::WindowNotificationLevel::NONE;
2764 case TIZEN_POLICY_LEVEL_DEFAULT:
2766 level = Dali::WindowNotificationLevel::BASE;
2769 case TIZEN_POLICY_LEVEL_MEDIUM:
2771 level = Dali::WindowNotificationLevel::MEDIUM;
2774 case TIZEN_POLICY_LEVEL_HIGH:
2776 level = Dali::WindowNotificationLevel::HIGH;
2779 case TIZEN_POLICY_LEVEL_TOP:
2781 level = Dali::WindowNotificationLevel::TOP;
2786 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2787 level = Dali::WindowNotificationLevel::NONE;
2792 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2797 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2799 while(!mTizenPolicy)
2801 wl_display_dispatch_queue(mDisplay, mEventQueue);
2804 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2807 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2809 while(!mTizenPolicy)
2811 wl_display_dispatch_queue(mDisplay, mEventQueue);
2814 mScreenOffModeChangeDone = false;
2815 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2817 unsigned int mode = 0;
2819 switch(screenOffMode)
2821 case WindowScreenOffMode::TIMEOUT:
2826 case WindowScreenOffMode::NEVER:
2833 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2837 while(!mScreenOffModeChangeDone && count < 3)
2839 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2840 wl_display_dispatch_queue(mDisplay, mEventQueue);
2844 if(!mScreenOffModeChangeDone)
2846 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2847 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2849 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2851 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2852 return Dali::WindowOperationResult::PERMISSION_DENIED;
2855 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2857 return Dali::WindowOperationResult::SUCCEED;
2860 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2862 while(!mTizenPolicy)
2864 wl_display_dispatch_queue(mDisplay, mEventQueue);
2869 while(!mScreenOffModeChangeDone && count < 3)
2871 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2872 wl_display_dispatch_queue(mDisplay, mEventQueue);
2876 if(!mScreenOffModeChangeDone)
2878 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2879 return WindowScreenOffMode::TIMEOUT;
2882 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2884 switch(mScreenOffMode)
2888 screenMode = WindowScreenOffMode::TIMEOUT;
2893 screenMode = WindowScreenOffMode::NEVER;
2898 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2903 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2905 START_DURATION_CHECK();
2906 while(!mTizenDisplayPolicy)
2908 wl_display_dispatch_queue(mDisplay, mEventQueue);
2911 mBrightnessChangeDone = false;
2912 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2914 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2918 while(!mBrightnessChangeDone && count < 3)
2920 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2921 wl_display_dispatch_queue(mDisplay, mEventQueue);
2924 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2926 if(!mBrightnessChangeDone)
2928 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2929 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2931 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2933 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2934 return Dali::WindowOperationResult::PERMISSION_DENIED;
2937 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2939 return Dali::WindowOperationResult::SUCCEED;
2942 int WindowBaseEcoreWl2::GetBrightness() const
2944 START_DURATION_CHECK();
2945 while(!mTizenDisplayPolicy)
2947 wl_display_dispatch_queue(mDisplay, mEventQueue);
2952 while(!mBrightnessChangeDone && count < 3)
2954 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2955 wl_display_dispatch_queue(mDisplay, mEventQueue);
2958 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2960 if(!mBrightnessChangeDone)
2962 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2966 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2971 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2973 Ecore_Wl2_Window_Keygrab_Mode mode;
2977 case KeyGrab::TOPMOST:
2979 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2982 case KeyGrab::SHARED:
2984 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2987 case KeyGrab::OVERRIDE_EXCLUSIVE:
2989 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2992 case KeyGrab::EXCLUSIVE:
2994 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
3003 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
3006 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
3008 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
3011 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
3013 int keyCount = key.Count();
3014 int keyGrabModeCount = grabMode.Count();
3016 if(keyCount != keyGrabModeCount || keyCount == 0)
3023 Eina_List* keyList = NULL;
3024 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
3026 for(int index = 0; index < keyCount; ++index)
3028 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
3030 switch(grabMode[index])
3032 case KeyGrab::TOPMOST:
3034 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
3037 case KeyGrab::SHARED:
3039 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
3042 case KeyGrab::OVERRIDE_EXCLUSIVE:
3044 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
3047 case KeyGrab::EXCLUSIVE:
3049 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
3054 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
3059 keyList = eina_list_append(keyList, &info);
3062 START_DURATION_CHECK();
3063 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
3064 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_set");
3066 result.Resize(keyCount, true);
3068 Eina_List* l = NULL;
3069 Eina_List* m = NULL;
3070 void* listData = NULL;
3072 if(grabList != NULL)
3074 EINA_LIST_FOREACH(grabList, m, data)
3077 EINA_LIST_FOREACH(keyList, l, listData)
3079 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
3081 DALI_LOG_ERROR("input key list has null data!");
3085 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
3087 result[index] = false;
3096 eina_list_free(keyList);
3097 eina_list_free(grabList);
3103 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
3105 int keyCount = key.Count();
3113 Eina_List* keyList = NULL;
3114 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
3116 for(int index = 0; index < keyCount; ++index)
3118 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
3119 keyList = eina_list_append(keyList, &info);
3122 START_DURATION_CHECK();
3123 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
3124 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_unset");
3126 result.Resize(keyCount, true);
3128 Eina_List* l = NULL;
3129 Eina_List* m = NULL;
3130 void* listData = NULL;
3133 if(ungrabList != NULL)
3135 EINA_LIST_FOREACH(ungrabList, m, data)
3138 EINA_LIST_FOREACH(keyList, l, listData)
3140 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
3142 result[index] = false;
3151 eina_list_free(keyList);
3152 eina_list_free(ungrabList);
3158 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
3163 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
3165 // 1 inch = 25.4 millimeters
3166 xres = ecore_wl2_output_dpi_get(output);
3167 yres = ecore_wl2_output_dpi_get(output);
3169 dpiHorizontal = int(xres + 0.5f); // rounding
3170 dpiVertical = int(yres + 0.5f);
3173 int WindowBaseEcoreWl2::GetWindowRotationAngle() const
3175 int orientation = mWindowRotationAngle;
3176 if(mSupportedPreProtation)
3183 int WindowBaseEcoreWl2::GetScreenRotationAngle()
3185 if(mSupportedPreProtation)
3187 DALI_LOG_RELEASE_INFO("Support PreRotation and return 0\n");
3191 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
3197 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
3199 mScreenRotationAngle = transform * 90;
3200 return mScreenRotationAngle;
3203 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
3205 mWindowRotationAngle = degree;
3206 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
3209 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
3211 START_DURATION_CHECK();
3212 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
3213 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_change_done_send");
3216 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
3218 START_DURATION_CHECK();
3219 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
3220 FINISH_DURATION_CHECK("ecore_wl2_window_alpha_set");
3223 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
3225 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
3228 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
3231 START_DURATION_CHECK();
3232 ecore_wl2_display_sync(display);
3234 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
3236 if(mEcoreWindow == 0)
3238 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
3242 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
3243 FINISH_DURATION_CHECK("ecore_wl2 functions");
3246 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
3248 Ecore_Wl2_Window* ecoreParent = NULL;
3251 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
3252 ecoreParent = winBaseEcore2->mEcoreWindow;
3255 START_DURATION_CHECK();
3256 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
3257 FINISH_DURATION_CHECK("ecore_wl2_window_transient_parent_set");
3260 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
3262 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
3265 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
3267 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
3270 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
3272 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);
3273 START_DURATION_CHECK();
3274 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
3275 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_geometry_set");
3278 void WindowBaseEcoreWl2::InitializeIme()
3280 Eina_Iterator* globals;
3281 struct wl_registry* registry;
3282 Ecore_Wl2_Global* global;
3283 Ecore_Wl2_Display* ecoreWl2Display;
3285 if(mIsIMEWindowInitialized)
3287 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::InitializeIme, IME Window is already initialized\n");
3291 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
3293 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
3297 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p, mIsIMEWindowInitialized: %d\n", ecoreWl2Display, mEcoreWindow, mIsIMEWindowInitialized);
3299 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
3301 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
3305 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
3307 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
3311 START_DURATION_CHECK();
3312 EINA_ITERATOR_FOREACH(globals, global)
3314 #ifdef OVER_TIZEN_VERSION_7
3315 if(strcmp(global->interface, "zwp_input_panel_v1") == 0)
3317 mWlInputPanel = (zwp_input_panel_v1*)wl_registry_bind(registry, global->id, &zwp_input_panel_v1_interface, 1);
3320 if(strcmp(global->interface, "wl_input_panel") == 0)
3322 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
3325 else if(strcmp(global->interface, "wl_output") == 0)
3327 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
3333 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
3339 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
3342 #ifdef OVER_TIZEN_VERSION_7
3343 mWlInputPanelSurface = zwp_input_panel_v1_get_input_panel_surface(mWlInputPanel, mWlSurface);
3345 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
3347 if(!mWlInputPanelSurface)
3349 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
3352 #ifdef OVER_TIZEN_VERSION_7
3353 zwp_input_panel_surface_v1_set_toplevel(mWlInputPanelSurface, mWlOutput, ZWP_INPUT_PANEL_SURFACE_V1_POSITION_CENTER_BOTTOM);
3355 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
3357 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_toplevel");
3358 mIsIMEWindowInitialized = true;
3361 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
3363 if(!mWlInputPanelSurface)
3365 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
3369 START_DURATION_CHECK();
3370 #ifdef OVER_TIZEN_VERSION_7
3371 zwp_input_panel_surface_v1_set_ready(mWlInputPanelSurface, 1);
3373 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
3375 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_ready");
3378 void WindowBaseEcoreWl2::RequestMoveToServer()
3380 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3383 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
3387 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3390 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
3394 START_DURATION_CHECK();
3395 ecore_wl2_window_move(mEcoreWindow, input);
3396 FINISH_DURATION_CHECK("ecore_wl2_window_move");
3397 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
3400 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
3402 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3405 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
3409 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3412 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
3416 ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
3418 START_DURATION_CHECK();
3419 ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
3420 FINISH_DURATION_CHECK("ecore_wl2_window_resize");
3421 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);
3424 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
3426 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
3427 START_DURATION_CHECK();
3430 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
3434 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
3436 FINISH_DURATION_CHECK("ecore_wl2_window_floating_mode_set");
3439 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
3441 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
3444 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
3446 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
3447 Eina_Rectangle rect;
3449 rect.x = convertRegion.x;
3450 rect.y = convertRegion.y;
3451 rect.w = convertRegion.width;
3452 rect.h = convertRegion.height;
3454 DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3455 START_DURATION_CHECK();
3456 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
3457 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_add");
3458 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3461 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
3463 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
3464 Eina_Rectangle rect;
3466 rect.x = convertRegion.x;
3467 rect.y = convertRegion.y;
3468 rect.w = convertRegion.width;
3469 rect.h = convertRegion.height;
3471 DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3472 START_DURATION_CHECK();
3473 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
3474 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_subtract");
3475 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3478 bool WindowBaseEcoreWl2::PointerConstraintsLock()
3480 #ifdef OVER_TIZEN_VERSION_8
3481 return ecore_wl2_window_pointer_constraints_lock_pointer(mEcoreWindow);
3487 bool WindowBaseEcoreWl2::PointerConstraintsUnlock()
3489 #ifdef OVER_TIZEN_VERSION_8
3490 return ecore_wl2_window_pointer_constraints_unlock_pointer(mEcoreWindow);
3496 void WindowBaseEcoreWl2::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
3498 #ifdef OVER_TIZEN_VERSION_8
3499 ecore_wl2_window_locked_pointer_region_set(mEcoreWindow, x, y, width, height);
3500 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3504 void WindowBaseEcoreWl2::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
3506 #ifdef OVER_TIZEN_VERSION_8
3507 ecore_wl2_window_locked_pointer_cursor_position_hint_set(mEcoreWindow, x, y);
3508 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3512 bool WindowBaseEcoreWl2::PointerWarp(int32_t x, int32_t y)
3514 return ecore_wl2_window_pointer_warp(mEcoreWindow, x, y);
3517 void WindowBaseEcoreWl2::CursorVisibleSet(bool visible)
3519 #ifdef OVER_TIZEN_VERSION_8
3520 ecore_wl2_window_cursor_visible_set(mEcoreWindow, visible);
3524 // Request grab key events according to the requested device subtype
3525 //(For now, subtype could be '0'/'11'/'12' which equals to ECORE_DEVICE_SUBCLASS_NONE/REMOCON/VIRTUAL_KEYBOARD)
3526 bool WindowBaseEcoreWl2::KeyboardGrab(Device::Subclass::Type deviceSubclass)
3528 #ifdef OVER_TIZEN_VERSION_8
3529 Ecore_Device_Subclass ecoreDeviceSubclass;
3530 switch(deviceSubclass)
3532 case Device::Subclass::NONE:
3534 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_NONE;
3537 case Device::Subclass::REMOCON:
3539 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_REMOCON;
3542 case Device::Subclass::VIRTUAL_KEYBOARD:
3544 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD;
3549 DALI_LOG_ERROR("deviceSubclass : %d type is not support, subtype could be 'NONE', 'REMOCON', 'VIRTUAL_KEYBOARD'\n");
3553 return ecore_wl2_window_keyboard_grab(mEcoreWindow, ecoreDeviceSubclass);
3559 // Request ungrab key events
3560 bool WindowBaseEcoreWl2::KeyboardUnGrab()
3562 #ifdef OVER_TIZEN_VERSION_8
3563 return ecore_wl2_window_keyboard_ungrab(mEcoreWindow);
3569 void WindowBaseEcoreWl2::SetFullScreen(bool fullscreen)
3571 DALI_LOG_RELEASE_INFO("ecore_wl2_window_fullscreen_set, window: [%p], fullscreen [%d]\n", mEcoreWindow, fullscreen);
3572 START_DURATION_CHECK();
3573 ecore_wl2_window_fullscreen_set(mEcoreWindow, fullscreen);
3574 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3575 FINISH_DURATION_CHECK("ecore_wl2_window_fullscreen_set");
3578 bool WindowBaseEcoreWl2::GetFullScreen()
3580 return ecore_wl2_window_fullscreen_get(mEcoreWindow);
3583 void WindowBaseEcoreWl2::SetFrontBufferRendering(bool enable)
3585 mIsFrontBufferRendering = enable;
3588 bool WindowBaseEcoreWl2::GetFrontBufferRendering()
3590 return mIsFrontBufferRendering;
3593 void WindowBaseEcoreWl2::SetEglWindowFrontBufferMode(bool enable)
3595 wl_egl_window_tizen_set_frontbuffer_mode(mEglWindow, enable);
3598 } // namespace Adaptor
3600 } // namespace Internal
3604 #pragma GCC diagnostic pop