2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Ecore is littered with C style cast
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wold-style-cast"
23 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
26 #include <dali/internal/input/common/key-impl.h>
27 #include <dali/internal/system/common/time-service.h>
28 #include <dali/internal/window-system/common/window-impl.h>
29 #include <dali/internal/window-system/common/window-render-surface.h>
30 #include <dali/internal/window-system/common/window-system.h>
33 #include <Ecore_Input.h>
34 #include <dali/integration-api/debug.h>
35 #include <dali/integration-api/trace.h>
36 #include <dali/public-api/adaptor-framework/window-enumerations.h>
37 #include <dali/public-api/events/mouse-button.h>
38 #include <dali/public-api/object/any.h>
40 #if defined(VCONF_ENABLED)
41 #include <vconf-keys.h>
45 #define START_DURATION_CHECK() \
46 uint32_t durationMilliSeconds = static_cast<uint32_t>(-1); \
47 uint32_t startTime, endTime; \
48 startTime = TimeService::GetMilliSeconds();
50 #define FINISH_DURATION_CHECK(functionName) \
51 endTime = TimeService::GetMilliSeconds(); \
52 durationMilliSeconds = endTime - startTime; \
53 if(durationMilliSeconds > 0) \
55 DALI_LOG_DEBUG_INFO("%s : duration [%u ms]\n", functionName, durationMilliSeconds); \
58 #include <wayland-egl-tizen.h>
68 #if defined(DEBUG_ENABLED)
69 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
72 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
75 * @brief Enumeration of location for window resized by display server.
77 enum class ResizeLocation
79 INVALID = 0, ///< Invalid value
80 TOP_LEFT = 5, ///< Start resizing window to the top-left edge.
81 LEFT = 4, ///< Start resizing window to the left side.
82 BOTTOM_LEFT = 6, ///< Start resizing window to the bottom-left edge.
83 BOTTOM = 2, ///< Start resizing window to the bottom side.
84 BOTTOM_RIGHT = 10, ///< Start resizing window to the bottom-right edge.
85 RIGHT = 8, ///< Start resizing window to the right side.
86 TOP_RIGHT = 9, ///< Start resizing window to the top-right edge.
87 TOP = 1 ///< Start resizing window to the top side.
90 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
91 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
92 const ResizeLocation RESIZE_LOCATIONS[] = {ResizeLocation::TOP_LEFT, ResizeLocation::LEFT, ResizeLocation::BOTTOM_LEFT, ResizeLocation::BOTTOM, ResizeLocation::BOTTOM_RIGHT, ResizeLocation::RIGHT, ResizeLocation::TOP_RIGHT, ResizeLocation::TOP, ResizeLocation::INVALID};
94 #if defined(VCONF_ENABLED)
95 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
101 xkb_keycode_t keyCode;
106 * Get the device name from the provided ecore key event
108 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
110 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
114 result = ecoreDeviceName;
119 * Get the device class from the provided ecore event
121 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
123 switch(ecoreDeviceClass)
125 case ECORE_DEVICE_CLASS_SEAT:
127 deviceClass = Device::Class::USER;
130 case ECORE_DEVICE_CLASS_KEYBOARD:
132 deviceClass = Device::Class::KEYBOARD;
135 case ECORE_DEVICE_CLASS_MOUSE:
137 deviceClass = Device::Class::MOUSE;
140 case ECORE_DEVICE_CLASS_TOUCH:
142 deviceClass = Device::Class::TOUCH;
145 case ECORE_DEVICE_CLASS_PEN:
147 deviceClass = Device::Class::PEN;
150 case ECORE_DEVICE_CLASS_POINTER:
152 deviceClass = Device::Class::POINTER;
155 case ECORE_DEVICE_CLASS_GAMEPAD:
157 deviceClass = Device::Class::GAMEPAD;
162 deviceClass = Device::Class::NONE;
168 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
170 switch(ecoreDeviceSubclass)
172 case ECORE_DEVICE_SUBCLASS_FINGER:
174 deviceSubclass = Device::Subclass::FINGER;
177 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
179 deviceSubclass = Device::Subclass::FINGERNAIL;
182 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
184 deviceSubclass = Device::Subclass::KNUCKLE;
187 case ECORE_DEVICE_SUBCLASS_PALM:
189 deviceSubclass = Device::Subclass::PALM;
192 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
194 deviceSubclass = Device::Subclass::HAND_SIDE;
197 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
199 deviceSubclass = Device::Subclass::HAND_FLAT;
202 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
204 deviceSubclass = Device::Subclass::PEN_TIP;
207 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
209 deviceSubclass = Device::Subclass::TRACKPAD;
212 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
214 deviceSubclass = Device::Subclass::TRACKPOINT;
217 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
219 deviceSubclass = Device::Subclass::TRACKBALL;
222 case ECORE_DEVICE_SUBCLASS_REMOCON:
224 deviceSubclass = Device::Subclass::REMOCON;
227 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
229 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
234 deviceSubclass = Device::Subclass::NONE;
240 void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
242 KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
243 if(foundKeyCode->isKeyCode)
248 xkb_keysym_t keySym = foundKeyCode->keySym;
250 const xkb_keysym_t* symsOut = NULL;
252 nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
256 if(*symsOut == keySym)
258 foundKeyCode->keyCode = key;
259 foundKeyCode->isKeyCode = true;
265 * Return the recalculated window resizing location according to the current orientation.
267 ResizeLocation RecalculateLocationToCurrentOrientation(WindowResizeDirection direction, int windowRotationAngle)
272 case WindowResizeDirection::TOP_LEFT:
277 case WindowResizeDirection::LEFT:
282 case WindowResizeDirection::BOTTOM_LEFT:
287 case WindowResizeDirection::BOTTOM:
292 case WindowResizeDirection::BOTTOM_RIGHT:
297 case WindowResizeDirection::RIGHT:
302 case WindowResizeDirection::TOP_RIGHT:
307 case WindowResizeDirection::TOP:
319 if(index != 8 && windowRotationAngle != 0)
321 index = (index + (windowRotationAngle / 90) * 2) % 8;
324 return RESIZE_LOCATIONS[index];
327 /////////////////////////////////////////////////////////////////////////////////////////////////
329 /////////////////////////////////////////////////////////////////////////////////////////////////
331 /// Called when the window iconify state is changed.
332 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
334 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
337 return windowBase->OnIconifyStateChanged(data, type, event);
340 return ECORE_CALLBACK_PASS_ON;
343 /// Called when the window gains focus
344 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
346 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
349 return windowBase->OnFocusIn(data, type, event);
352 return ECORE_CALLBACK_PASS_ON;
355 /// Called when the window loses focus
356 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
358 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
361 return windowBase->OnFocusOut(data, type, event);
364 return ECORE_CALLBACK_PASS_ON;
367 /// Called when the output is transformed
368 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
370 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
373 return windowBase->OnOutputTransform(data, type, event);
376 return ECORE_CALLBACK_PASS_ON;
379 /// Called when the output transform should be ignored
380 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
382 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
385 return windowBase->OnIgnoreOutputTransform(data, type, event);
388 return ECORE_CALLBACK_PASS_ON;
392 * Called when rotate event is recevied.
394 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
396 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
399 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
400 windowBase->OnRotation(data, type, event);
402 return ECORE_CALLBACK_PASS_ON;
406 * Called when configure event is recevied.
408 static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
410 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
413 windowBase->OnConfiguration(data, type, event);
415 return ECORE_CALLBACK_PASS_ON;
418 /////////////////////////////////////////////////////////////////////////////////////////////////
420 /////////////////////////////////////////////////////////////////////////////////////////////////
423 * Called when a touch down is received.
425 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
427 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
430 windowBase->OnMouseButtonDown(data, type, event);
432 return ECORE_CALLBACK_PASS_ON;
436 * Called when a touch up is received.
438 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
440 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
443 windowBase->OnMouseButtonUp(data, type, event);
445 return ECORE_CALLBACK_PASS_ON;
449 * Called when a touch motion is received.
451 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
453 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
456 windowBase->OnMouseButtonMove(data, type, event);
458 return ECORE_CALLBACK_PASS_ON;
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);
959 ecore_wl2_window_free(mEcoreWindow);
963 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
965 if(surface.Empty() == false)
967 // check we have a valid type
968 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
970 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
974 // we own the surface about to created
976 CreateWindow(positionSize);
979 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
981 SetTransparency(isTransparent);
983 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
984 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
988 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
990 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
993 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
994 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
995 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
996 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
997 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
999 // Register Rotate event
1000 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
1002 // Register Configure event
1003 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
1005 // Register Touch events
1006 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
1007 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
1008 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
1009 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
1010 #ifdef OVER_TIZEN_VERSION_8
1011 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_RELATIVE_MOVE, EcoreEventMouseButtonRelativeMove, this));
1013 // Register pointer lock/unlock event
1014 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_POINTER_CONSTRAINTS, EcoreEventPointerConstraints, this));
1017 // Register Mouse wheel events
1018 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
1020 // Register Mouse IO events
1021 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
1022 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
1024 // Register Detent event
1025 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
1027 // Register Key events
1028 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
1029 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
1031 // Register Selection event - clipboard selection
1032 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
1033 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OFFER_DATA_READY, EcoreEventDataReceive, this));
1035 // Register Effect Start/End event
1036 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
1037 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
1039 // Register Keyboard repeat event
1040 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
1042 // Register Window redraw request event
1043 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
1045 // Register Window auxiliary event
1046 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
1048 // Register Conformant change event
1049 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_CONFORMANT_CHANGE, EcoreEventConformantChange, this));
1051 #if defined(VCONF_ENABLED)
1052 // Register Vconf notify - font name and size
1053 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
1054 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
1057 // Register Window is moved and resized done event.
1058 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE, EcoreEventWindowMoveCompleted, this));
1059 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE, EcoreEventWindowResizeCompleted, this));
1061 mDisplay = ecore_wl2_display_get(display);
1064 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
1067 mEventQueue = wl_display_create_queue(mDisplay);
1070 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
1072 wl_registry* registry = wl_display_get_registry(displayWrapper);
1073 wl_registry_add_listener(registry, ®istryListener, this);
1075 // To support ECORE_WL2_EVENT_CONFORMANT_CHANGE event handler
1076 ecore_wl2_window_conformant_set(mEcoreWindow, true);
1079 wl_proxy_wrapper_destroy(displayWrapper);
1083 // get auxiliary hint
1084 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
1087 Eina_List* l = NULL;
1090 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))))
1092 mSupportedAuxiliaryHints.push_back(hint);
1094 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
1099 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
1101 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
1102 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
1104 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1106 if(iconifyChangedEvent->iconified == EINA_TRUE)
1108 mIconifyChangedSignal.Emit(true);
1112 mIconifyChangedSignal.Emit(false);
1114 handled = ECORE_CALLBACK_DONE;
1120 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
1122 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
1124 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1126 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
1128 mFocusChangedSignal.Emit(true);
1131 return ECORE_CALLBACK_PASS_ON;
1134 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
1136 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
1138 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1140 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
1142 mFocusChangedSignal.Emit(false);
1145 return ECORE_CALLBACK_PASS_ON;
1148 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
1150 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
1152 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
1154 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
1156 mScreenRotationAngle = GetScreenRotationAngle();
1158 mOutputTransformedSignal.Emit();
1161 return ECORE_CALLBACK_PASS_ON;
1164 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
1166 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
1168 if(ignoreTransformEvent->win == mEcoreWindow)
1170 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
1172 mScreenRotationAngle = GetScreenRotationAngle();
1174 mOutputTransformedSignal.Emit();
1177 return ECORE_CALLBACK_PASS_ON;
1180 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
1182 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
1184 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1186 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
1188 RotationEvent rotationEvent;
1189 rotationEvent.angle = ev->angle;
1190 rotationEvent.winResize = 0;
1192 if(ev->w == 0 || ev->h == 0)
1194 // When rotation event does not have the window width or height,
1195 // previous DALi side window's size are used.
1196 ev->w = mWindowPositionSize.width;
1197 ev->h = mWindowPositionSize.height;
1200 mWindowRotationAngle = ev->angle;
1202 mWindowPositionSize.width = ev->w;
1203 mWindowPositionSize.height = ev->h;
1205 PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1207 rotationEvent.x = newPositionSize.x;
1208 rotationEvent.y = newPositionSize.y;
1209 rotationEvent.width = newPositionSize.width;
1210 rotationEvent.height = newPositionSize.height;
1212 mRotationSignal.Emit(rotationEvent);
1216 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1218 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1220 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1222 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1223 // by calling ecore_wl2_window_commit
1225 int tempWidth = ev->w;
1226 int tempHeight = ev->h;
1228 // Initialize with previous size for skip resize when new size is 0.
1229 // When window is just moved or window is resized by client application,
1230 // The configure notification event's size will be 0.
1231 // If new size is 0, the resized work should be skip.
1232 int newWidth = mWindowPositionSize.width;
1233 int newHeight = mWindowPositionSize.height;
1234 bool windowMoved = false, windowResized = false;
1236 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1241 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1243 windowResized = true;
1244 newWidth = tempWidth;
1245 newHeight = tempHeight;
1248 if(windowMoved || windowResized)
1250 mWindowPositionSize.x = ev->x;
1251 mWindowPositionSize.y = ev->y;
1252 mWindowPositionSize.width = newWidth;
1253 mWindowPositionSize.height = newHeight;
1254 DALI_LOG_RELEASE_INFO("Update position & resize signal by server, current angle [%d] x[%d] y[%d] w[%d] h[%d]\n", mWindowRotationAngle, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1256 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1258 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1259 mUpdatePositionSizeSignal.Emit(newPositionSize);
1262 mMaximizeChangedSignal.Emit(static_cast<bool>(ev->states & ECORE_WL2_WINDOW_STATE_MAXIMIZED));
1264 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1268 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1270 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1272 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1274 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
1276 Device::Class::Type deviceClass;
1277 Device::Subclass::Type deviceSubclass;
1279 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1280 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1282 PointState::Type state(PointState::DOWN);
1284 if(deviceClass != Device::Class::Type::MOUSE)
1286 // Check if the buttons field is set and ensure it's the primary touch button.
1287 // If this event was triggered by buttons other than the primary button (used for touch), then
1288 // just send an interrupted event to Core.
1289 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1291 state = PointState::INTERRUPTED;
1295 Integration::Point point;
1296 point.SetDeviceId(touchEvent->multi.device);
1297 point.SetState(state);
1298 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1299 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1300 point.SetPressure(touchEvent->multi.pressure);
1301 point.SetAngle(Degree(touchEvent->multi.angle));
1302 point.SetDeviceClass(deviceClass);
1303 point.SetDeviceSubclass(deviceSubclass);
1304 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1306 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1310 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1312 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1314 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1316 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
1318 Device::Class::Type deviceClass;
1319 Device::Subclass::Type deviceSubclass;
1321 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1322 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1324 Integration::Point point;
1325 point.SetDeviceId(touchEvent->multi.device);
1326 point.SetState(PointState::UP);
1327 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1328 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1329 point.SetPressure(touchEvent->multi.pressure);
1330 point.SetAngle(Degree(touchEvent->multi.angle));
1331 point.SetDeviceClass(deviceClass);
1332 point.SetDeviceSubclass(deviceSubclass);
1333 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1335 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1339 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1341 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1343 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1345 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
1347 Device::Class::Type deviceClass;
1348 Device::Subclass::Type deviceSubclass;
1350 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1351 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1353 Integration::Point point;
1354 point.SetDeviceId(touchEvent->multi.device);
1355 point.SetState(PointState::MOTION);
1356 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1357 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1358 point.SetPressure(touchEvent->multi.pressure);
1359 point.SetAngle(Degree(touchEvent->multi.angle));
1360 point.SetDeviceClass(deviceClass);
1361 point.SetDeviceSubclass(deviceSubclass);
1363 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1367 #ifdef OVER_TIZEN_VERSION_8
1368 void WindowBaseEcoreWl2::OnMouseButtonRelativeMove(void* data, int type, void* event)
1370 Ecore_Event_Mouse_Relative_Move* relativeMoveEvent = static_cast<Ecore_Event_Mouse_Relative_Move*>(event);
1372 if(relativeMoveEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1374 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_RELATIVE_MOVE");
1376 Device::Class::Type deviceClass;
1377 Device::Subclass::Type deviceSubclass;
1379 GetDeviceClass(ecore_device_class_get(relativeMoveEvent->dev), deviceClass);
1380 GetDeviceSubclass(ecore_device_subclass_get(relativeMoveEvent->dev), deviceSubclass);
1382 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);
1384 mMouseRelativeEventSignal.Emit(mouseRelativeEvent);
1389 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1391 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1393 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1395 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
1397 Integration::Point point;
1398 point.SetDeviceId(touchEvent->multi.device);
1399 point.SetState(PointState::INTERRUPTED);
1400 point.SetScreenPosition(Vector2(0.0f, 0.0f));
1402 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1404 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1408 #ifdef OVER_TIZEN_VERSION_8
1409 void WindowBaseEcoreWl2::OnPointerConstraints(void* data, int type, void* event)
1411 Ecore_Wl2_Event_Pointer_Constraints* constraintsEvent = static_cast<Ecore_Wl2_Event_Pointer_Constraints*>(event);
1413 if(constraintsEvent && constraintsEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1415 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_POINTER_CONSTRAINTS");
1416 Dali::Int32Pair position(constraintsEvent->x, constraintsEvent->y);
1417 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnPointerConstraints[%d, %d]\n", position.GetX(), position.GetY());
1419 mPointerConstraintsSignal.Emit(position, constraintsEvent->locked, constraintsEvent->confined);
1424 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1426 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1428 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1430 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
1432 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);
1434 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1436 mWheelEventSignal.Emit(wheelEvent);
1440 void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
1442 Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
1444 if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1446 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
1448 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);
1450 Device::Class::Type deviceClass;
1451 Device::Subclass::Type deviceSubclass;
1453 GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
1454 GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
1456 Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
1458 mMouseInOutEventSignal.Emit(inOutEvent);
1462 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1464 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1466 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1468 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1470 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1472 mWheelEventSignal.Emit(wheelEvent);
1475 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1477 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1479 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1481 std::string keyName(keyEvent->keyname);
1482 std::string logicalKey("");
1483 std::string keyString("");
1484 std::string compose("");
1486 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_DOWN");
1488 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1489 if(keyEvent->compose)
1491 compose = keyEvent->compose;
1494 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1497 logicalKey = keyEvent->key;
1501 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1505 // Get a specific key code from dali key look up table.
1506 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1509 keyCode = (keyCode == -1) ? 0 : keyCode;
1510 int modifier(keyEvent->modifiers);
1511 unsigned long time = keyEvent->timestamp;
1512 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1514 keyCode = atoi(keyEvent->keyname + 8);
1517 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1518 if(keyEvent->string)
1520 keyString = keyEvent->string;
1523 std::string deviceName;
1524 Device::Class::Type deviceClass;
1525 Device::Subclass::Type deviceSubclass;
1527 GetDeviceName(keyEvent, deviceName);
1528 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1529 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1531 bool isRepeat = false;
1532 #ifdef OVER_TIZEN_VERSION_8
1533 if(keyEvent->event_flags & ECORE_EVENT_FLAG_REPEAT)
1539 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1540 keyEvent.isRepeat = isRepeat;
1542 mKeyEventSignal.Emit(keyEvent);
1546 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1548 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1550 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1552 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1553 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1554 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1556 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1559 #endif // Since ecore 1.23 version
1561 std::string keyName(keyEvent->keyname);
1562 std::string logicalKey("");
1563 std::string keyString("");
1564 std::string compose("");
1566 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_UP");
1568 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1569 if(keyEvent->compose)
1571 compose = keyEvent->compose;
1574 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1577 logicalKey = keyEvent->key;
1581 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1585 // Get a specific key code from dali key look up table.
1586 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1589 keyCode = (keyCode == -1) ? 0 : keyCode;
1590 int modifier(keyEvent->modifiers);
1591 unsigned long time = keyEvent->timestamp;
1592 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1594 keyCode = atoi(keyEvent->keyname + 8);
1597 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1598 if(keyEvent->string)
1600 keyString = keyEvent->string;
1603 std::string deviceName;
1604 Device::Class::Type deviceClass;
1605 Device::Subclass::Type deviceSubclass;
1607 GetDeviceName(keyEvent, deviceName);
1608 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1609 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1611 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1613 mKeyEventSignal.Emit(keyEvent);
1617 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1619 mSelectionDataSendSignal.Emit(event);
1622 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1624 mSelectionDataReceivedSignal.Emit(event);
1627 void WindowBaseEcoreWl2::OnFontNameChanged()
1629 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1632 void WindowBaseEcoreWl2::OnFontSizeChanged()
1634 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1637 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1639 mTransitionEffectEventSignal.Emit(state, type);
1642 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1644 mKeyboardRepeatSettingsChangedSignal.Emit();
1647 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1649 mWindowRedrawRequestSignal.Emit();
1652 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1654 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1657 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
1658 std::string key(message->key);
1659 std::string value(message->val);
1660 Dali::Property::Array options;
1662 if(message->options)
1666 EINA_LIST_FOREACH(message->options, l, data)
1668 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
1669 std::string option(static_cast<char*>(data));
1670 options.Add(option);
1674 mAuxiliaryMessageSignal.Emit(key, value, options);
1678 void WindowBaseEcoreWl2::OnEcoreEventConformantChange(void* event)
1680 Ecore_Wl2_Event_Conformant_Change* ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(event);
1681 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1683 WindowInsetsPartType partType = WindowInsetsPartType::STATUS_BAR;
1690 switch(ev->part_type)
1692 case ECORE_WL2_INDICATOR_PART:
1694 partType = WindowInsetsPartType::STATUS_BAR;
1695 ecore_wl2_window_indicator_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1698 case ECORE_WL2_KEYBOARD_PART:
1700 partType = WindowInsetsPartType::KEYBOARD;
1701 ecore_wl2_window_keyboard_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1704 case ECORE_WL2_CLIPBOARD_PART:
1706 partType = WindowInsetsPartType::CLIPBOARD;
1707 ecore_wl2_window_clipboard_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1716 WindowInsetsPartState partState = WindowInsetsPartState::INVISIBLE;
1723 // Insets are applied only if system UI(e.g. virtual keyboard) satisfies the following 2 conditions.
1724 // 1. System UI fits to the window width or height.
1725 // 2. System UI begins or ends from the edge of window.
1726 // Otherwise, we should not resize window content because there would be empty space around system UI.
1727 bool applyInsets = false;
1729 // Zero insets are applied if state is invisible
1736 partState = WindowInsetsPartState::VISIBLE;
1738 int winX = mWindowPositionSize.x;
1739 int winY = mWindowPositionSize.y;
1740 int winW = mWindowPositionSize.width;
1741 int winH = mWindowPositionSize.height;
1743 if((x <= winX) && (x + w >= winX + winW))
1745 if((y <= winY) && (y + h >= winY) && (y + h <= winY + winH))
1750 else if((y + h >= winY + winH) && (y >= winY) && (y <= winY + winH))
1752 bottom = winY + winH - y;
1756 else if((y <= winY) && (y + h >= winY + winH))
1758 if((x <= winX) && (x + w >= winX) && (x + w <= winX + winW))
1760 left = x + w - winX;
1763 else if((x + w >= winX + winW) && (x >= winX) && (x <= winX + winW))
1765 right = winX + winW - x;
1773 mInsetsChangedSignal.Emit(partType, partState, Extents(left, right, top, bottom));
1778 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1780 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1781 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1782 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1785 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1789 void WindowBaseEcoreWl2::OnMoveCompleted(void* event)
1791 Ecore_Wl2_Event_Window_Interactive_Move_Done* movedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Move_Done*>(event);
1792 if(movedDoneEvent && movedDoneEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1794 Dali::PositionSize orgPositionSize(movedDoneEvent->x, movedDoneEvent->y, movedDoneEvent->w, movedDoneEvent->h);
1795 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1796 Dali::Int32Pair newPosition(newPositionSize.x, newPositionSize.y);
1797 DALI_LOG_RELEASE_INFO("window(%p) has been moved by server[%d, %d]\n", mEcoreWindow, newPositionSize.x, newPositionSize.y);
1798 mMoveCompletedSignal.Emit(newPosition);
1802 void WindowBaseEcoreWl2::OnResizeCompleted(void* event)
1804 Ecore_Wl2_Event_Window_Interactive_Resize_Done* resizedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Resize_Done*>(event);
1805 if(resizedDoneEvent && resizedDoneEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1807 Dali::PositionSize orgPositionSize(resizedDoneEvent->x, resizedDoneEvent->y, resizedDoneEvent->w, resizedDoneEvent->h);
1808 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1809 Dali::Uint16Pair newSize(newPositionSize.width, newPositionSize.height);
1810 DALI_LOG_RELEASE_INFO("window(%p) has been resized by server[%d, %d]\n", mEcoreWindow, newPositionSize.width, newPositionSize.height);
1811 mResizeCompletedSignal.Emit(newSize);
1815 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1817 if(strcmp(interface, tizen_policy_interface.name) == 0)
1819 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1821 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1824 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1828 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1830 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1832 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1834 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1835 if(!mTizenDisplayPolicy)
1837 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1841 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1843 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1847 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1849 mTizenPolicy = NULL;
1850 mTizenDisplayPolicy = NULL;
1853 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)
1855 int originalX, originalY, originalWidth, originalHeight;
1856 bool changed = false;
1860 DALI_LOG_ERROR("Failed to get wayland surface in WindowBaseEcoreWl2::TizenPolicyConformantArea()\n");
1864 if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_INDICATOR)
1866 ecore_wl2_window_indicator_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1867 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1869 ecore_wl2_window_indicator_geometry_set(mEcoreWindow, x, y, w, h);
1874 * The given state is based on the visibility value of indicator.
1875 * Thus we need to add 1 to it before comparing with indicator state.
1877 Ecore_Wl2_Indicator_State indState = ecore_wl2_window_indicator_state_get(mEcoreWindow);
1878 if((state + 1) != indState)
1880 ecore_wl2_window_indicator_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Indicator_State>(state + 1));
1884 else if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_KEYBOARD)
1886 ecore_wl2_window_keyboard_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1887 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1889 ecore_wl2_window_keyboard_geometry_set(mEcoreWindow, x, y, w, h);
1894 * The given state is based on the visibility value of virtual keyboard window.
1895 * Thus we need to add 1 to it before comparing with keyboard state.
1897 Ecore_Wl2_Virtual_Keyboard_State kbdState = ecore_wl2_window_keyboard_state_get(mEcoreWindow);
1898 if((state + 1) != (kbdState))
1900 ecore_wl2_window_keyboard_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Virtual_Keyboard_State>(state + 1));
1904 else if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD)
1906 ecore_wl2_window_clipboard_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1907 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1909 ecore_wl2_window_clipboard_geometry_set(mEcoreWindow, x, y, w, h);
1914 * The given state is based on the visibility value of clipboard window.
1915 * Thus we need to add 1 to it before comparing with clipboard state.
1917 Ecore_Wl2_Clipboard_State clipState = ecore_wl2_window_clipboard_state_get(mEcoreWindow);
1918 if((state + 1) != clipState)
1920 ecore_wl2_window_clipboard_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Clipboard_State>(state + 1));
1927 Ecore_Wl2_Event_Conformant_Change* ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(calloc(1, sizeof(Ecore_Wl2_Event_Conformant_Change)));
1933 ev->win = GetNativeWindowId();
1934 ev->part_type = static_cast<Ecore_Wl2_Conformant_Part_Type>(conformantPart);
1936 ecore_event_add(ECORE_WL2_EVENT_CONFORMANT_CHANGE, ev, NULL, NULL);
1939 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);
1942 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1944 mNotificationLevel = level;
1945 mNotificationChangeState = state;
1946 mNotificationLevelChangeDone = true;
1948 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1951 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1953 mScreenOffMode = mode;
1954 mScreenOffModeChangeState = state;
1955 mScreenOffModeChangeDone = true;
1957 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1960 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1962 mBrightness = brightness;
1963 mBrightnessChangeState = state;
1964 mBrightnessChangeDone = true;
1966 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1969 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1971 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1972 KeyCodeMap foundKeyCode;
1974 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1975 if(sym == XKB_KEY_NoSymbol || !mKeyMap)
1977 DALI_LOG_ERROR("Failed to get keysym or keymap in WindowBaseEcoreWl2\n");
1981 foundKeyCode.keySym = sym;
1982 foundKeyCode.isKeyCode = false;
1983 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1984 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1987 Any WindowBaseEcoreWl2::GetNativeWindow()
1989 return mEcoreWindow;
1992 int WindowBaseEcoreWl2::GetNativeWindowId()
1994 return ecore_wl2_window_id_get(mEcoreWindow);
1997 std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
1999 #ifdef OVER_TIZEN_VERSION_7
2000 return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
2002 return std::string();
2006 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
2008 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
2010 START_DURATION_CHECK();
2011 if(totalAngle == 90 || totalAngle == 270)
2013 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
2017 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
2019 FINISH_DURATION_CHECK("wl_egl_window_create");
2021 return static_cast<EGLNativeWindowType>(mEglWindow);
2024 void WindowBaseEcoreWl2::DestroyEglWindow()
2026 if(mEglWindow != NULL)
2028 START_DURATION_CHECK();
2029 wl_egl_window_destroy(mEglWindow);
2030 FINISH_DURATION_CHECK("wl_egl_window_destroy");
2036 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
2038 wl_egl_window_tizen_rotation rotation;
2044 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
2049 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
2054 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
2059 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
2064 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
2069 START_DURATION_CHECK();
2070 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
2071 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_rotation");
2074 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
2076 wl_output_transform bufferTransform;
2082 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2087 bufferTransform = WL_OUTPUT_TRANSFORM_90;
2092 bufferTransform = WL_OUTPUT_TRANSFORM_180;
2097 bufferTransform = WL_OUTPUT_TRANSFORM_270;
2102 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2107 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_buffer_transform() with buffer Transform [%d]\n", bufferTransform);
2108 START_DURATION_CHECK();
2109 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
2110 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_buffer_transform");
2113 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
2115 wl_output_transform windowTransform;
2121 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2126 windowTransform = WL_OUTPUT_TRANSFORM_90;
2131 windowTransform = WL_OUTPUT_TRANSFORM_180;
2136 windowTransform = WL_OUTPUT_TRANSFORM_270;
2141 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2146 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_window_transform() with window Transform [%d]\n", windowTransform);
2147 START_DURATION_CHECK();
2148 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
2149 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_window_transform");
2152 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
2154 DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2155 START_DURATION_CHECK();
2156 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
2158 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
2159 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
2161 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
2162 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
2164 FINISH_DURATION_CHECK("wl_egl_window functions");
2167 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
2169 START_DURATION_CHECK();
2171 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
2172 FINISH_DURATION_CHECK("wl_egl_window_tizen_get_capabilities");
2174 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
2176 mSupportedPreProtation = true;
2179 mSupportedPreProtation = false;
2183 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
2185 PositionSize newPositionSize;
2186 int32_t screenWidth, screenHeight;
2187 WindowSystem::GetScreenSize(screenWidth, screenHeight);
2189 if(mWindowRotationAngle == 90)
2191 newPositionSize.x = positionSize.y;
2192 newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
2193 newPositionSize.width = positionSize.height;
2194 newPositionSize.height = positionSize.width;
2196 else if(mWindowRotationAngle == 180)
2198 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
2199 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
2200 newPositionSize.width = positionSize.width;
2201 newPositionSize.height = positionSize.height;
2203 else if(mWindowRotationAngle == 270)
2205 newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
2206 newPositionSize.y = positionSize.x;
2207 newPositionSize.width = positionSize.height;
2208 newPositionSize.height = positionSize.width;
2212 newPositionSize.x = positionSize.x;
2213 newPositionSize.y = positionSize.y;
2214 newPositionSize.width = positionSize.width;
2215 newPositionSize.height = positionSize.height;
2218 return newPositionSize;
2221 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
2223 PositionSize newPositionSize;
2224 int32_t screenWidth, screenHeight;
2225 WindowSystem::GetScreenSize(screenWidth, screenHeight);
2227 if(mWindowRotationAngle == 90)
2229 newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
2230 newPositionSize.y = positionSize.x;
2231 newPositionSize.width = positionSize.height;
2232 newPositionSize.height = positionSize.width;
2234 else if(mWindowRotationAngle == 180)
2236 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
2237 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
2238 newPositionSize.width = positionSize.width;
2239 newPositionSize.height = positionSize.height;
2241 else if(mWindowRotationAngle == 270)
2243 newPositionSize.x = positionSize.y;
2244 newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
2245 newPositionSize.width = positionSize.height;
2246 newPositionSize.height = positionSize.width;
2250 newPositionSize.x = positionSize.x;
2251 newPositionSize.y = positionSize.y;
2252 newPositionSize.width = positionSize.width;
2253 newPositionSize.height = positionSize.height;
2256 return newPositionSize;
2259 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
2261 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2263 mWindowPositionSize = newPositionSize;
2264 DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
2265 START_DURATION_CHECK();
2266 ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
2267 FINISH_DURATION_CHECK("ecore_wl2_window_position_set");
2270 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
2272 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2274 mWindowPositionSize = newPositionSize;
2275 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);
2276 START_DURATION_CHECK();
2277 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
2278 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
2281 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
2283 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2285 mWindowPositionSize = newPositionSize;
2286 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);
2287 START_DURATION_CHECK();
2288 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
2289 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
2292 void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
2294 #ifdef OVER_TIZEN_VERSION_8
2295 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);
2296 START_DURATION_CHECK();
2297 ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
2298 FINISH_DURATION_CHECK("ecore_wl2_window_layout_set");
2302 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
2304 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
2305 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
2308 void WindowBaseEcoreWl2::Raise()
2310 START_DURATION_CHECK();
2311 // Use ecore_wl2_window_activate to prevent the window shown without rendering
2312 ecore_wl2_window_activate(mEcoreWindow);
2313 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
2316 void WindowBaseEcoreWl2::Lower()
2318 START_DURATION_CHECK();
2319 ecore_wl2_window_lower(mEcoreWindow);
2320 FINISH_DURATION_CHECK("ecore_wl2_window_lower");
2323 void WindowBaseEcoreWl2::Activate()
2325 START_DURATION_CHECK();
2326 ecore_wl2_window_activate(mEcoreWindow);
2327 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
2330 void WindowBaseEcoreWl2::Maximize(bool maximize)
2332 START_DURATION_CHECK();
2333 ecore_wl2_window_maximized_set(mEcoreWindow, maximize);
2334 FINISH_DURATION_CHECK("ecore_wl2_window_maximized_set");
2337 bool WindowBaseEcoreWl2::IsMaximized() const
2339 return ecore_wl2_window_maximized_get(mEcoreWindow);
2342 void WindowBaseEcoreWl2::SetMaximumSize(Dali::Window::WindowSize size)
2344 DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2345 START_DURATION_CHECK();
2346 ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2347 FINISH_DURATION_CHECK("ecore_wl2_window_maximum_size_set");
2348 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2351 void WindowBaseEcoreWl2::Minimize(bool minimize)
2353 START_DURATION_CHECK();
2354 ecore_wl2_window_iconified_set(mEcoreWindow, minimize);
2355 FINISH_DURATION_CHECK("ecore_wl2_window_iconified_set");
2358 bool WindowBaseEcoreWl2::IsMinimized() const
2360 return ecore_wl2_window_iconified_get(mEcoreWindow);
2363 void WindowBaseEcoreWl2::SetMimimumSize(Dali::Window::WindowSize size)
2365 DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2366 START_DURATION_CHECK();
2367 ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2368 FINISH_DURATION_CHECK("ecore_wl2_window_minimum_size_set");
2369 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2372 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
2374 int rotations[4] = {0};
2375 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
2376 for(std::size_t i = 0; i < angles.size(); ++i)
2378 rotations[i] = static_cast<int>(angles[i]);
2379 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
2382 START_DURATION_CHECK();
2383 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
2384 FINISH_DURATION_CHECK("ecore_wl2_window_available_rotations_set");
2387 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
2389 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
2390 START_DURATION_CHECK();
2391 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
2392 FINISH_DURATION_CHECK("ecore_wl2_window_preferred_rotation_set");
2395 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
2397 START_DURATION_CHECK();
2398 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
2399 FINISH_DURATION_CHECK("ecore_wl2_window_focus_skip_set");
2402 void WindowBaseEcoreWl2::Show()
2406 START_DURATION_CHECK();
2407 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
2408 FINISH_DURATION_CHECK("ecore_wl2_window_geometry_set");
2412 ecore_wl2_window_show(mEcoreWindow);
2415 void WindowBaseEcoreWl2::Hide()
2418 ecore_wl2_window_hide(mEcoreWindow);
2421 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
2423 return mSupportedAuxiliaryHints.size();
2426 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
2428 if(index >= GetSupportedAuxiliaryHintCount())
2430 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
2433 return mSupportedAuxiliaryHints[index];
2436 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
2438 bool supported = false;
2440 // Check if the hint is suppported
2441 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
2452 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
2456 // Check if the hint is already added
2457 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2459 if(mAuxiliaryHints[i].first == hint)
2461 // Just change the value
2462 mAuxiliaryHints[i].second = value;
2464 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
2466 return i + 1; // id is index + 1
2471 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
2473 unsigned int id = mAuxiliaryHints.size();
2475 START_DURATION_CHECK();
2476 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
2477 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_add");
2479 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
2484 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
2486 if(id == 0 || id > mAuxiliaryHints.size())
2488 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
2492 mAuxiliaryHints[id - 1].second = std::string();
2494 START_DURATION_CHECK();
2495 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
2496 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_del");
2498 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
2503 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
2505 if(id == 0 || id > mAuxiliaryHints.size())
2507 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
2511 mAuxiliaryHints[id - 1].second = value;
2513 START_DURATION_CHECK();
2514 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
2515 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_change");
2517 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());
2522 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
2524 if(id == 0 || id > mAuxiliaryHints.size())
2526 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
2527 return std::string();
2530 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());
2532 return mAuxiliaryHints[id - 1].second;
2535 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
2537 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2539 if(mAuxiliaryHints[i].first == hint)
2541 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
2546 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
2551 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
2553 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
2555 Eina_Rectangle rect;
2556 rect.x = convertRegion.x;
2557 rect.y = convertRegion.y;
2558 rect.w = convertRegion.width;
2559 rect.h = convertRegion.height;
2561 DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2562 START_DURATION_CHECK();
2563 ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
2564 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_set");
2565 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2568 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
2573 Ecore_Wl2_Window_Type windowType;
2577 case Dali::WindowType::NORMAL:
2579 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::NORMAL\n");
2580 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2583 case Dali::WindowType::NOTIFICATION:
2585 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::NOTIFICATION\n");
2586 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
2589 case Dali::WindowType::UTILITY:
2591 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::UTILITY\n");
2592 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
2595 case Dali::WindowType::DIALOG:
2597 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::DIALOG\n");
2598 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
2601 case Dali::WindowType::IME:
2603 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::IME\n");
2604 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
2607 case Dali::WindowType::DESKTOP:
2609 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::DESKTOP\n");
2610 windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
2615 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, default window type\n");
2616 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2621 START_DURATION_CHECK();
2622 ecore_wl2_window_type_set(mEcoreWindow, windowType);
2623 FINISH_DURATION_CHECK("ecore_wl2_window_type_set");
2627 Dali::WindowType WindowBaseEcoreWl2::GetType() const
2629 DALI_LOG_RELEASE_INFO("GetType, DALI WindType: %d, mIsIMEWindowInitialized: %d\n", mType, mIsIMEWindowInitialized);
2633 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
2635 START_DURATION_CHECK();
2636 while(!mTizenPolicy)
2638 wl_display_dispatch_queue(mDisplay, mEventQueue);
2641 int notificationLevel;
2645 case Dali::WindowNotificationLevel::NONE:
2647 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
2650 case Dali::WindowNotificationLevel::BASE:
2652 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2655 case Dali::WindowNotificationLevel::MEDIUM:
2657 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
2660 case Dali::WindowNotificationLevel::HIGH:
2662 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
2665 case Dali::WindowNotificationLevel::TOP:
2667 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
2672 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
2673 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2678 mNotificationLevelChangeDone = false;
2679 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2681 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2685 while(!mNotificationLevelChangeDone && count < 3)
2687 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2688 wl_display_dispatch_queue(mDisplay, mEventQueue);
2691 FINISH_DURATION_CHECK("ecore_wl2 & wl_display");
2693 if(!mNotificationLevelChangeDone)
2695 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2696 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2698 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2700 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2701 return Dali::WindowOperationResult::PERMISSION_DENIED;
2704 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2706 return Dali::WindowOperationResult::SUCCEED;
2709 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2711 while(!mTizenPolicy)
2713 wl_display_dispatch_queue(mDisplay, mEventQueue);
2718 while(!mNotificationLevelChangeDone && count < 3)
2720 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2721 wl_display_dispatch_queue(mDisplay, mEventQueue);
2725 if(!mNotificationLevelChangeDone)
2727 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2728 return Dali::WindowNotificationLevel::NONE;
2731 Dali::WindowNotificationLevel level;
2733 switch(mNotificationLevel)
2735 case TIZEN_POLICY_LEVEL_NONE:
2737 level = Dali::WindowNotificationLevel::NONE;
2740 case TIZEN_POLICY_LEVEL_DEFAULT:
2742 level = Dali::WindowNotificationLevel::BASE;
2745 case TIZEN_POLICY_LEVEL_MEDIUM:
2747 level = Dali::WindowNotificationLevel::MEDIUM;
2750 case TIZEN_POLICY_LEVEL_HIGH:
2752 level = Dali::WindowNotificationLevel::HIGH;
2755 case TIZEN_POLICY_LEVEL_TOP:
2757 level = Dali::WindowNotificationLevel::TOP;
2762 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2763 level = Dali::WindowNotificationLevel::NONE;
2768 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2773 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2775 while(!mTizenPolicy)
2777 wl_display_dispatch_queue(mDisplay, mEventQueue);
2780 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2783 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2785 while(!mTizenPolicy)
2787 wl_display_dispatch_queue(mDisplay, mEventQueue);
2790 mScreenOffModeChangeDone = false;
2791 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2793 unsigned int mode = 0;
2795 switch(screenOffMode)
2797 case WindowScreenOffMode::TIMEOUT:
2802 case WindowScreenOffMode::NEVER:
2809 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2813 while(!mScreenOffModeChangeDone && count < 3)
2815 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2816 wl_display_dispatch_queue(mDisplay, mEventQueue);
2820 if(!mScreenOffModeChangeDone)
2822 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2823 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2825 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2827 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2828 return Dali::WindowOperationResult::PERMISSION_DENIED;
2831 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2833 return Dali::WindowOperationResult::SUCCEED;
2836 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2838 while(!mTizenPolicy)
2840 wl_display_dispatch_queue(mDisplay, mEventQueue);
2845 while(!mScreenOffModeChangeDone && count < 3)
2847 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2848 wl_display_dispatch_queue(mDisplay, mEventQueue);
2852 if(!mScreenOffModeChangeDone)
2854 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2855 return WindowScreenOffMode::TIMEOUT;
2858 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2860 switch(mScreenOffMode)
2864 screenMode = WindowScreenOffMode::TIMEOUT;
2869 screenMode = WindowScreenOffMode::NEVER;
2874 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2879 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2881 START_DURATION_CHECK();
2882 while(!mTizenDisplayPolicy)
2884 wl_display_dispatch_queue(mDisplay, mEventQueue);
2887 mBrightnessChangeDone = false;
2888 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2890 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2894 while(!mBrightnessChangeDone && count < 3)
2896 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2897 wl_display_dispatch_queue(mDisplay, mEventQueue);
2900 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2902 if(!mBrightnessChangeDone)
2904 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2905 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2907 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2909 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2910 return Dali::WindowOperationResult::PERMISSION_DENIED;
2913 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2915 return Dali::WindowOperationResult::SUCCEED;
2918 int WindowBaseEcoreWl2::GetBrightness() const
2920 START_DURATION_CHECK();
2921 while(!mTizenDisplayPolicy)
2923 wl_display_dispatch_queue(mDisplay, mEventQueue);
2928 while(!mBrightnessChangeDone && count < 3)
2930 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2931 wl_display_dispatch_queue(mDisplay, mEventQueue);
2934 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2936 if(!mBrightnessChangeDone)
2938 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2942 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2947 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2949 Ecore_Wl2_Window_Keygrab_Mode mode;
2953 case KeyGrab::TOPMOST:
2955 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2958 case KeyGrab::SHARED:
2960 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2963 case KeyGrab::OVERRIDE_EXCLUSIVE:
2965 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2968 case KeyGrab::EXCLUSIVE:
2970 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2979 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2982 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2984 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2987 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2989 int keyCount = key.Count();
2990 int keyGrabModeCount = grabMode.Count();
2992 if(keyCount != keyGrabModeCount || keyCount == 0)
2999 Eina_List* keyList = NULL;
3000 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
3002 for(int index = 0; index < keyCount; ++index)
3004 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
3006 switch(grabMode[index])
3008 case KeyGrab::TOPMOST:
3010 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
3013 case KeyGrab::SHARED:
3015 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
3018 case KeyGrab::OVERRIDE_EXCLUSIVE:
3020 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
3023 case KeyGrab::EXCLUSIVE:
3025 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
3030 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
3035 keyList = eina_list_append(keyList, &info);
3038 START_DURATION_CHECK();
3039 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
3040 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_set");
3042 result.Resize(keyCount, true);
3044 Eina_List* l = NULL;
3045 Eina_List* m = NULL;
3046 void* listData = NULL;
3048 if(grabList != NULL)
3050 EINA_LIST_FOREACH(grabList, m, data)
3053 EINA_LIST_FOREACH(keyList, l, listData)
3055 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
3057 DALI_LOG_ERROR("input key list has null data!");
3061 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
3063 result[index] = false;
3072 eina_list_free(keyList);
3073 eina_list_free(grabList);
3079 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
3081 int keyCount = key.Count();
3089 Eina_List* keyList = NULL;
3090 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
3092 for(int index = 0; index < keyCount; ++index)
3094 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
3095 keyList = eina_list_append(keyList, &info);
3098 START_DURATION_CHECK();
3099 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
3100 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_unset");
3102 result.Resize(keyCount, true);
3104 Eina_List* l = NULL;
3105 Eina_List* m = NULL;
3106 void* listData = NULL;
3109 if(ungrabList != NULL)
3111 EINA_LIST_FOREACH(ungrabList, m, data)
3114 EINA_LIST_FOREACH(keyList, l, listData)
3116 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
3118 result[index] = false;
3127 eina_list_free(keyList);
3128 eina_list_free(ungrabList);
3134 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
3139 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
3141 // 1 inch = 25.4 millimeters
3142 xres = ecore_wl2_output_dpi_get(output);
3143 yres = ecore_wl2_output_dpi_get(output);
3145 dpiHorizontal = int(xres + 0.5f); // rounding
3146 dpiVertical = int(yres + 0.5f);
3149 int WindowBaseEcoreWl2::GetWindowRotationAngle() const
3151 int orientation = mWindowRotationAngle;
3152 if(mSupportedPreProtation)
3159 int WindowBaseEcoreWl2::GetScreenRotationAngle()
3161 if(mSupportedPreProtation)
3163 DALI_LOG_RELEASE_INFO("Support PreRotation and return 0\n");
3167 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
3173 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
3175 mScreenRotationAngle = transform * 90;
3176 return mScreenRotationAngle;
3179 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
3181 mWindowRotationAngle = degree;
3182 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
3185 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
3187 START_DURATION_CHECK();
3188 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
3189 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_change_done_send");
3192 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
3194 START_DURATION_CHECK();
3195 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
3196 FINISH_DURATION_CHECK("ecore_wl2_window_alpha_set");
3199 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
3201 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
3204 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
3207 START_DURATION_CHECK();
3208 ecore_wl2_display_sync(display);
3210 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
3212 if(mEcoreWindow == 0)
3214 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
3218 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
3219 FINISH_DURATION_CHECK("ecore_wl2 functions");
3222 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
3224 Ecore_Wl2_Window* ecoreParent = NULL;
3227 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
3228 ecoreParent = winBaseEcore2->mEcoreWindow;
3231 START_DURATION_CHECK();
3232 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
3233 FINISH_DURATION_CHECK("ecore_wl2_window_transient_parent_set");
3236 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
3238 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
3241 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
3243 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
3246 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
3248 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);
3249 START_DURATION_CHECK();
3250 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
3251 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_geometry_set");
3254 void WindowBaseEcoreWl2::InitializeIme()
3256 Eina_Iterator* globals;
3257 struct wl_registry* registry;
3258 Ecore_Wl2_Global* global;
3259 Ecore_Wl2_Display* ecoreWl2Display;
3261 if(mIsIMEWindowInitialized)
3263 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::InitializeIme, IME Window is already initialized\n");
3267 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
3269 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
3273 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p, mIsIMEWindowInitialized: %d\n", ecoreWl2Display, mEcoreWindow, mIsIMEWindowInitialized);
3275 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
3277 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
3281 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
3283 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
3287 START_DURATION_CHECK();
3288 EINA_ITERATOR_FOREACH(globals, global)
3290 #ifdef OVER_TIZEN_VERSION_7
3291 if(strcmp(global->interface, "zwp_input_panel_v1") == 0)
3293 mWlInputPanel = (zwp_input_panel_v1*)wl_registry_bind(registry, global->id, &zwp_input_panel_v1_interface, 1);
3296 if(strcmp(global->interface, "wl_input_panel") == 0)
3298 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
3301 else if(strcmp(global->interface, "wl_output") == 0)
3303 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
3309 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
3315 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
3318 #ifdef OVER_TIZEN_VERSION_7
3319 mWlInputPanelSurface = zwp_input_panel_v1_get_input_panel_surface(mWlInputPanel, mWlSurface);
3321 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
3323 if(!mWlInputPanelSurface)
3325 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
3328 #ifdef OVER_TIZEN_VERSION_7
3329 zwp_input_panel_surface_v1_set_toplevel(mWlInputPanelSurface, mWlOutput, ZWP_INPUT_PANEL_SURFACE_V1_POSITION_CENTER_BOTTOM);
3331 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
3333 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_toplevel");
3334 mIsIMEWindowInitialized = true;
3337 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
3339 if(!mWlInputPanelSurface)
3341 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
3345 START_DURATION_CHECK();
3346 #ifdef OVER_TIZEN_VERSION_7
3347 zwp_input_panel_surface_v1_set_ready(mWlInputPanelSurface, 1);
3349 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
3351 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_ready");
3354 void WindowBaseEcoreWl2::RequestMoveToServer()
3356 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3359 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
3363 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3366 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
3370 START_DURATION_CHECK();
3371 ecore_wl2_window_move(mEcoreWindow, input);
3372 FINISH_DURATION_CHECK("ecore_wl2_window_move");
3373 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
3376 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
3378 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3381 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
3385 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3388 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
3392 ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
3394 START_DURATION_CHECK();
3395 ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
3396 FINISH_DURATION_CHECK("ecore_wl2_window_resize");
3397 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);
3400 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
3402 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
3403 START_DURATION_CHECK();
3406 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
3410 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
3412 FINISH_DURATION_CHECK("ecore_wl2_window_floating_mode_set");
3415 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
3417 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
3420 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
3422 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
3423 Eina_Rectangle rect;
3425 rect.x = convertRegion.x;
3426 rect.y = convertRegion.y;
3427 rect.w = convertRegion.width;
3428 rect.h = convertRegion.height;
3430 DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3431 START_DURATION_CHECK();
3432 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
3433 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_add");
3434 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3437 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
3439 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
3440 Eina_Rectangle rect;
3442 rect.x = convertRegion.x;
3443 rect.y = convertRegion.y;
3444 rect.w = convertRegion.width;
3445 rect.h = convertRegion.height;
3447 DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3448 START_DURATION_CHECK();
3449 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
3450 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_subtract");
3451 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3454 bool WindowBaseEcoreWl2::PointerConstraintsLock()
3456 #ifdef OVER_TIZEN_VERSION_8
3457 return ecore_wl2_window_pointer_constraints_lock_pointer(mEcoreWindow);
3463 bool WindowBaseEcoreWl2::PointerConstraintsUnlock()
3465 #ifdef OVER_TIZEN_VERSION_8
3466 return ecore_wl2_window_pointer_constraints_unlock_pointer(mEcoreWindow);
3472 void WindowBaseEcoreWl2::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
3474 #ifdef OVER_TIZEN_VERSION_8
3475 ecore_wl2_window_locked_pointer_region_set(mEcoreWindow, x, y, width, height);
3476 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3480 void WindowBaseEcoreWl2::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
3482 #ifdef OVER_TIZEN_VERSION_8
3483 ecore_wl2_window_locked_pointer_cursor_position_hint_set(mEcoreWindow, x, y);
3484 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3488 bool WindowBaseEcoreWl2::PointerWarp(int32_t x, int32_t y)
3490 return ecore_wl2_window_pointer_warp(mEcoreWindow, x, y);
3493 void WindowBaseEcoreWl2::CursorVisibleSet(bool visible)
3495 #ifdef OVER_TIZEN_VERSION_8
3496 ecore_wl2_window_cursor_visible_set(mEcoreWindow, visible);
3500 // Request grab key events according to the requested device subtype
3501 //(For now, subtype could be '0'/'11'/'12' which equals to ECORE_DEVICE_SUBCLASS_NONE/REMOCON/VIRTUAL_KEYBOARD)
3502 bool WindowBaseEcoreWl2::KeyboardGrab(Device::Subclass::Type deviceSubclass)
3504 #ifdef OVER_TIZEN_VERSION_8
3505 Ecore_Device_Subclass ecoreDeviceSubclass;
3506 switch(deviceSubclass)
3508 case Device::Subclass::NONE:
3510 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_NONE;
3513 case Device::Subclass::REMOCON:
3515 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_REMOCON;
3518 case Device::Subclass::VIRTUAL_KEYBOARD:
3520 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD;
3525 DALI_LOG_ERROR("deviceSubclass : %d type is not support, subtype could be 'NONE', 'REMOCON', 'VIRTUAL_KEYBOARD'\n");
3529 return ecore_wl2_window_keyboard_grab(mEcoreWindow, ecoreDeviceSubclass);
3535 // Request ungrab key events
3536 bool WindowBaseEcoreWl2::KeyboardUnGrab()
3538 #ifdef OVER_TIZEN_VERSION_8
3539 return ecore_wl2_window_keyboard_ungrab(mEcoreWindow);
3545 void WindowBaseEcoreWl2::SetFullScreen(bool fullscreen)
3547 DALI_LOG_RELEASE_INFO("ecore_wl2_window_fullscreen_set, window: [%p], fullscreen [%d]\n", mEcoreWindow, fullscreen);
3548 START_DURATION_CHECK();
3549 ecore_wl2_window_fullscreen_set(mEcoreWindow, fullscreen);
3550 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3551 FINISH_DURATION_CHECK("ecore_wl2_window_fullscreen_set");
3554 bool WindowBaseEcoreWl2::GetFullScreen()
3556 return ecore_wl2_window_fullscreen_get(mEcoreWindow);
3559 void WindowBaseEcoreWl2::SetFrontBufferRendering(bool enable)
3561 mIsFrontBufferRendering = enable;
3564 bool WindowBaseEcoreWl2::GetFrontBufferRendering()
3566 return mIsFrontBufferRendering;
3569 void WindowBaseEcoreWl2::SetEglWindowFrontBufferMode(bool enable)
3571 wl_egl_window_tizen_set_frontbuffer_mode(mEglWindow, enable);
3574 } // namespace Adaptor
3576 } // namespace Internal
3580 #pragma GCC diagnostic pop