2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Ecore is littered with C style cast
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wold-style-cast"
23 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
26 #include <dali/internal/input/common/key-impl.h>
27 #include <dali/internal/system/common/time-service.h>
28 #include <dali/internal/window-system/common/window-impl.h>
29 #include <dali/internal/window-system/common/window-render-surface.h>
30 #include <dali/internal/window-system/common/window-system.h>
33 #include <Ecore_Input.h>
34 #include <dali/integration-api/debug.h>
35 #include <dali/integration-api/trace.h>
36 #include <dali/public-api/adaptor-framework/window-enumerations.h>
37 #include <dali/public-api/events/mouse-button.h>
38 #include <dali/public-api/object/any.h>
40 #if defined(VCONF_ENABLED)
41 #include <vconf-keys.h>
45 #define START_DURATION_CHECK() \
46 uint32_t durationMilliSeconds = static_cast<uint32_t>(-1); \
47 uint32_t startTime, endTime; \
48 startTime = TimeService::GetMilliSeconds();
50 #define FINISH_DURATION_CHECK(functionName) \
51 endTime = TimeService::GetMilliSeconds(); \
52 durationMilliSeconds = endTime - startTime; \
53 if(durationMilliSeconds > 0) \
55 DALI_LOG_DEBUG_INFO("%s : duration [%u ms]\n", functionName, durationMilliSeconds); \
58 #include <wayland-egl-tizen.h>
68 #if defined(DEBUG_ENABLED)
69 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
72 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
75 * @brief Enumeration of location for window resized by display server.
77 enum class ResizeLocation
79 INVALID = 0, ///< Invalid value
80 TOP_LEFT = 5, ///< Start resizing window to the top-left edge.
81 LEFT = 4, ///< Start resizing window to the left side.
82 BOTTOM_LEFT = 6, ///< Start resizing window to the bottom-left edge.
83 BOTTOM = 2, ///< Start resizing window to the bottom side.
84 BOTTOM_RIGHT = 10, ///< Start resizing window to the bottom-right edge.
85 RIGHT = 8, ///< Start resizing window to the right side.
86 TOP_RIGHT = 9, ///< Start resizing window to the top-right edge.
87 TOP = 1 ///< Start resizing window to the top side.
90 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
91 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
92 const ResizeLocation RESIZE_LOCATIONS[] = {ResizeLocation::TOP_LEFT, ResizeLocation::LEFT, ResizeLocation::BOTTOM_LEFT, ResizeLocation::BOTTOM, ResizeLocation::BOTTOM_RIGHT, ResizeLocation::RIGHT, ResizeLocation::TOP_RIGHT, ResizeLocation::TOP, ResizeLocation::INVALID};
94 #if defined(VCONF_ENABLED)
95 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
101 xkb_keycode_t keyCode;
106 * Get the device name from the provided ecore key event
108 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
110 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
114 result = ecoreDeviceName;
119 * Get the device class from the provided ecore event
121 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
123 switch(ecoreDeviceClass)
125 case ECORE_DEVICE_CLASS_SEAT:
127 deviceClass = Device::Class::USER;
130 case ECORE_DEVICE_CLASS_KEYBOARD:
132 deviceClass = Device::Class::KEYBOARD;
135 case ECORE_DEVICE_CLASS_MOUSE:
137 deviceClass = Device::Class::MOUSE;
140 case ECORE_DEVICE_CLASS_TOUCH:
142 deviceClass = Device::Class::TOUCH;
145 case ECORE_DEVICE_CLASS_PEN:
147 deviceClass = Device::Class::PEN;
150 case ECORE_DEVICE_CLASS_POINTER:
152 deviceClass = Device::Class::POINTER;
155 case ECORE_DEVICE_CLASS_GAMEPAD:
157 deviceClass = Device::Class::GAMEPAD;
162 deviceClass = Device::Class::NONE;
168 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
170 switch(ecoreDeviceSubclass)
172 case ECORE_DEVICE_SUBCLASS_FINGER:
174 deviceSubclass = Device::Subclass::FINGER;
177 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
179 deviceSubclass = Device::Subclass::FINGERNAIL;
182 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
184 deviceSubclass = Device::Subclass::KNUCKLE;
187 case ECORE_DEVICE_SUBCLASS_PALM:
189 deviceSubclass = Device::Subclass::PALM;
192 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
194 deviceSubclass = Device::Subclass::HAND_SIDE;
197 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
199 deviceSubclass = Device::Subclass::HAND_FLAT;
202 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
204 deviceSubclass = Device::Subclass::PEN_TIP;
207 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
209 deviceSubclass = Device::Subclass::TRACKPAD;
212 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
214 deviceSubclass = Device::Subclass::TRACKPOINT;
217 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
219 deviceSubclass = Device::Subclass::TRACKBALL;
222 case ECORE_DEVICE_SUBCLASS_REMOCON:
224 deviceSubclass = Device::Subclass::REMOCON;
227 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
229 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
232 case ECORE_DEVICE_SUBCLASS_VIRTUAL_REMOCON:
234 deviceSubclass = Device::Subclass::VIRTUAL_REMOCON;
237 case ECORE_DEVICE_SUBCLASS_VIRTUAL_MOUSE:
239 deviceSubclass = Device::Subclass::VIRTUAL_MOUSE;
244 deviceSubclass = Device::Subclass::NONE;
250 void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
252 KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
253 if(foundKeyCode->isKeyCode)
258 xkb_keysym_t keySym = foundKeyCode->keySym;
260 const xkb_keysym_t* symsOut = NULL;
262 nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
266 if(*symsOut == keySym)
268 foundKeyCode->keyCode = key;
269 foundKeyCode->isKeyCode = true;
275 * Return the recalculated window resizing location according to the current orientation.
277 ResizeLocation RecalculateLocationToCurrentOrientation(WindowResizeDirection direction, int windowRotationAngle)
282 case WindowResizeDirection::TOP_LEFT:
287 case WindowResizeDirection::LEFT:
292 case WindowResizeDirection::BOTTOM_LEFT:
297 case WindowResizeDirection::BOTTOM:
302 case WindowResizeDirection::BOTTOM_RIGHT:
307 case WindowResizeDirection::RIGHT:
312 case WindowResizeDirection::TOP_RIGHT:
317 case WindowResizeDirection::TOP:
329 if(index != 8 && windowRotationAngle != 0)
331 index = (index + (windowRotationAngle / 90) * 2) % 8;
334 return RESIZE_LOCATIONS[index];
337 /////////////////////////////////////////////////////////////////////////////////////////////////
339 /////////////////////////////////////////////////////////////////////////////////////////////////
341 /// Called when the window iconify state is changed.
342 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
344 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
347 return windowBase->OnIconifyStateChanged(data, type, event);
350 return ECORE_CALLBACK_PASS_ON;
353 /// Called when the window gains focus
354 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
356 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
359 return windowBase->OnFocusIn(data, type, event);
362 return ECORE_CALLBACK_PASS_ON;
365 /// Called when the window loses focus
366 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
368 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
371 return windowBase->OnFocusOut(data, type, event);
374 return ECORE_CALLBACK_PASS_ON;
377 /// Called when the output is transformed
378 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
380 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
383 return windowBase->OnOutputTransform(data, type, event);
386 return ECORE_CALLBACK_PASS_ON;
389 /// Called when the output transform should be ignored
390 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
392 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
395 return windowBase->OnIgnoreOutputTransform(data, type, event);
398 return ECORE_CALLBACK_PASS_ON;
402 * Called when rotate event is recevied.
404 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
406 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
409 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
410 windowBase->OnRotation(data, type, event);
412 return ECORE_CALLBACK_PASS_ON;
416 * Called when configure event is recevied.
418 static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
420 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
423 windowBase->OnConfiguration(data, type, event);
425 return ECORE_CALLBACK_PASS_ON;
428 /////////////////////////////////////////////////////////////////////////////////////////////////
430 /////////////////////////////////////////////////////////////////////////////////////////////////
433 * Called when a touch down is received.
435 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
437 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
440 windowBase->OnMouseButtonDown(data, type, event);
442 return ECORE_CALLBACK_PASS_ON;
446 * Called when a touch up is received.
448 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
450 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
453 windowBase->OnMouseButtonUp(data, type, event);
455 return ECORE_CALLBACK_PASS_ON;
459 * Called when a touch motion is received.
461 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
463 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
466 windowBase->OnMouseButtonMove(data, type, event);
468 return ECORE_CALLBACK_PASS_ON;
471 #ifdef OVER_TIZEN_VERSION_8
473 * Called when a touch motion is received.
475 static Eina_Bool EcoreEventMouseButtonRelativeMove(void* data, int type, void* event)
477 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
480 windowBase->OnMouseButtonRelativeMove(data, type, event);
482 return ECORE_CALLBACK_PASS_ON;
487 * Called when a touch is canceled.
489 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
491 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
494 windowBase->OnMouseButtonCancel(data, type, event);
496 return ECORE_CALLBACK_PASS_ON;
499 #ifdef OVER_TIZEN_VERSION_8
501 * Called when pointer constraints event is recevied.
503 static Eina_Bool EcoreEventPointerConstraints(void* data, int type, void* event)
505 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
508 windowBase->OnPointerConstraints(data, type, event);
510 return ECORE_CALLBACK_PASS_ON;
515 * Called when a mouse wheel is received.
517 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
519 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
522 windowBase->OnMouseWheel(data, type, event);
524 return ECORE_CALLBACK_PASS_ON;
528 * Called when a mouse in is received.
530 static Eina_Bool EcoreEventMouseIn(void* data, int type, void* event)
532 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
535 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::IN);
537 return ECORE_CALLBACK_PASS_ON;
541 * Called when a mouse out is received.
543 static Eina_Bool EcoreEventMouseOut(void* data, int type, void* event)
545 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
548 // When the mouse is out, the previous mouse must be canceled.
549 windowBase->OnMouseButtonCancel(data, type, event);
550 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::OUT);
552 return ECORE_CALLBACK_PASS_ON;
556 * Called when a detent rotation event is recevied.
558 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
560 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
563 windowBase->OnDetentRotation(data, type, event);
565 return ECORE_CALLBACK_PASS_ON;
568 /////////////////////////////////////////////////////////////////////////////////////////////////
570 /////////////////////////////////////////////////////////////////////////////////////////////////
573 * Called when a key down is received.
575 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
577 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
580 windowBase->OnKeyDown(data, type, event);
582 return ECORE_CALLBACK_PASS_ON;
586 * Called when a key up is received.
588 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
590 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
593 windowBase->OnKeyUp(data, type, event);
595 return ECORE_CALLBACK_PASS_ON;
598 /////////////////////////////////////////////////////////////////////////////////////////////////
599 // Selection Callbacks
600 /////////////////////////////////////////////////////////////////////////////////////////////////
603 * Called when the source window notifies us the content in clipboard is selected.
605 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
607 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
610 windowBase->OnDataSend(data, type, event);
612 return ECORE_CALLBACK_PASS_ON;
616 * Called when the source window sends us about the selected content.
617 * For example, when item is selected in the clipboard.
619 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
621 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
624 windowBase->OnDataReceive(data, type, event);
626 return ECORE_CALLBACK_PASS_ON;
629 /////////////////////////////////////////////////////////////////////////////////////////////////
630 // Effect Start/End Callbacks
631 /////////////////////////////////////////////////////////////////////////////////////////////////
634 * Called when transition animation of the window's shown/hidden is started by window manager.
636 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
638 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
639 Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
640 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
643 if(effectStart->type < 3) // only under restack
645 windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
648 return ECORE_CALLBACK_PASS_ON;
652 * Called when transition animation of the window's shown/hidden is ended by window manager.
654 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
656 Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
657 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
658 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
661 if(effectEnd->type < 3) // only under restack
663 windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
666 return ECORE_CALLBACK_PASS_ON;
669 /////////////////////////////////////////////////////////////////////////////////////////////////
670 // Keyboard Repeat Settings Changed Callbacks
671 /////////////////////////////////////////////////////////////////////////////////////////////////
673 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
675 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
676 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event)->id);
679 windowBase->OnKeyboardRepeatSettingsChanged();
682 return ECORE_CALLBACK_RENEW;
685 /////////////////////////////////////////////////////////////////////////////////////////////////
686 // Keymap Changed Callbacks
687 /////////////////////////////////////////////////////////////////////////////////////////////////
689 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
691 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
694 windowBase->KeymapChanged(data, type, event);
697 return ECORE_CALLBACK_RENEW;
700 /////////////////////////////////////////////////////////////////////////////////////////////////
702 /////////////////////////////////////////////////////////////////////////////////////////////////
704 #if defined(VCONF_ENABLED)
706 * Called when a font name is changed.
708 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
710 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
713 windowBase->OnFontNameChanged();
718 * Called when a font size is changed.
720 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
722 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
725 windowBase->OnFontSizeChanged();
730 /////////////////////////////////////////////////////////////////////////////////////////////////
731 // Window Redraw Request Event Callbacks
732 /////////////////////////////////////////////////////////////////////////////////////////////////
734 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
736 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
737 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event)->win);
740 windowBase->OnEcoreEventWindowRedrawRequest();
743 return ECORE_CALLBACK_RENEW;
746 /////////////////////////////////////////////////////////////////////////////////////////////////
747 // Window Auxiliary Message Callbacks
748 /////////////////////////////////////////////////////////////////////////////////////////////////
749 static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* event)
751 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
754 windowBase->OnEcoreEventWindowAuxiliaryMessage(event);
756 return ECORE_CALLBACK_RENEW;
759 /////////////////////////////////////////////////////////////////////////////////////////////////
760 // Window is Moved/Resized By Server Callbacks
761 /////////////////////////////////////////////////////////////////////////////////////////////////
762 static Eina_Bool EcoreEventWindowMoveCompleted(void* data, int type, void* event)
764 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
767 windowBase->OnMoveCompleted(event);
769 return ECORE_CALLBACK_RENEW;
772 static Eina_Bool EcoreEventWindowResizeCompleted(void* data, int type, void* event)
774 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
777 windowBase->OnResizeCompleted(event);
779 return ECORE_CALLBACK_RENEW;
782 /////////////////////////////////////////////////////////////////////////////////////////////////
783 // Conformant Change Callback
784 /////////////////////////////////////////////////////////////////////////////////////////////////
785 static Eina_Bool EcoreEventConformantChange(void* data, int type, void* event)
787 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
790 windowBase->OnEcoreEventConformantChange(event);
792 return ECORE_CALLBACK_RENEW;
795 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
797 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
800 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
804 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
806 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
809 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
813 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
817 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)
819 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
822 windowBase->TizenPolicyConformantArea(data, tizenPolicy, surface, conformantPart, state, x, y, w, h);
826 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
828 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
831 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
835 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
839 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
841 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
844 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
848 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
852 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
856 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
860 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
864 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)
868 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
870 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
873 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
877 const struct wl_registry_listener registryListener =
879 RegistryGlobalCallback,
880 RegistryGlobalCallbackRemove};
882 const struct tizen_policy_listener tizenPolicyListener =
884 TizenPolicyConformant,
885 TizenPolicyConformantArea,
886 TizenPolicyNotificationChangeDone,
887 TizenPolicyTransientForDone,
888 TizenPolicyScreenModeChangeDone,
889 TizenPolicyIconifyStateChanged,
890 TizenPolicySupportedAuxiliaryHints,
891 TizenPolicyAllowedAuxiliaryHint,
892 TizenPolicyAuxiliaryMessage,
893 TizenPolicyConformantRegion};
895 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
897 DisplayPolicyBrightnessChangeDone};
899 } // unnamed namespace
901 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
902 : mEcoreEventHandler(),
903 mEcoreWindow(nullptr),
905 mWlInputPanel(nullptr),
907 mWlInputPanelSurface(nullptr),
910 mEventQueue(nullptr),
911 mTizenPolicy(nullptr),
912 mTizenDisplayPolicy(nullptr),
914 mSupportedAuxiliaryHints(),
915 mWindowPositionSize(positionSize),
917 mType(WindowType::NORMAL),
918 mNotificationLevel(-1),
921 mWindowRotationAngle(0),
922 mScreenRotationAngle(0),
923 mSupportedPreProtation(0),
924 mNotificationChangeState(0),
925 mScreenOffModeChangeState(0),
926 mBrightnessChangeState(0),
927 mLastSubmittedMoveResizeSerial(0),
928 mMoveResizeSerial(0),
929 mNotificationLevelChangeDone(true),
930 mScreenOffModeChangeDone(true),
933 mBrightnessChangeDone(true),
934 mIsFrontBufferRendering(false),
935 mIsIMEWindowInitialized(false)
937 Initialize(positionSize, surface, isTransparent);
940 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
942 #if defined(VCONF_ENABLED)
943 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
944 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
947 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
949 ecore_event_handler_del(*iter);
951 mEcoreEventHandler.Clear();
955 wl_event_queue_destroy(mEventQueue);
958 mSupportedAuxiliaryHints.clear();
959 mAuxiliaryHints.clear();
961 if(mEglWindow != NULL)
963 wl_egl_window_destroy(mEglWindow);
971 ecore_wl2_window_free(mEcoreWindow);
973 catch(std::bad_weak_ptr const& ex)
975 DALI_LOG_ERROR("WindowBaseEcoreWl2::~WindowBaseEcoreWl2() - window (%p) std::bad_weak_ptr caught: %s\n", mEcoreWindow, ex.what());
980 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
982 if(surface.Empty() == false)
984 // check we have a valid type
985 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
987 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
991 // we own the surface about to created
993 CreateWindow(positionSize);
996 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
998 SetTransparency(isTransparent);
1000 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
1001 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
1005 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1007 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
1010 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
1011 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
1012 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
1013 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
1014 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
1016 // Register Rotate event
1017 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
1019 // Register Configure event
1020 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
1022 // Register Touch events
1023 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
1024 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
1025 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
1026 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
1027 #ifdef OVER_TIZEN_VERSION_8
1028 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_RELATIVE_MOVE, EcoreEventMouseButtonRelativeMove, this));
1030 // Register pointer lock/unlock event
1031 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_POINTER_CONSTRAINTS, EcoreEventPointerConstraints, this));
1034 // Register Mouse wheel events
1035 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
1037 // Register Mouse IO events
1038 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
1039 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
1041 // Register Detent event
1042 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
1044 // Register Key events
1045 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
1046 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
1048 // Register Selection event - clipboard selection
1049 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
1050 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OFFER_DATA_READY, EcoreEventDataReceive, this));
1052 // Register Effect Start/End event
1053 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
1054 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
1056 // Register Keyboard repeat event
1057 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
1059 // Register Window redraw request event
1060 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
1062 // Register Window auxiliary event
1063 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
1065 // Register Conformant change event
1066 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_CONFORMANT_CHANGE, EcoreEventConformantChange, this));
1068 #if defined(VCONF_ENABLED)
1069 // Register Vconf notify - font name and size
1070 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
1071 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
1074 // Register Window is moved and resized done event.
1075 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE, EcoreEventWindowMoveCompleted, this));
1076 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE, EcoreEventWindowResizeCompleted, this));
1078 mDisplay = ecore_wl2_display_get(display);
1081 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
1084 mEventQueue = wl_display_create_queue(mDisplay);
1087 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
1089 wl_registry* registry = wl_display_get_registry(displayWrapper);
1090 wl_registry_add_listener(registry, ®istryListener, this);
1092 // To support ECORE_WL2_EVENT_CONFORMANT_CHANGE event handler
1093 ecore_wl2_window_conformant_set(mEcoreWindow, true);
1096 wl_proxy_wrapper_destroy(displayWrapper);
1100 // get auxiliary hint
1101 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
1104 Eina_List* l = NULL;
1107 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))))
1109 mSupportedAuxiliaryHints.push_back(hint);
1111 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
1116 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
1118 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
1119 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
1121 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1123 if(iconifyChangedEvent->iconified == EINA_TRUE)
1125 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnIconifyStateChanged, the window (%p) is iconified\n", mEcoreWindow);
1126 mIconifyChangedSignal.Emit(true);
1130 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnIconifyStateChanged, the window (%p) is not iconified\n", mEcoreWindow);
1131 mIconifyChangedSignal.Emit(false);
1133 handled = ECORE_CALLBACK_DONE;
1139 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
1141 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
1143 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1145 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnFocusIn, Window (%p) EcoreEventWindowFocusIn\n", mEcoreWindow);
1147 mFocusChangedSignal.Emit(true);
1150 return ECORE_CALLBACK_PASS_ON;
1153 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
1155 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
1157 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1159 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnFocusOut, Window (%p) EcoreEventWindowFocusOut\n", mEcoreWindow);
1161 mFocusChangedSignal.Emit(false);
1164 return ECORE_CALLBACK_PASS_ON;
1167 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
1169 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
1171 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
1173 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnOutputTransform, Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
1175 mScreenRotationAngle = GetScreenRotationAngle();
1177 mOutputTransformedSignal.Emit();
1180 return ECORE_CALLBACK_PASS_ON;
1183 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
1185 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
1187 if(ignoreTransformEvent->win == mEcoreWindow)
1189 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnIgnoreOutputTransform, Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
1191 mScreenRotationAngle = GetScreenRotationAngle();
1193 mOutputTransformedSignal.Emit();
1196 return ECORE_CALLBACK_PASS_ON;
1199 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
1201 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
1203 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1205 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, Window (%p), angle: %d, width: %d, height: %d\n", mEcoreWindow, ev->angle, ev->w, ev->h);
1207 RotationEvent rotationEvent;
1208 rotationEvent.angle = ev->angle;
1209 rotationEvent.winResize = 0;
1211 if(ev->w == 0 || ev->h == 0)
1213 // When rotation event does not have the window width or height,
1214 // previous DALi side window's size are used.
1215 ev->w = mWindowPositionSize.width;
1216 ev->h = mWindowPositionSize.height;
1219 mWindowRotationAngle = ev->angle;
1221 mWindowPositionSize.width = ev->w;
1222 mWindowPositionSize.height = ev->h;
1224 PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1226 rotationEvent.x = newPositionSize.x;
1227 rotationEvent.y = newPositionSize.y;
1228 rotationEvent.width = newPositionSize.width;
1229 rotationEvent.height = newPositionSize.height;
1231 mRotationSignal.Emit(rotationEvent);
1235 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1237 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1239 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1241 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1242 // by calling ecore_wl2_window_commit
1244 int tempWidth = ev->w;
1245 int tempHeight = ev->h;
1247 // Initialize with previous size for skip resize when new size is 0.
1248 // When window is just moved or window is resized by client application,
1249 // The configure notification event's size will be 0.
1250 // If new size is 0, the resized work should be skip.
1251 int newWidth = mWindowPositionSize.width;
1252 int newHeight = mWindowPositionSize.height;
1253 bool windowMoved = false, windowResized = false;
1255 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1260 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1262 windowResized = true;
1263 newWidth = tempWidth;
1264 newHeight = tempHeight;
1267 if(windowMoved || windowResized)
1269 mWindowPositionSize.x = ev->x;
1270 mWindowPositionSize.y = ev->y;
1271 mWindowPositionSize.width = newWidth;
1272 mWindowPositionSize.height = newHeight;
1273 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnConfiguration, Window (%p), Update position & resize signal by Ecore, current angle [%d] x[%d] y[%d] w[%d] h[%d]\n", mEcoreWindow, mWindowRotationAngle, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1275 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1277 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1278 mUpdatePositionSizeSignal.Emit(newPositionSize);
1281 mMaximizeChangedSignal.Emit(static_cast<bool>(ev->states & ECORE_WL2_WINDOW_STATE_MAXIMIZED));
1283 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1287 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1289 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1291 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1293 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
1295 Device::Class::Type deviceClass;
1296 Device::Subclass::Type deviceSubclass;
1298 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1299 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1301 PointState::Type state(PointState::DOWN);
1303 if(deviceClass != Device::Class::Type::MOUSE)
1305 // Check if the buttons field is set and ensure it's the primary touch button.
1306 // If this event was triggered by buttons other than the primary button (used for touch), then
1307 // just send an interrupted event to Core.
1308 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1310 state = PointState::INTERRUPTED;
1314 Integration::Point point;
1315 point.SetDeviceId(touchEvent->multi.device);
1316 point.SetState(state);
1317 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1318 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1319 point.SetPressure(touchEvent->multi.pressure);
1320 point.SetAngle(Degree(touchEvent->multi.angle));
1321 point.SetDeviceClass(deviceClass);
1322 point.SetDeviceSubclass(deviceSubclass);
1323 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1325 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1329 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1331 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1333 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1335 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
1337 Device::Class::Type deviceClass;
1338 Device::Subclass::Type deviceSubclass;
1340 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1341 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1343 Integration::Point point;
1344 point.SetDeviceId(touchEvent->multi.device);
1345 point.SetState(PointState::UP);
1346 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1347 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1348 point.SetPressure(touchEvent->multi.pressure);
1349 point.SetAngle(Degree(touchEvent->multi.angle));
1350 point.SetDeviceClass(deviceClass);
1351 point.SetDeviceSubclass(deviceSubclass);
1352 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1354 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1358 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1360 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1362 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1364 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
1366 Device::Class::Type deviceClass;
1367 Device::Subclass::Type deviceSubclass;
1369 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1370 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1372 Integration::Point point;
1373 point.SetDeviceId(touchEvent->multi.device);
1374 point.SetState(PointState::MOTION);
1375 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1376 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1377 point.SetPressure(touchEvent->multi.pressure);
1378 point.SetAngle(Degree(touchEvent->multi.angle));
1379 point.SetDeviceClass(deviceClass);
1380 point.SetDeviceSubclass(deviceSubclass);
1382 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1386 #ifdef OVER_TIZEN_VERSION_8
1387 void WindowBaseEcoreWl2::OnMouseButtonRelativeMove(void* data, int type, void* event)
1389 Ecore_Event_Mouse_Relative_Move* relativeMoveEvent = static_cast<Ecore_Event_Mouse_Relative_Move*>(event);
1391 if(relativeMoveEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1393 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_RELATIVE_MOVE");
1395 Device::Class::Type deviceClass;
1396 Device::Subclass::Type deviceSubclass;
1398 GetDeviceClass(ecore_device_class_get(relativeMoveEvent->dev), deviceClass);
1399 GetDeviceSubclass(ecore_device_subclass_get(relativeMoveEvent->dev), deviceSubclass);
1401 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);
1403 mMouseRelativeEventSignal.Emit(mouseRelativeEvent);
1408 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1410 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1412 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1414 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
1416 Device::Class::Type deviceClass;
1417 Device::Subclass::Type deviceSubclass;
1419 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1420 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1422 Integration::Point point;
1423 point.SetDeviceId(touchEvent->multi.device);
1424 point.SetState(PointState::INTERRUPTED);
1425 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1426 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1427 point.SetPressure(touchEvent->multi.pressure);
1428 point.SetAngle(Degree(touchEvent->multi.angle));
1429 point.SetDeviceClass(deviceClass);
1430 point.SetDeviceSubclass(deviceSubclass);
1432 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1434 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1438 #ifdef OVER_TIZEN_VERSION_8
1439 void WindowBaseEcoreWl2::OnPointerConstraints(void* data, int type, void* event)
1441 Ecore_Wl2_Event_Pointer_Constraints* constraintsEvent = static_cast<Ecore_Wl2_Event_Pointer_Constraints*>(event);
1443 if(constraintsEvent && constraintsEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1445 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_POINTER_CONSTRAINTS");
1446 Dali::Int32Pair position(constraintsEvent->x, constraintsEvent->y);
1447 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnPointerConstraints[%d, %d]\n", position.GetX(), position.GetY());
1449 mPointerConstraintsSignal.Emit(position, constraintsEvent->locked, constraintsEvent->confined);
1454 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1456 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1458 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1460 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
1462 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);
1464 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1466 mWheelEventSignal.Emit(wheelEvent);
1470 void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
1472 Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
1474 if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1476 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
1478 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);
1480 Device::Class::Type deviceClass;
1481 Device::Subclass::Type deviceSubclass;
1483 GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
1484 GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
1486 Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
1488 mMouseInOutEventSignal.Emit(inOutEvent);
1492 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1494 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1496 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnDetentRotation, Window (%p)\n", mEcoreWindow);
1498 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1500 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1502 mWheelEventSignal.Emit(wheelEvent);
1505 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1507 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1509 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1511 std::string keyName(keyEvent->keyname);
1512 std::string logicalKey("");
1513 std::string keyString("");
1514 std::string compose("");
1516 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_DOWN");
1518 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1519 if(keyEvent->compose)
1521 compose = keyEvent->compose;
1524 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1527 logicalKey = keyEvent->key;
1531 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1535 // Get a specific key code from dali key look up table.
1536 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1539 keyCode = (keyCode == -1) ? 0 : keyCode;
1540 int modifier(keyEvent->modifiers);
1541 unsigned long time = keyEvent->timestamp;
1542 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1544 keyCode = atoi(keyEvent->keyname + 8);
1547 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1548 if(keyEvent->string)
1550 keyString = keyEvent->string;
1553 std::string deviceName;
1554 Device::Class::Type deviceClass;
1555 Device::Subclass::Type deviceSubclass;
1557 GetDeviceName(keyEvent, deviceName);
1558 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1559 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1561 bool isRepeat = false;
1562 #ifdef OVER_TIZEN_VERSION_8
1563 if(keyEvent->event_flags & ECORE_EVENT_FLAG_REPEAT)
1569 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1570 keyEvent.isRepeat = isRepeat;
1571 keyEvent.windowId = GetNativeWindowId();
1573 mKeyEventSignal.Emit(keyEvent);
1577 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1579 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1581 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1583 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1584 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1585 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1587 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1590 #endif // Since ecore 1.23 version
1592 std::string keyName(keyEvent->keyname);
1593 std::string logicalKey("");
1594 std::string keyString("");
1595 std::string compose("");
1597 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_UP");
1599 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1600 if(keyEvent->compose)
1602 compose = keyEvent->compose;
1605 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1608 logicalKey = keyEvent->key;
1612 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1616 // Get a specific key code from dali key look up table.
1617 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1620 keyCode = (keyCode == -1) ? 0 : keyCode;
1621 int modifier(keyEvent->modifiers);
1622 unsigned long time = keyEvent->timestamp;
1623 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1625 keyCode = atoi(keyEvent->keyname + 8);
1628 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1629 if(keyEvent->string)
1631 keyString = keyEvent->string;
1634 std::string deviceName;
1635 Device::Class::Type deviceClass;
1636 Device::Subclass::Type deviceSubclass;
1638 GetDeviceName(keyEvent, deviceName);
1639 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1640 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1642 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1643 keyEvent.windowId = GetNativeWindowId();
1645 mKeyEventSignal.Emit(keyEvent);
1649 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1651 mSelectionDataSendSignal.Emit(event);
1654 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1656 mSelectionDataReceivedSignal.Emit(event);
1659 void WindowBaseEcoreWl2::OnFontNameChanged()
1661 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1664 void WindowBaseEcoreWl2::OnFontSizeChanged()
1666 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1669 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1671 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnTransitionEffectEvent, Window (%p)\n", mEcoreWindow);
1672 mTransitionEffectEventSignal.Emit(state, type);
1675 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1677 mKeyboardRepeatSettingsChangedSignal.Emit();
1680 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1682 mWindowRedrawRequestSignal.Emit();
1685 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1687 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1690 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, Window (%p), key:%s, value:%s \n", mEcoreWindow, message->key, message->val);
1691 std::string key(message->key);
1692 std::string value(message->val);
1693 Dali::Property::Array options;
1695 if(message->options)
1699 EINA_LIST_FOREACH(message->options, l, data)
1701 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, Window (%p), option: %s\n", mEcoreWindow, (char*)data);
1702 std::string option(static_cast<char*>(data));
1703 options.Add(option);
1707 mAuxiliaryMessageSignal.Emit(key, value, options);
1711 void WindowBaseEcoreWl2::OnEcoreEventConformantChange(void* event)
1713 Ecore_Wl2_Event_Conformant_Change* ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(event);
1714 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1716 WindowInsetsPartType partType = WindowInsetsPartType::STATUS_BAR;
1723 switch(ev->part_type)
1725 case ECORE_WL2_INDICATOR_PART:
1727 partType = WindowInsetsPartType::STATUS_BAR;
1728 ecore_wl2_window_indicator_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1731 case ECORE_WL2_KEYBOARD_PART:
1733 partType = WindowInsetsPartType::KEYBOARD;
1734 ecore_wl2_window_keyboard_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1737 case ECORE_WL2_CLIPBOARD_PART:
1739 partType = WindowInsetsPartType::CLIPBOARD;
1740 ecore_wl2_window_clipboard_geometry_get(mEcoreWindow, &x, &y, &w, &h);
1749 WindowInsetsPartState partState = WindowInsetsPartState::INVISIBLE;
1756 // Insets are applied only if system UI(e.g. virtual keyboard) satisfies the following 2 conditions.
1757 // 1. System UI fits to the window width or height.
1758 // 2. System UI begins or ends from the edge of window.
1759 // Otherwise, we should not resize window content because there would be empty space around system UI.
1760 bool applyInsets = false;
1762 // Zero insets are applied if state is invisible
1769 partState = WindowInsetsPartState::VISIBLE;
1771 int winX = mWindowPositionSize.x;
1772 int winY = mWindowPositionSize.y;
1773 int winW = mWindowPositionSize.width;
1774 int winH = mWindowPositionSize.height;
1776 if((x <= winX) && (x + w >= winX + winW))
1778 if((y <= winY) && (y + h >= winY) && (y + h <= winY + winH))
1783 else if((y + h >= winY + winH) && (y >= winY) && (y <= winY + winH))
1785 bottom = winY + winH - y;
1789 else if((y <= winY) && (y + h >= winY + winH))
1791 if((x <= winX) && (x + w >= winX) && (x + w <= winX + winW))
1793 left = x + w - winX;
1796 else if((x + w >= winX + winW) && (x >= winX) && (x <= winX + winW))
1798 right = winX + winW - x;
1806 mInsetsChangedSignal.Emit(partType, partState, Extents(left, right, top, bottom));
1811 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1813 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1814 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1815 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1818 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1822 void WindowBaseEcoreWl2::OnMoveCompleted(void* event)
1824 Ecore_Wl2_Event_Window_Interactive_Move_Done* movedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Move_Done*>(event);
1825 if(movedDoneEvent && movedDoneEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1827 Dali::PositionSize orgPositionSize(movedDoneEvent->x, movedDoneEvent->y, movedDoneEvent->w, movedDoneEvent->h);
1828 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1829 Dali::Int32Pair newPosition(newPositionSize.x, newPositionSize.y);
1830 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnMoveCompleted, window(%p) has been moved by server[%d, %d]\n", mEcoreWindow, newPositionSize.x, newPositionSize.y);
1831 mMoveCompletedSignal.Emit(newPosition);
1835 void WindowBaseEcoreWl2::OnResizeCompleted(void* event)
1837 Ecore_Wl2_Event_Window_Interactive_Resize_Done* resizedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Resize_Done*>(event);
1838 if(resizedDoneEvent && resizedDoneEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
1840 Dali::PositionSize orgPositionSize(resizedDoneEvent->x, resizedDoneEvent->y, resizedDoneEvent->w, resizedDoneEvent->h);
1841 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
1842 Dali::Uint16Pair newSize(newPositionSize.width, newPositionSize.height);
1843 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnResizeCompleted, window(%p) has been resized by server[%d, %d]\n", mEcoreWindow, newPositionSize.width, newPositionSize.height);
1844 mResizeCompletedSignal.Emit(newSize);
1848 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1850 if(strcmp(interface, tizen_policy_interface.name) == 0)
1852 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1854 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1857 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1861 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1863 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1865 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1867 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1868 if(!mTizenDisplayPolicy)
1870 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1874 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1876 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1880 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1882 mTizenPolicy = NULL;
1883 mTizenDisplayPolicy = NULL;
1886 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)
1888 int originalX, originalY, originalWidth, originalHeight;
1889 bool changed = false;
1893 DALI_LOG_ERROR("Failed to get wayland surface in WindowBaseEcoreWl2::TizenPolicyConformantArea()\n");
1897 if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_INDICATOR)
1899 ecore_wl2_window_indicator_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1900 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1902 ecore_wl2_window_indicator_geometry_set(mEcoreWindow, x, y, w, h);
1907 * The given state is based on the visibility value of indicator.
1908 * Thus we need to add 1 to it before comparing with indicator state.
1910 Ecore_Wl2_Indicator_State indState = ecore_wl2_window_indicator_state_get(mEcoreWindow);
1911 if((state + 1) != indState)
1913 ecore_wl2_window_indicator_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Indicator_State>(state + 1));
1917 else if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_KEYBOARD)
1919 ecore_wl2_window_keyboard_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1920 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1922 ecore_wl2_window_keyboard_geometry_set(mEcoreWindow, x, y, w, h);
1927 * The given state is based on the visibility value of virtual keyboard window.
1928 * Thus we need to add 1 to it before comparing with keyboard state.
1930 Ecore_Wl2_Virtual_Keyboard_State kbdState = ecore_wl2_window_keyboard_state_get(mEcoreWindow);
1931 if((state + 1) != (kbdState))
1933 ecore_wl2_window_keyboard_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Virtual_Keyboard_State>(state + 1));
1937 else if(conformantPart == TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD)
1939 ecore_wl2_window_clipboard_geometry_get(mEcoreWindow, &originalX, &originalY, &originalWidth, &originalHeight);
1940 if((originalX != x) || (originalY != y) || (originalWidth != w) || (originalHeight != h))
1942 ecore_wl2_window_clipboard_geometry_set(mEcoreWindow, x, y, w, h);
1947 * The given state is based on the visibility value of clipboard window.
1948 * Thus we need to add 1 to it before comparing with clipboard state.
1950 Ecore_Wl2_Clipboard_State clipState = ecore_wl2_window_clipboard_state_get(mEcoreWindow);
1951 if((state + 1) != clipState)
1953 ecore_wl2_window_clipboard_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Clipboard_State>(state + 1));
1960 Ecore_Wl2_Event_Conformant_Change* ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(calloc(1, sizeof(Ecore_Wl2_Event_Conformant_Change)));
1966 ev->win = GetNativeWindowId();
1967 ev->part_type = static_cast<Ecore_Wl2_Conformant_Part_Type>(conformantPart);
1969 ecore_event_add(ECORE_WL2_EVENT_CONFORMANT_CHANGE, ev, NULL, NULL);
1972 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);
1975 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1977 mNotificationLevel = level;
1978 mNotificationChangeState = state;
1979 mNotificationLevelChangeDone = true;
1981 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1984 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1986 mScreenOffMode = mode;
1987 mScreenOffModeChangeState = state;
1988 mScreenOffModeChangeDone = true;
1990 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1993 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1995 mBrightness = brightness;
1996 mBrightnessChangeState = state;
1997 mBrightnessChangeDone = true;
1999 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
2002 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
2004 xkb_keysym_t sym = XKB_KEY_NoSymbol;
2005 KeyCodeMap foundKeyCode;
2007 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
2008 if(sym == XKB_KEY_NoSymbol || !mKeyMap)
2010 DALI_LOG_ERROR("Failed to get keysym or keymap in WindowBaseEcoreWl2\n");
2014 foundKeyCode.keySym = sym;
2015 foundKeyCode.isKeyCode = false;
2016 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
2017 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
2020 Any WindowBaseEcoreWl2::GetNativeWindow()
2022 return mEcoreWindow;
2025 int WindowBaseEcoreWl2::GetNativeWindowId()
2027 return ecore_wl2_window_id_get(mEcoreWindow);
2030 std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
2032 #ifdef OVER_TIZEN_VERSION_7
2033 return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
2035 return std::string();
2039 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
2041 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
2043 START_DURATION_CHECK();
2044 if(totalAngle == 90 || totalAngle == 270)
2046 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
2050 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
2052 FINISH_DURATION_CHECK("wl_egl_window_create");
2054 return static_cast<EGLNativeWindowType>(mEglWindow);
2057 void WindowBaseEcoreWl2::DestroyEglWindow()
2059 if(mEglWindow != NULL)
2061 START_DURATION_CHECK();
2062 wl_egl_window_destroy(mEglWindow);
2063 FINISH_DURATION_CHECK("wl_egl_window_destroy");
2069 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
2071 wl_egl_window_tizen_rotation rotation;
2077 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
2082 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
2087 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
2092 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
2097 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
2102 START_DURATION_CHECK();
2103 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
2104 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_rotation");
2107 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
2109 wl_output_transform bufferTransform;
2115 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2120 bufferTransform = WL_OUTPUT_TRANSFORM_90;
2125 bufferTransform = WL_OUTPUT_TRANSFORM_180;
2130 bufferTransform = WL_OUTPUT_TRANSFORM_270;
2135 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2140 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_buffer_transform() with buffer Transform [%d]\n", bufferTransform);
2141 START_DURATION_CHECK();
2142 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
2143 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_buffer_transform");
2146 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
2148 wl_output_transform windowTransform;
2154 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2159 windowTransform = WL_OUTPUT_TRANSFORM_90;
2164 windowTransform = WL_OUTPUT_TRANSFORM_180;
2169 windowTransform = WL_OUTPUT_TRANSFORM_270;
2174 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
2179 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_window_transform() with window Transform [%d]\n", windowTransform);
2180 START_DURATION_CHECK();
2181 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
2182 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_window_transform");
2185 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
2187 DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2188 START_DURATION_CHECK();
2189 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
2191 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
2192 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
2194 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
2195 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
2197 FINISH_DURATION_CHECK("wl_egl_window functions");
2200 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
2202 START_DURATION_CHECK();
2204 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
2205 FINISH_DURATION_CHECK("wl_egl_window_tizen_get_capabilities");
2207 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
2209 mSupportedPreProtation = true;
2212 mSupportedPreProtation = false;
2216 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
2218 PositionSize newPositionSize;
2219 int32_t screenWidth, screenHeight;
2220 WindowSystem::GetScreenSize(screenWidth, screenHeight);
2222 if(mWindowRotationAngle == 90)
2224 newPositionSize.x = positionSize.y;
2225 newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
2226 newPositionSize.width = positionSize.height;
2227 newPositionSize.height = positionSize.width;
2229 else if(mWindowRotationAngle == 180)
2231 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
2232 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
2233 newPositionSize.width = positionSize.width;
2234 newPositionSize.height = positionSize.height;
2236 else if(mWindowRotationAngle == 270)
2238 newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
2239 newPositionSize.y = positionSize.x;
2240 newPositionSize.width = positionSize.height;
2241 newPositionSize.height = positionSize.width;
2245 newPositionSize.x = positionSize.x;
2246 newPositionSize.y = positionSize.y;
2247 newPositionSize.width = positionSize.width;
2248 newPositionSize.height = positionSize.height;
2251 return newPositionSize;
2254 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
2256 PositionSize newPositionSize;
2257 int32_t screenWidth, screenHeight;
2258 WindowSystem::GetScreenSize(screenWidth, screenHeight);
2260 if(mWindowRotationAngle == 90)
2262 newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
2263 newPositionSize.y = positionSize.x;
2264 newPositionSize.width = positionSize.height;
2265 newPositionSize.height = positionSize.width;
2267 else if(mWindowRotationAngle == 180)
2269 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
2270 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
2271 newPositionSize.width = positionSize.width;
2272 newPositionSize.height = positionSize.height;
2274 else if(mWindowRotationAngle == 270)
2276 newPositionSize.x = positionSize.y;
2277 newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
2278 newPositionSize.width = positionSize.height;
2279 newPositionSize.height = positionSize.width;
2283 newPositionSize.x = positionSize.x;
2284 newPositionSize.y = positionSize.y;
2285 newPositionSize.width = positionSize.width;
2286 newPositionSize.height = positionSize.height;
2289 return newPositionSize;
2292 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
2294 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2296 mWindowPositionSize = newPositionSize;
2297 DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
2298 START_DURATION_CHECK();
2299 ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
2300 FINISH_DURATION_CHECK("ecore_wl2_window_position_set");
2303 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
2305 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2307 mWindowPositionSize = newPositionSize;
2308 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);
2309 START_DURATION_CHECK();
2310 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
2311 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
2314 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
2316 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
2318 mWindowPositionSize = newPositionSize;
2319 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);
2320 START_DURATION_CHECK();
2321 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
2322 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
2325 void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
2327 #ifdef OVER_TIZEN_VERSION_8
2328 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);
2329 START_DURATION_CHECK();
2330 ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
2331 FINISH_DURATION_CHECK("ecore_wl2_window_layout_set");
2335 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
2337 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
2338 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
2341 void WindowBaseEcoreWl2::Raise()
2343 START_DURATION_CHECK();
2344 // Use ecore_wl2_window_activate to prevent the window shown without rendering
2345 ecore_wl2_window_activate(mEcoreWindow);
2346 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
2349 void WindowBaseEcoreWl2::Lower()
2351 START_DURATION_CHECK();
2352 ecore_wl2_window_lower(mEcoreWindow);
2353 FINISH_DURATION_CHECK("ecore_wl2_window_lower");
2356 void WindowBaseEcoreWl2::Activate()
2358 START_DURATION_CHECK();
2359 ecore_wl2_window_activate(mEcoreWindow);
2360 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
2363 void WindowBaseEcoreWl2::Maximize(bool maximize)
2365 START_DURATION_CHECK();
2366 ecore_wl2_window_maximized_set(mEcoreWindow, maximize);
2367 FINISH_DURATION_CHECK("ecore_wl2_window_maximized_set");
2370 bool WindowBaseEcoreWl2::IsMaximized() const
2372 return ecore_wl2_window_maximized_get(mEcoreWindow);
2375 void WindowBaseEcoreWl2::SetMaximumSize(Dali::Window::WindowSize size)
2377 DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2378 START_DURATION_CHECK();
2379 ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2380 FINISH_DURATION_CHECK("ecore_wl2_window_maximum_size_set");
2381 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2384 void WindowBaseEcoreWl2::Minimize(bool minimize)
2386 START_DURATION_CHECK();
2387 ecore_wl2_window_iconified_set(mEcoreWindow, minimize);
2388 FINISH_DURATION_CHECK("ecore_wl2_window_iconified_set");
2391 bool WindowBaseEcoreWl2::IsMinimized() const
2393 return ecore_wl2_window_iconified_get(mEcoreWindow);
2396 void WindowBaseEcoreWl2::SetMimimumSize(Dali::Window::WindowSize size)
2398 DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2399 START_DURATION_CHECK();
2400 ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2401 FINISH_DURATION_CHECK("ecore_wl2_window_minimum_size_set");
2402 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2405 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
2407 int rotations[4] = {0};
2408 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
2409 for(std::size_t i = 0; i < angles.size(); ++i)
2411 rotations[i] = static_cast<int>(angles[i]);
2412 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
2415 START_DURATION_CHECK();
2416 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
2417 FINISH_DURATION_CHECK("ecore_wl2_window_available_rotations_set");
2420 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
2422 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
2423 START_DURATION_CHECK();
2424 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
2425 FINISH_DURATION_CHECK("ecore_wl2_window_preferred_rotation_set");
2428 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
2430 START_DURATION_CHECK();
2431 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
2432 FINISH_DURATION_CHECK("ecore_wl2_window_focus_skip_set");
2435 void WindowBaseEcoreWl2::Show()
2439 START_DURATION_CHECK();
2440 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
2441 FINISH_DURATION_CHECK("ecore_wl2_window_geometry_set");
2445 ecore_wl2_window_show(mEcoreWindow);
2448 void WindowBaseEcoreWl2::Hide()
2451 ecore_wl2_window_hide(mEcoreWindow);
2454 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
2456 return mSupportedAuxiliaryHints.size();
2459 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
2461 if(index >= GetSupportedAuxiliaryHintCount())
2463 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
2466 return mSupportedAuxiliaryHints[index];
2469 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
2471 bool supported = false;
2473 // Check if the hint is suppported
2474 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
2485 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
2489 // Check if the hint is already added
2490 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2492 if(mAuxiliaryHints[i].first == hint)
2494 // Just change the value
2495 mAuxiliaryHints[i].second = value;
2497 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
2499 return i + 1; // id is index + 1
2504 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
2506 unsigned int id = mAuxiliaryHints.size();
2508 START_DURATION_CHECK();
2509 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
2510 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_add");
2512 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
2517 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
2519 if(id == 0 || id > mAuxiliaryHints.size())
2521 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
2525 mAuxiliaryHints[id - 1].second = std::string();
2527 START_DURATION_CHECK();
2528 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
2529 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_del");
2531 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
2536 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
2538 if(id == 0 || id > mAuxiliaryHints.size())
2540 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
2544 mAuxiliaryHints[id - 1].second = value;
2546 START_DURATION_CHECK();
2547 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
2548 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_change");
2550 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());
2555 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
2557 if(id == 0 || id > mAuxiliaryHints.size())
2559 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
2560 return std::string();
2563 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());
2565 return mAuxiliaryHints[id - 1].second;
2568 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
2570 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2572 if(mAuxiliaryHints[i].first == hint)
2574 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
2579 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
2584 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
2586 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
2588 Eina_Rectangle rect;
2589 rect.x = convertRegion.x;
2590 rect.y = convertRegion.y;
2591 rect.w = convertRegion.width;
2592 rect.h = convertRegion.height;
2594 DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2595 START_DURATION_CHECK();
2596 ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
2597 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_set");
2598 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2601 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
2606 Ecore_Wl2_Window_Type windowType;
2610 case Dali::WindowType::NORMAL:
2612 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::NORMAL\n");
2613 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2616 case Dali::WindowType::NOTIFICATION:
2618 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::NOTIFICATION\n");
2619 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
2622 case Dali::WindowType::UTILITY:
2624 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::UTILITY\n");
2625 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
2628 case Dali::WindowType::DIALOG:
2630 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::DIALOG\n");
2631 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
2634 case Dali::WindowType::IME:
2636 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::IME\n");
2637 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
2640 case Dali::WindowType::DESKTOP:
2642 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, Dali::WindowType::DESKTOP\n");
2643 windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
2648 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetType, default window type\n");
2649 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2654 START_DURATION_CHECK();
2655 ecore_wl2_window_type_set(mEcoreWindow, windowType);
2656 FINISH_DURATION_CHECK("ecore_wl2_window_type_set");
2660 Dali::WindowType WindowBaseEcoreWl2::GetType() const
2662 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::GetType(), Window (%p), DALI WindType: %d, mIsIMEWindowInitialized: %d\n", mEcoreWindow, mType, mIsIMEWindowInitialized);
2666 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
2668 START_DURATION_CHECK();
2669 while(!mTizenPolicy)
2671 wl_display_dispatch_queue(mDisplay, mEventQueue);
2674 int notificationLevel;
2676 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetNotificationLevel(), Window (%p), level [%d]\n", mEcoreWindow, level);
2679 case Dali::WindowNotificationLevel::NONE:
2681 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
2684 case Dali::WindowNotificationLevel::BASE:
2686 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2689 case Dali::WindowNotificationLevel::MEDIUM:
2691 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
2694 case Dali::WindowNotificationLevel::HIGH:
2696 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
2699 case Dali::WindowNotificationLevel::TOP:
2701 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
2706 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetNotificationLevel(), invalid level [%d]\n", level);
2707 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2712 mNotificationLevelChangeDone = false;
2713 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2715 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2719 while(!mNotificationLevelChangeDone && count < 3)
2721 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2722 wl_display_dispatch_queue(mDisplay, mEventQueue);
2725 FINISH_DURATION_CHECK("ecore_wl2 & wl_display");
2727 if(!mNotificationLevelChangeDone)
2729 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2730 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2732 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2734 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2735 return Dali::WindowOperationResult::PERMISSION_DENIED;
2738 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2740 return Dali::WindowOperationResult::SUCCEED;
2743 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2745 while(!mTizenPolicy)
2747 wl_display_dispatch_queue(mDisplay, mEventQueue);
2752 while(!mNotificationLevelChangeDone && count < 3)
2754 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2755 wl_display_dispatch_queue(mDisplay, mEventQueue);
2759 if(!mNotificationLevelChangeDone)
2761 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2762 return Dali::WindowNotificationLevel::NONE;
2765 Dali::WindowNotificationLevel level;
2767 switch(mNotificationLevel)
2769 case TIZEN_POLICY_LEVEL_NONE:
2771 level = Dali::WindowNotificationLevel::NONE;
2774 case TIZEN_POLICY_LEVEL_DEFAULT:
2776 level = Dali::WindowNotificationLevel::BASE;
2779 case TIZEN_POLICY_LEVEL_MEDIUM:
2781 level = Dali::WindowNotificationLevel::MEDIUM;
2784 case TIZEN_POLICY_LEVEL_HIGH:
2786 level = Dali::WindowNotificationLevel::HIGH;
2789 case TIZEN_POLICY_LEVEL_TOP:
2791 level = Dali::WindowNotificationLevel::TOP;
2796 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2797 level = Dali::WindowNotificationLevel::NONE;
2802 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2807 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2809 while(!mTizenPolicy)
2811 wl_display_dispatch_queue(mDisplay, mEventQueue);
2814 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2817 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2819 while(!mTizenPolicy)
2821 wl_display_dispatch_queue(mDisplay, mEventQueue);
2824 mScreenOffModeChangeDone = false;
2825 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2827 unsigned int mode = 0;
2829 switch(screenOffMode)
2831 case WindowScreenOffMode::TIMEOUT:
2836 case WindowScreenOffMode::NEVER:
2843 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2847 while(!mScreenOffModeChangeDone && count < 3)
2849 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2850 wl_display_dispatch_queue(mDisplay, mEventQueue);
2854 if(!mScreenOffModeChangeDone)
2856 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2857 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2859 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2861 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2862 return Dali::WindowOperationResult::PERMISSION_DENIED;
2865 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2867 return Dali::WindowOperationResult::SUCCEED;
2870 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2872 while(!mTizenPolicy)
2874 wl_display_dispatch_queue(mDisplay, mEventQueue);
2879 while(!mScreenOffModeChangeDone && count < 3)
2881 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2882 wl_display_dispatch_queue(mDisplay, mEventQueue);
2886 if(!mScreenOffModeChangeDone)
2888 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2889 return WindowScreenOffMode::TIMEOUT;
2892 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2894 switch(mScreenOffMode)
2898 screenMode = WindowScreenOffMode::TIMEOUT;
2903 screenMode = WindowScreenOffMode::NEVER;
2908 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2913 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2915 START_DURATION_CHECK();
2916 while(!mTizenDisplayPolicy)
2918 wl_display_dispatch_queue(mDisplay, mEventQueue);
2921 mBrightnessChangeDone = false;
2922 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2924 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
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::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2939 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2941 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2943 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2944 return Dali::WindowOperationResult::PERMISSION_DENIED;
2947 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2949 return Dali::WindowOperationResult::SUCCEED;
2952 int WindowBaseEcoreWl2::GetBrightness() const
2954 START_DURATION_CHECK();
2955 while(!mTizenDisplayPolicy)
2957 wl_display_dispatch_queue(mDisplay, mEventQueue);
2962 while(!mBrightnessChangeDone && count < 3)
2964 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2965 wl_display_dispatch_queue(mDisplay, mEventQueue);
2968 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2970 if(!mBrightnessChangeDone)
2972 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2976 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2981 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2983 Ecore_Wl2_Window_Keygrab_Mode mode;
2987 case KeyGrab::TOPMOST:
2989 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2992 case KeyGrab::SHARED:
2994 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2997 case KeyGrab::OVERRIDE_EXCLUSIVE:
2999 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
3002 case KeyGrab::EXCLUSIVE:
3004 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
3013 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
3016 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
3018 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
3021 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
3023 int keyCount = key.Count();
3024 int keyGrabModeCount = grabMode.Count();
3026 if(keyCount != keyGrabModeCount || keyCount == 0)
3033 Eina_List* keyList = NULL;
3034 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
3036 for(int index = 0; index < keyCount; ++index)
3038 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
3040 switch(grabMode[index])
3042 case KeyGrab::TOPMOST:
3044 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
3047 case KeyGrab::SHARED:
3049 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
3052 case KeyGrab::OVERRIDE_EXCLUSIVE:
3054 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
3057 case KeyGrab::EXCLUSIVE:
3059 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
3064 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
3069 keyList = eina_list_append(keyList, &info);
3072 START_DURATION_CHECK();
3073 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
3074 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_set");
3076 result.Resize(keyCount, true);
3078 Eina_List* l = NULL;
3079 Eina_List* m = NULL;
3080 void* listData = NULL;
3082 if(grabList != NULL)
3084 EINA_LIST_FOREACH(grabList, m, data)
3087 EINA_LIST_FOREACH(keyList, l, listData)
3089 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
3091 DALI_LOG_ERROR("input key list has null data!");
3095 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
3097 result[index] = false;
3106 eina_list_free(keyList);
3107 eina_list_free(grabList);
3113 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
3115 int keyCount = key.Count();
3123 Eina_List* keyList = NULL;
3124 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
3126 for(int index = 0; index < keyCount; ++index)
3128 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
3129 keyList = eina_list_append(keyList, &info);
3132 START_DURATION_CHECK();
3133 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
3134 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_unset");
3136 result.Resize(keyCount, true);
3138 Eina_List* l = NULL;
3139 Eina_List* m = NULL;
3140 void* listData = NULL;
3143 if(ungrabList != NULL)
3145 EINA_LIST_FOREACH(ungrabList, m, data)
3148 EINA_LIST_FOREACH(keyList, l, listData)
3150 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
3152 result[index] = false;
3161 eina_list_free(keyList);
3162 eina_list_free(ungrabList);
3168 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
3173 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
3175 // 1 inch = 25.4 millimeters
3176 xres = ecore_wl2_output_dpi_get(output);
3177 yres = ecore_wl2_output_dpi_get(output);
3179 dpiHorizontal = int(xres + 0.5f); // rounding
3180 dpiVertical = int(yres + 0.5f);
3183 int WindowBaseEcoreWl2::GetWindowRotationAngle() const
3185 int orientation = mWindowRotationAngle;
3186 if(mSupportedPreProtation)
3193 int WindowBaseEcoreWl2::GetScreenRotationAngle()
3195 if(mSupportedPreProtation)
3197 DALI_LOG_RELEASE_INFO("Support PreRotation and return 0\n");
3201 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
3207 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
3209 mScreenRotationAngle = transform * 90;
3210 return mScreenRotationAngle;
3213 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
3215 mWindowRotationAngle = degree;
3216 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
3219 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
3221 START_DURATION_CHECK();
3222 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
3223 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_change_done_send");
3226 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
3228 START_DURATION_CHECK();
3229 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
3230 FINISH_DURATION_CHECK("ecore_wl2_window_alpha_set");
3233 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
3235 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
3238 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
3241 START_DURATION_CHECK();
3242 ecore_wl2_display_sync(display);
3244 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
3246 if(mEcoreWindow == 0)
3248 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
3252 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
3253 FINISH_DURATION_CHECK("ecore_wl2 functions");
3256 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
3258 Ecore_Wl2_Window* ecoreParent = NULL;
3261 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
3262 ecoreParent = winBaseEcore2->mEcoreWindow;
3265 START_DURATION_CHECK();
3266 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
3267 FINISH_DURATION_CHECK("ecore_wl2_window_transient_parent_set");
3270 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
3272 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
3275 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
3277 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
3280 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
3282 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);
3283 START_DURATION_CHECK();
3284 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
3285 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_geometry_set");
3288 void WindowBaseEcoreWl2::InitializeIme()
3290 Eina_Iterator* globals;
3291 struct wl_registry* registry;
3292 Ecore_Wl2_Global* global;
3293 Ecore_Wl2_Display* ecoreWl2Display;
3295 if(mIsIMEWindowInitialized)
3297 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::InitializeIme, IME Window is already initialized\n");
3301 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
3303 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
3307 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p, mIsIMEWindowInitialized: %d\n", ecoreWl2Display, mEcoreWindow, mIsIMEWindowInitialized);
3309 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
3311 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
3315 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
3317 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
3321 START_DURATION_CHECK();
3322 EINA_ITERATOR_FOREACH(globals, global)
3324 #ifdef OVER_TIZEN_VERSION_7
3325 if(strcmp(global->interface, "zwp_input_panel_v1") == 0)
3327 mWlInputPanel = (zwp_input_panel_v1*)wl_registry_bind(registry, global->id, &zwp_input_panel_v1_interface, 1);
3330 if(strcmp(global->interface, "wl_input_panel") == 0)
3332 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
3335 else if(strcmp(global->interface, "wl_output") == 0)
3337 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
3343 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
3349 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
3352 #ifdef OVER_TIZEN_VERSION_7
3353 mWlInputPanelSurface = zwp_input_panel_v1_get_input_panel_surface(mWlInputPanel, mWlSurface);
3355 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
3357 if(!mWlInputPanelSurface)
3359 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
3362 #ifdef OVER_TIZEN_VERSION_7
3363 zwp_input_panel_surface_v1_set_toplevel(mWlInputPanelSurface, mWlOutput, ZWP_INPUT_PANEL_SURFACE_V1_POSITION_CENTER_BOTTOM);
3365 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
3367 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_toplevel");
3368 mIsIMEWindowInitialized = true;
3371 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
3373 if(!mWlInputPanelSurface)
3375 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
3379 START_DURATION_CHECK();
3380 #ifdef OVER_TIZEN_VERSION_7
3381 zwp_input_panel_surface_v1_set_ready(mWlInputPanelSurface, 1);
3383 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
3385 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_ready");
3388 void WindowBaseEcoreWl2::RequestMoveToServer()
3390 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3393 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
3397 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3400 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
3404 START_DURATION_CHECK();
3405 ecore_wl2_window_move(mEcoreWindow, input);
3406 FINISH_DURATION_CHECK("ecore_wl2_window_move");
3407 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
3410 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
3412 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3415 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
3419 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3422 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
3426 ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
3428 START_DURATION_CHECK();
3429 ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
3430 FINISH_DURATION_CHECK("ecore_wl2_window_resize");
3431 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);
3434 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
3436 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
3437 START_DURATION_CHECK();
3440 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
3444 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
3446 FINISH_DURATION_CHECK("ecore_wl2_window_floating_mode_set");
3449 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
3451 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
3454 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
3456 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
3457 Eina_Rectangle rect;
3459 rect.x = convertRegion.x;
3460 rect.y = convertRegion.y;
3461 rect.w = convertRegion.width;
3462 rect.h = convertRegion.height;
3464 DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3465 START_DURATION_CHECK();
3466 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
3467 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_add");
3468 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3471 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
3473 Rect<int> convertRegion = RecalculatePositionSizeToSystem(inputRegion);
3474 Eina_Rectangle rect;
3476 rect.x = convertRegion.x;
3477 rect.y = convertRegion.y;
3478 rect.w = convertRegion.width;
3479 rect.h = convertRegion.height;
3481 DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3482 START_DURATION_CHECK();
3483 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
3484 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_subtract");
3485 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3488 bool WindowBaseEcoreWl2::PointerConstraintsLock()
3490 #ifdef OVER_TIZEN_VERSION_8
3491 return ecore_wl2_window_pointer_constraints_lock_pointer(mEcoreWindow);
3497 bool WindowBaseEcoreWl2::PointerConstraintsUnlock()
3499 #ifdef OVER_TIZEN_VERSION_8
3500 return ecore_wl2_window_pointer_constraints_unlock_pointer(mEcoreWindow);
3506 void WindowBaseEcoreWl2::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
3508 #ifdef OVER_TIZEN_VERSION_8
3509 ecore_wl2_window_locked_pointer_region_set(mEcoreWindow, x, y, width, height);
3510 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3514 void WindowBaseEcoreWl2::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
3516 #ifdef OVER_TIZEN_VERSION_8
3517 ecore_wl2_window_locked_pointer_cursor_position_hint_set(mEcoreWindow, x, y);
3518 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3522 bool WindowBaseEcoreWl2::PointerWarp(int32_t x, int32_t y)
3524 return ecore_wl2_window_pointer_warp(mEcoreWindow, x, y);
3527 void WindowBaseEcoreWl2::CursorVisibleSet(bool visible)
3529 #ifdef OVER_TIZEN_VERSION_8
3530 ecore_wl2_window_cursor_visible_set(mEcoreWindow, visible);
3534 // Request grab key events according to the requested device subtype
3535 //(For now, subtype could be '0'/'11'/'12' which equals to ECORE_DEVICE_SUBCLASS_NONE/REMOCON/VIRTUAL_KEYBOARD)
3536 bool WindowBaseEcoreWl2::KeyboardGrab(Device::Subclass::Type deviceSubclass)
3538 #ifdef OVER_TIZEN_VERSION_8
3539 Ecore_Device_Subclass ecoreDeviceSubclass;
3540 switch(deviceSubclass)
3542 case Device::Subclass::NONE:
3544 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_NONE;
3547 case Device::Subclass::REMOCON:
3549 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_REMOCON;
3552 case Device::Subclass::VIRTUAL_KEYBOARD:
3554 ecoreDeviceSubclass = ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD;
3559 DALI_LOG_ERROR("deviceSubclass : %d type is not support, subtype could be 'NONE', 'REMOCON', 'VIRTUAL_KEYBOARD'\n");
3563 return ecore_wl2_window_keyboard_grab(mEcoreWindow, ecoreDeviceSubclass);
3569 // Request ungrab key events
3570 bool WindowBaseEcoreWl2::KeyboardUnGrab()
3572 #ifdef OVER_TIZEN_VERSION_8
3573 return ecore_wl2_window_keyboard_ungrab(mEcoreWindow);
3579 void WindowBaseEcoreWl2::SetFullScreen(bool fullscreen)
3581 DALI_LOG_RELEASE_INFO("ecore_wl2_window_fullscreen_set, window: [%p], fullscreen [%d]\n", mEcoreWindow, fullscreen);
3582 START_DURATION_CHECK();
3583 ecore_wl2_window_fullscreen_set(mEcoreWindow, fullscreen);
3584 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3585 FINISH_DURATION_CHECK("ecore_wl2_window_fullscreen_set");
3588 bool WindowBaseEcoreWl2::GetFullScreen()
3590 return ecore_wl2_window_fullscreen_get(mEcoreWindow);
3593 void WindowBaseEcoreWl2::SetFrontBufferRendering(bool enable)
3595 mIsFrontBufferRendering = enable;
3598 bool WindowBaseEcoreWl2::GetFrontBufferRendering()
3600 return mIsFrontBufferRendering;
3603 void WindowBaseEcoreWl2::SetEglWindowFrontBufferMode(bool enable)
3605 wl_egl_window_tizen_set_frontbuffer_mode(mEglWindow, enable);
3608 } // namespace Adaptor
3610 } // namespace Internal
3614 #pragma GCC diagnostic pop