2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Ecore is littered with C style cast
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wold-style-cast"
23 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
26 #include <dali/internal/input/common/key-impl.h>
27 #include <dali/internal/system/common/time-service.h>
28 #include <dali/internal/window-system/common/window-impl.h>
29 #include <dali/internal/window-system/common/window-render-surface.h>
30 #include <dali/internal/window-system/common/window-system.h>
33 #include <Ecore_Input.h>
34 #include <dali/integration-api/debug.h>
35 #include <dali/integration-api/trace.h>
36 #include <dali/public-api/adaptor-framework/window-enumerations.h>
37 #include <dali/public-api/events/mouse-button.h>
38 #include <dali/public-api/object/any.h>
40 #if defined(VCONF_ENABLED)
41 #include <vconf-keys.h>
45 #define START_DURATION_CHECK() \
46 uint32_t durationMilliSeconds = static_cast<uint32_t>(-1); \
47 uint32_t startTime, endTime; \
48 startTime = TimeService::GetMilliSeconds();
50 #define FINISH_DURATION_CHECK(functionName) \
51 endTime = TimeService::GetMilliSeconds(); \
52 durationMilliSeconds = endTime - startTime; \
53 if(durationMilliSeconds > 0) \
55 DALI_LOG_DEBUG_INFO("%s : duration [%u ms]\n", functionName, durationMilliSeconds); \
58 #include <wayland-egl-tizen.h>
68 #if defined(DEBUG_ENABLED)
69 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
72 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
75 * @brief Enumeration of location for window resized by display server.
77 enum class ResizeLocation
79 INVALID = 0, ///< Invalid value
80 TOP_LEFT = 5, ///< Start resizing window to the top-left edge.
81 LEFT = 4, ///< Start resizing window to the left side.
82 BOTTOM_LEFT = 6, ///< Start resizing window to the bottom-left edge.
83 BOTTOM = 2, ///< Start resizing window to the bottom side.
84 BOTTOM_RIGHT = 10, ///< Start resizing window to the bottom-right edge.
85 RIGHT = 8, ///< Start resizing window to the right side.
86 TOP_RIGHT = 9, ///< Start resizing window to the top-right edge.
87 TOP = 1 ///< Start resizing window to the top side.
90 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
91 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
92 const ResizeLocation RESIZE_LOCATIONS[] = {ResizeLocation::TOP_LEFT, ResizeLocation::LEFT, ResizeLocation::BOTTOM_LEFT, ResizeLocation::BOTTOM, ResizeLocation::BOTTOM_RIGHT, ResizeLocation::RIGHT, ResizeLocation::TOP_RIGHT, ResizeLocation::TOP, ResizeLocation::INVALID};
94 #if defined(VCONF_ENABLED)
95 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
101 xkb_keycode_t keyCode;
106 * Get the device name from the provided ecore key event
108 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
110 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
114 result = ecoreDeviceName;
119 * Get the device class from the provided ecore event
121 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
123 switch(ecoreDeviceClass)
125 case ECORE_DEVICE_CLASS_SEAT:
127 deviceClass = Device::Class::USER;
130 case ECORE_DEVICE_CLASS_KEYBOARD:
132 deviceClass = Device::Class::KEYBOARD;
135 case ECORE_DEVICE_CLASS_MOUSE:
137 deviceClass = Device::Class::MOUSE;
140 case ECORE_DEVICE_CLASS_TOUCH:
142 deviceClass = Device::Class::TOUCH;
145 case ECORE_DEVICE_CLASS_PEN:
147 deviceClass = Device::Class::PEN;
150 case ECORE_DEVICE_CLASS_POINTER:
152 deviceClass = Device::Class::POINTER;
155 case ECORE_DEVICE_CLASS_GAMEPAD:
157 deviceClass = Device::Class::GAMEPAD;
162 deviceClass = Device::Class::NONE;
168 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
170 switch(ecoreDeviceSubclass)
172 case ECORE_DEVICE_SUBCLASS_FINGER:
174 deviceSubclass = Device::Subclass::FINGER;
177 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
179 deviceSubclass = Device::Subclass::FINGERNAIL;
182 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
184 deviceSubclass = Device::Subclass::KNUCKLE;
187 case ECORE_DEVICE_SUBCLASS_PALM:
189 deviceSubclass = Device::Subclass::PALM;
192 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
194 deviceSubclass = Device::Subclass::HAND_SIDE;
197 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
199 deviceSubclass = Device::Subclass::HAND_FLAT;
202 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
204 deviceSubclass = Device::Subclass::PEN_TIP;
207 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
209 deviceSubclass = Device::Subclass::TRACKPAD;
212 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
214 deviceSubclass = Device::Subclass::TRACKPOINT;
217 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
219 deviceSubclass = Device::Subclass::TRACKBALL;
222 case ECORE_DEVICE_SUBCLASS_REMOCON:
224 deviceSubclass = Device::Subclass::REMOCON;
227 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
229 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
234 deviceSubclass = Device::Subclass::NONE;
240 void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
242 KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
243 if(foundKeyCode->isKeyCode)
248 xkb_keysym_t keySym = foundKeyCode->keySym;
250 const xkb_keysym_t* symsOut = NULL;
252 nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
256 if(*symsOut == keySym)
258 foundKeyCode->keyCode = key;
259 foundKeyCode->isKeyCode = true;
265 * Return the recalculated window resizing location according to the current orientation.
267 ResizeLocation RecalculateLocationToCurrentOrientation(WindowResizeDirection direction, int windowRotationAngle)
272 case WindowResizeDirection::TOP_LEFT:
277 case WindowResizeDirection::LEFT:
282 case WindowResizeDirection::BOTTOM_LEFT:
287 case WindowResizeDirection::BOTTOM:
292 case WindowResizeDirection::BOTTOM_RIGHT:
297 case WindowResizeDirection::RIGHT:
302 case WindowResizeDirection::TOP_RIGHT:
307 case WindowResizeDirection::TOP:
319 if(index != 8 && windowRotationAngle != 0)
321 index = (index + (windowRotationAngle / 90) * 2) % 8;
324 return RESIZE_LOCATIONS[index];
327 /////////////////////////////////////////////////////////////////////////////////////////////////
329 /////////////////////////////////////////////////////////////////////////////////////////////////
331 /// Called when the window iconify state is changed.
332 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
334 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
337 return windowBase->OnIconifyStateChanged(data, type, event);
340 return ECORE_CALLBACK_PASS_ON;
343 /// Called when the window gains focus
344 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
346 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
349 return windowBase->OnFocusIn(data, type, event);
352 return ECORE_CALLBACK_PASS_ON;
355 /// Called when the window loses focus
356 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
358 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
361 return windowBase->OnFocusOut(data, type, event);
364 return ECORE_CALLBACK_PASS_ON;
367 /// Called when the output is transformed
368 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
370 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
373 return windowBase->OnOutputTransform(data, type, event);
376 return ECORE_CALLBACK_PASS_ON;
379 /// Called when the output transform should be ignored
380 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
382 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
385 return windowBase->OnIgnoreOutputTransform(data, type, event);
388 return ECORE_CALLBACK_PASS_ON;
392 * Called when rotate event is recevied.
394 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
396 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
399 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
400 windowBase->OnRotation(data, type, event);
402 return ECORE_CALLBACK_PASS_ON;
406 * Called when configure event is recevied.
408 static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
410 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
413 windowBase->OnConfiguration(data, type, event);
415 return ECORE_CALLBACK_PASS_ON;
418 /////////////////////////////////////////////////////////////////////////////////////////////////
420 /////////////////////////////////////////////////////////////////////////////////////////////////
423 * Called when a touch down is received.
425 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
427 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
430 windowBase->OnMouseButtonDown(data, type, event);
432 return ECORE_CALLBACK_PASS_ON;
436 * Called when a touch up is received.
438 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
440 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
443 windowBase->OnMouseButtonUp(data, type, event);
445 return ECORE_CALLBACK_PASS_ON;
449 * Called when a touch motion is received.
451 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
453 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
456 windowBase->OnMouseButtonMove(data, type, event);
458 return ECORE_CALLBACK_PASS_ON;
462 * Called when a touch is canceled.
464 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
466 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
469 windowBase->OnMouseButtonCancel(data, type, event);
471 return ECORE_CALLBACK_PASS_ON;
475 * Called when a mouse wheel is received.
477 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
479 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
482 windowBase->OnMouseWheel(data, type, event);
484 return ECORE_CALLBACK_PASS_ON;
488 * Called when a mouse in is received.
490 static Eina_Bool EcoreEventMouseIn(void* data, int type, void* event)
492 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
495 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::IN);
497 return ECORE_CALLBACK_PASS_ON;
501 * Called when a mouse out is received.
503 static Eina_Bool EcoreEventMouseOut(void* data, int type, void* event)
505 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
508 // When the mouse is out, the previous mouse must be canceled.
509 windowBase->OnMouseButtonCancel(data, type, event);
510 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::OUT);
512 return ECORE_CALLBACK_PASS_ON;
516 * Called when a detent rotation event is recevied.
518 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
520 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
523 windowBase->OnDetentRotation(data, type, event);
525 return ECORE_CALLBACK_PASS_ON;
528 /////////////////////////////////////////////////////////////////////////////////////////////////
530 /////////////////////////////////////////////////////////////////////////////////////////////////
533 * Called when a key down is received.
535 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
537 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
540 windowBase->OnKeyDown(data, type, event);
542 return ECORE_CALLBACK_PASS_ON;
546 * Called when a key up is received.
548 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
550 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
553 windowBase->OnKeyUp(data, type, event);
555 return ECORE_CALLBACK_PASS_ON;
558 /////////////////////////////////////////////////////////////////////////////////////////////////
559 // Selection Callbacks
560 /////////////////////////////////////////////////////////////////////////////////////////////////
563 * Called when the source window notifies us the content in clipboard is selected.
565 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
567 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
570 windowBase->OnDataSend(data, type, event);
572 return ECORE_CALLBACK_PASS_ON;
576 * Called when the source window sends us about the selected content.
577 * For example, when item is selected in the clipboard.
579 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
581 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
584 windowBase->OnDataReceive(data, type, event);
586 return ECORE_CALLBACK_PASS_ON;
589 /////////////////////////////////////////////////////////////////////////////////////////////////
590 // Effect Start/End Callbacks
591 /////////////////////////////////////////////////////////////////////////////////////////////////
594 * Called when transition animation of the window's shown/hidden is started by window manager.
596 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
598 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
599 Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
600 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
603 if(effectStart->type < 3) // only under restack
605 windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
608 return ECORE_CALLBACK_PASS_ON;
612 * Called when transition animation of the window's shown/hidden is ended by window manager.
614 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
616 Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
617 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
618 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
621 if(effectEnd->type < 3) // only under restack
623 windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
626 return ECORE_CALLBACK_PASS_ON;
629 /////////////////////////////////////////////////////////////////////////////////////////////////
630 // Keyboard Repeat Settings Changed Callbacks
631 /////////////////////////////////////////////////////////////////////////////////////////////////
633 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
635 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
636 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event)->id);
639 windowBase->OnKeyboardRepeatSettingsChanged();
642 return ECORE_CALLBACK_RENEW;
645 /////////////////////////////////////////////////////////////////////////////////////////////////
646 // Keymap Changed Callbacks
647 /////////////////////////////////////////////////////////////////////////////////////////////////
649 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
651 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
654 windowBase->KeymapChanged(data, type, event);
657 return ECORE_CALLBACK_RENEW;
660 /////////////////////////////////////////////////////////////////////////////////////////////////
662 /////////////////////////////////////////////////////////////////////////////////////////////////
664 #if defined(VCONF_ENABLED)
666 * Called when a font name is changed.
668 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
670 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
673 windowBase->OnFontNameChanged();
678 * Called when a font size is changed.
680 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
682 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
685 windowBase->OnFontSizeChanged();
690 /////////////////////////////////////////////////////////////////////////////////////////////////
691 // Window Redraw Request Event Callbacks
692 /////////////////////////////////////////////////////////////////////////////////////////////////
694 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
696 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
697 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event)->win);
700 windowBase->OnEcoreEventWindowRedrawRequest();
703 return ECORE_CALLBACK_RENEW;
706 /////////////////////////////////////////////////////////////////////////////////////////////////
707 // Window Auxiliary Message Callbacks
708 /////////////////////////////////////////////////////////////////////////////////////////////////
709 static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* event)
711 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
714 windowBase->OnEcoreEventWindowAuxiliaryMessage(event);
716 return ECORE_CALLBACK_RENEW;
719 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
721 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
724 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
728 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
730 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
733 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
737 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
741 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)
745 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
747 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
750 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
754 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
758 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
760 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
763 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
767 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
771 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
775 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
779 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
783 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)
787 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
789 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
792 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
796 const struct wl_registry_listener registryListener =
798 RegistryGlobalCallback,
799 RegistryGlobalCallbackRemove};
801 const struct tizen_policy_listener tizenPolicyListener =
803 TizenPolicyConformant,
804 TizenPolicyConformantArea,
805 TizenPolicyNotificationChangeDone,
806 TizenPolicyTransientForDone,
807 TizenPolicyScreenModeChangeDone,
808 TizenPolicyIconifyStateChanged,
809 TizenPolicySupportedAuxiliaryHints,
810 TizenPolicyAllowedAuxiliaryHint,
811 TizenPolicyAuxiliaryMessage,
812 TizenPolicyConformantRegion};
814 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
816 DisplayPolicyBrightnessChangeDone};
818 } // unnamed namespace
820 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
821 : mEcoreEventHandler(),
822 mEcoreWindow(nullptr),
824 mWlInputPanel(nullptr),
826 mWlInputPanelSurface(nullptr),
829 mEventQueue(nullptr),
830 mTizenPolicy(nullptr),
831 mTizenDisplayPolicy(nullptr),
833 mSupportedAuxiliaryHints(),
834 mWindowPositionSize(positionSize),
836 mType(WindowType::NORMAL),
837 mNotificationLevel(-1),
840 mWindowRotationAngle(0),
841 mScreenRotationAngle(0),
842 mSupportedPreProtation(0),
843 mNotificationChangeState(0),
844 mScreenOffModeChangeState(0),
845 mBrightnessChangeState(0),
846 mLastSubmittedMoveResizeSerial(0),
847 mMoveResizeSerial(0),
848 mNotificationLevelChangeDone(true),
849 mScreenOffModeChangeDone(true),
852 mBrightnessChangeDone(true)
854 Initialize(positionSize, surface, isTransparent);
857 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
859 #if defined(VCONF_ENABLED)
860 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
861 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
864 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
866 ecore_event_handler_del(*iter);
868 mEcoreEventHandler.Clear();
872 wl_event_queue_destroy(mEventQueue);
875 mSupportedAuxiliaryHints.clear();
876 mAuxiliaryHints.clear();
878 if(mEglWindow != NULL)
880 wl_egl_window_destroy(mEglWindow);
886 ecore_wl2_window_free(mEcoreWindow);
888 WindowSystem::Shutdown();
892 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
894 if(surface.Empty() == false)
896 // check we have a valid type
897 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
899 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
903 // we own the surface about to created
904 WindowSystem::Initialize();
907 CreateWindow(positionSize);
910 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
912 SetTransparency(isTransparent);
914 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
915 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
916 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
917 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
918 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
920 // Register Rotate event
921 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
923 // Register Configure event
924 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
926 // Register Touch events
927 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
928 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
929 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
930 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
932 // Register Mouse wheel events
933 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
935 // Register Mouse IO events
936 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
937 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
939 // Register Detent event
940 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
942 // Register Key events
943 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
944 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
946 // Register Selection event - clipboard selection
947 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
948 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
950 // Register Effect Start/End event
951 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
952 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
954 // Register Keyboard repeat event
955 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
957 // Register Window redraw request event
958 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
960 // Register Window auxiliary event
961 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
963 #if defined(VCONF_ENABLED)
964 // Register Vconf notify - font name and size
965 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
966 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
969 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
970 mDisplay = ecore_wl2_display_get(display);
974 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
977 mEventQueue = wl_display_create_queue(mDisplay);
980 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
982 wl_registry* registry = wl_display_get_registry(displayWrapper);
983 wl_registry_add_listener(registry, ®istryListener, this);
986 wl_proxy_wrapper_destroy(displayWrapper);
990 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
994 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
996 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
999 // get auxiliary hint
1000 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
1003 Eina_List* l = NULL;
1006 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))))
1008 mSupportedAuxiliaryHints.push_back(hint);
1010 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
1015 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
1017 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
1018 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
1020 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1022 if(iconifyChangedEvent->iconified == EINA_TRUE)
1024 mIconifyChangedSignal.Emit(true);
1028 mIconifyChangedSignal.Emit(false);
1030 handled = ECORE_CALLBACK_DONE;
1036 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
1038 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
1040 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1042 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
1044 mFocusChangedSignal.Emit(true);
1047 return ECORE_CALLBACK_PASS_ON;
1050 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
1052 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
1054 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1056 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
1058 mFocusChangedSignal.Emit(false);
1061 return ECORE_CALLBACK_PASS_ON;
1064 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
1066 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
1068 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
1070 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
1072 mScreenRotationAngle = GetScreenRotationAngle();
1074 mOutputTransformedSignal.Emit();
1077 return ECORE_CALLBACK_PASS_ON;
1080 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
1082 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
1084 if(ignoreTransformEvent->win == mEcoreWindow)
1086 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
1088 mScreenRotationAngle = GetScreenRotationAngle();
1090 mOutputTransformedSignal.Emit();
1093 return ECORE_CALLBACK_PASS_ON;
1096 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
1098 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
1100 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1102 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
1104 RotationEvent rotationEvent;
1105 rotationEvent.angle = ev->angle;
1106 rotationEvent.winResize = 0;
1108 if(ev->w == 0 || ev->h == 0)
1110 // When rotation event does not have the window width or height,
1111 // previous DALi side window's size are used.
1112 ev->w = mWindowPositionSize.width;
1113 ev->h = mWindowPositionSize.height;
1116 mWindowRotationAngle = ev->angle;
1118 mWindowPositionSize.width = ev->w;
1119 mWindowPositionSize.height = ev->h;
1121 PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1123 rotationEvent.x = newPositionSize.x;
1124 rotationEvent.y = newPositionSize.y;
1125 rotationEvent.width = newPositionSize.width;
1126 rotationEvent.height = newPositionSize.height;
1128 mRotationSignal.Emit(rotationEvent);
1132 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1134 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1136 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1138 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1139 // by calling ecore_wl2_window_commit
1141 int tempWidth = static_cast<int>(ev->w);
1142 int tempHeight = static_cast<int>(ev->h);
1144 // Initialize with previous size for skip resize when new size is 0.
1145 // When window is just moved or window is resized by client application,
1146 // The configure notification event's size will be 0.
1147 // If new size is 0, the resized work should be skip.
1148 int newWidth = mWindowPositionSize.width;
1149 int newHeight = mWindowPositionSize.height;
1150 bool windowMoved = false, windowResized = false;
1152 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1157 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1159 windowResized = true;
1160 newWidth = tempWidth;
1161 newHeight = tempHeight;
1164 if(windowMoved || windowResized)
1166 mWindowPositionSize.x = ev->x;
1167 mWindowPositionSize.y = ev->y;
1168 mWindowPositionSize.width = newWidth;
1169 mWindowPositionSize.height = newHeight;
1170 DALI_LOG_RELEASE_INFO("Update position & resize signal by server, current angle [%d] x[%d] y[%d] w[%d] h[%d]\n", mWindowRotationAngle, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1172 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1174 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1175 mUpdatePositionSizeSignal.Emit(newPositionSize);
1178 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1182 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1184 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1186 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1188 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
1190 Device::Class::Type deviceClass;
1191 Device::Subclass::Type deviceSubclass;
1193 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1194 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1196 PointState::Type state(PointState::DOWN);
1198 if(deviceClass != Device::Class::Type::MOUSE)
1200 // Check if the buttons field is set and ensure it's the primary touch button.
1201 // If this event was triggered by buttons other than the primary button (used for touch), then
1202 // just send an interrupted event to Core.
1203 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1205 state = PointState::INTERRUPTED;
1209 Integration::Point point;
1210 point.SetDeviceId(touchEvent->multi.device);
1211 point.SetState(state);
1212 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1213 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1214 point.SetPressure(touchEvent->multi.pressure);
1215 point.SetAngle(Degree(touchEvent->multi.angle));
1216 point.SetDeviceClass(deviceClass);
1217 point.SetDeviceSubclass(deviceSubclass);
1218 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1220 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1224 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1226 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1228 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1230 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
1232 Device::Class::Type deviceClass;
1233 Device::Subclass::Type deviceSubclass;
1235 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1236 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1238 Integration::Point point;
1239 point.SetDeviceId(touchEvent->multi.device);
1240 point.SetState(PointState::UP);
1241 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1242 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1243 point.SetPressure(touchEvent->multi.pressure);
1244 point.SetAngle(Degree(touchEvent->multi.angle));
1245 point.SetDeviceClass(deviceClass);
1246 point.SetDeviceSubclass(deviceSubclass);
1247 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1249 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1253 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1255 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1257 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1259 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
1261 Device::Class::Type deviceClass;
1262 Device::Subclass::Type deviceSubclass;
1264 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1265 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1267 Integration::Point point;
1268 point.SetDeviceId(touchEvent->multi.device);
1269 point.SetState(PointState::MOTION);
1270 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1271 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1272 point.SetPressure(touchEvent->multi.pressure);
1273 point.SetAngle(Degree(touchEvent->multi.angle));
1274 point.SetDeviceClass(deviceClass);
1275 point.SetDeviceSubclass(deviceSubclass);
1277 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1281 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1283 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1285 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1287 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
1289 Integration::Point point;
1290 point.SetDeviceId(touchEvent->multi.device);
1291 point.SetState(PointState::INTERRUPTED);
1292 point.SetScreenPosition(Vector2(0.0f, 0.0f));
1294 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1296 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1300 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1302 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1304 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1306 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
1308 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);
1310 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1312 mWheelEventSignal.Emit(wheelEvent);
1316 void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
1318 Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
1320 if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1322 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
1324 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);
1326 Device::Class::Type deviceClass;
1327 Device::Subclass::Type deviceSubclass;
1329 GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
1330 GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
1332 Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
1334 mMouseInOutEventSignal.Emit(inOutEvent);
1338 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1340 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1342 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1344 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1346 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1348 mWheelEventSignal.Emit(wheelEvent);
1351 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1353 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1355 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1357 std::string keyName(keyEvent->keyname);
1358 std::string logicalKey("");
1359 std::string keyString("");
1360 std::string compose("");
1362 DALI_TRACE_BEGIN(gTraceFilter, "DALI_ON_KEY_DOWN");
1364 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1365 if(keyEvent->compose)
1367 compose = keyEvent->compose;
1370 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1373 logicalKey = keyEvent->key;
1377 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1381 // Get a specific key code from dali key look up table.
1382 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1385 keyCode = (keyCode == -1) ? 0 : keyCode;
1386 int modifier(keyEvent->modifiers);
1387 unsigned long time = keyEvent->timestamp;
1388 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1390 keyCode = atoi(keyEvent->keyname + 8);
1393 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1394 if(keyEvent->string)
1396 keyString = keyEvent->string;
1399 std::string deviceName;
1400 Device::Class::Type deviceClass;
1401 Device::Subclass::Type deviceSubclass;
1403 GetDeviceName(keyEvent, deviceName);
1404 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1405 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1407 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1409 mKeyEventSignal.Emit(keyEvent);
1411 DALI_TRACE_END(gTraceFilter, "DALI_ON_KEY_DOWN");
1415 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1417 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1419 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1421 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1422 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1423 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1425 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1428 #endif // Since ecore 1.23 version
1430 std::string keyName(keyEvent->keyname);
1431 std::string logicalKey("");
1432 std::string keyString("");
1433 std::string compose("");
1435 DALI_TRACE_BEGIN(gTraceFilter, "DALI_ON_KEY_UP");
1437 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1438 if(keyEvent->compose)
1440 compose = keyEvent->compose;
1443 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1446 logicalKey = keyEvent->key;
1450 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1454 // Get a specific key code from dali key look up table.
1455 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1458 keyCode = (keyCode == -1) ? 0 : keyCode;
1459 int modifier(keyEvent->modifiers);
1460 unsigned long time = keyEvent->timestamp;
1461 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1463 keyCode = atoi(keyEvent->keyname + 8);
1466 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1467 if(keyEvent->string)
1469 keyString = keyEvent->string;
1472 std::string deviceName;
1473 Device::Class::Type deviceClass;
1474 Device::Subclass::Type deviceSubclass;
1476 GetDeviceName(keyEvent, deviceName);
1477 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1478 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1480 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1482 mKeyEventSignal.Emit(keyEvent);
1484 DALI_TRACE_END(gTraceFilter, "DALI_ON_KEY_UP");
1488 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1490 mSelectionDataSendSignal.Emit(event);
1493 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1495 mSelectionDataReceivedSignal.Emit(event);
1498 void WindowBaseEcoreWl2::OnFontNameChanged()
1500 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1503 void WindowBaseEcoreWl2::OnFontSizeChanged()
1505 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1508 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1510 mTransitionEffectEventSignal.Emit(state, type);
1513 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1515 mKeyboardRepeatSettingsChangedSignal.Emit();
1518 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1520 mWindowRedrawRequestSignal.Emit();
1523 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1525 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1528 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
1529 std::string key(message->key);
1530 std::string value(message->val);
1531 Dali::Property::Array options;
1533 if(message->options)
1537 EINA_LIST_FOREACH(message->options, l, data)
1539 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
1540 std::string option(static_cast<char*>(data));
1541 options.Add(option);
1545 mAuxiliaryMessageSignal.Emit(key, value, options);
1549 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1551 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1552 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1553 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1556 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1560 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1562 if(strcmp(interface, tizen_policy_interface.name) == 0)
1564 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1566 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1569 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1573 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1575 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1577 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1579 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1580 if(!mTizenDisplayPolicy)
1582 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1586 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1588 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1592 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1594 mTizenPolicy = NULL;
1595 mTizenDisplayPolicy = NULL;
1598 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1600 mNotificationLevel = level;
1601 mNotificationChangeState = state;
1602 mNotificationLevelChangeDone = true;
1604 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1607 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1609 mScreenOffMode = mode;
1610 mScreenOffModeChangeState = state;
1611 mScreenOffModeChangeDone = true;
1613 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1616 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1618 mBrightness = brightness;
1619 mBrightnessChangeState = state;
1620 mBrightnessChangeDone = true;
1622 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1625 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1627 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1628 KeyCodeMap foundKeyCode;
1630 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1631 if(sym == XKB_KEY_NoSymbol)
1633 DALI_LOG_ERROR("Failed to get keysym in WindowBaseEcoreWl2\n");
1637 foundKeyCode.keySym = sym;
1638 foundKeyCode.isKeyCode = false;
1639 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1640 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1643 Any WindowBaseEcoreWl2::GetNativeWindow()
1645 return mEcoreWindow;
1648 int WindowBaseEcoreWl2::GetNativeWindowId()
1650 return ecore_wl2_window_id_get(mEcoreWindow);
1653 std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
1655 #ifdef OVER_TIZEN_VERSION_7
1656 return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
1658 return std::string();
1662 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1664 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1666 START_DURATION_CHECK();
1667 if(totalAngle == 90 || totalAngle == 270)
1669 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
1673 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1675 FINISH_DURATION_CHECK("wl_egl_window_create");
1677 return static_cast<EGLNativeWindowType>(mEglWindow);
1680 void WindowBaseEcoreWl2::DestroyEglWindow()
1682 if(mEglWindow != NULL)
1684 START_DURATION_CHECK();
1685 wl_egl_window_destroy(mEglWindow);
1686 FINISH_DURATION_CHECK("wl_egl_window_destroy");
1692 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
1694 wl_egl_window_tizen_rotation rotation;
1700 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1705 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1710 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1715 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1720 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1725 START_DURATION_CHECK();
1726 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
1727 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_rotation");
1730 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
1732 wl_output_transform bufferTransform;
1738 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1743 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1748 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1753 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1758 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1763 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_buffer_transform() with buffer Transform [%d]\n", bufferTransform);
1764 START_DURATION_CHECK();
1765 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
1766 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_buffer_transform");
1769 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
1771 wl_output_transform windowTransform;
1777 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1782 windowTransform = WL_OUTPUT_TRANSFORM_90;
1787 windowTransform = WL_OUTPUT_TRANSFORM_180;
1792 windowTransform = WL_OUTPUT_TRANSFORM_270;
1797 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1802 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_window_transform() with window Transform [%d]\n", windowTransform);
1803 START_DURATION_CHECK();
1804 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
1805 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_window_transform");
1808 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
1810 DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1811 START_DURATION_CHECK();
1812 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1814 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1815 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
1817 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
1818 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1820 FINISH_DURATION_CHECK("wl_egl_window functions");
1823 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1825 START_DURATION_CHECK();
1827 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
1828 FINISH_DURATION_CHECK("wl_egl_window_tizen_get_capabilities");
1830 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
1832 mSupportedPreProtation = true;
1835 mSupportedPreProtation = false;
1839 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
1841 PositionSize newPositionSize;
1842 int32_t screenWidth, screenHeight;
1843 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1845 if(mWindowRotationAngle == 90)
1847 newPositionSize.x = positionSize.y;
1848 newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
1849 newPositionSize.width = positionSize.height;
1850 newPositionSize.height = positionSize.width;
1852 else if(mWindowRotationAngle == 180)
1854 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1855 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1856 newPositionSize.width = positionSize.width;
1857 newPositionSize.height = positionSize.height;
1859 else if(mWindowRotationAngle == 270)
1861 newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
1862 newPositionSize.y = positionSize.x;
1863 newPositionSize.width = positionSize.height;
1864 newPositionSize.height = positionSize.width;
1868 newPositionSize.x = positionSize.x;
1869 newPositionSize.y = positionSize.y;
1870 newPositionSize.width = positionSize.width;
1871 newPositionSize.height = positionSize.height;
1874 return newPositionSize;
1877 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
1879 PositionSize newPositionSize;
1880 int32_t screenWidth, screenHeight;
1881 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1883 if(mWindowRotationAngle == 90)
1885 newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
1886 newPositionSize.y = positionSize.x;
1887 newPositionSize.width = positionSize.height;
1888 newPositionSize.height = positionSize.width;
1890 else if(mWindowRotationAngle == 180)
1892 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1893 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1894 newPositionSize.width = positionSize.width;
1895 newPositionSize.height = positionSize.height;
1897 else if(mWindowRotationAngle == 270)
1899 newPositionSize.x = positionSize.y;
1900 newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
1901 newPositionSize.width = positionSize.height;
1902 newPositionSize.height = positionSize.width;
1906 newPositionSize.x = positionSize.x;
1907 newPositionSize.y = positionSize.y;
1908 newPositionSize.width = positionSize.width;
1909 newPositionSize.height = positionSize.height;
1912 return newPositionSize;
1915 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
1917 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1919 mWindowPositionSize = newPositionSize;
1920 DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
1921 START_DURATION_CHECK();
1922 ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
1923 FINISH_DURATION_CHECK("ecore_wl2_window_position_set");
1926 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
1928 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1930 mWindowPositionSize = newPositionSize;
1931 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);
1932 START_DURATION_CHECK();
1933 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1934 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
1937 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
1939 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1941 mWindowPositionSize = newPositionSize;
1942 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);
1943 START_DURATION_CHECK();
1944 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1945 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
1948 void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
1950 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);
1951 START_DURATION_CHECK();
1952 ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
1953 FINISH_DURATION_CHECK("ecore_wl2_window_layout_set");
1956 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
1958 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
1959 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
1962 void WindowBaseEcoreWl2::Raise()
1964 START_DURATION_CHECK();
1965 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1966 ecore_wl2_window_activate(mEcoreWindow);
1967 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
1970 void WindowBaseEcoreWl2::Lower()
1972 START_DURATION_CHECK();
1973 ecore_wl2_window_lower(mEcoreWindow);
1974 FINISH_DURATION_CHECK("ecore_wl2_window_lower");
1977 void WindowBaseEcoreWl2::Activate()
1979 START_DURATION_CHECK();
1980 ecore_wl2_window_activate(mEcoreWindow);
1981 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
1984 void WindowBaseEcoreWl2::Maximize(bool maximize)
1986 START_DURATION_CHECK();
1987 ecore_wl2_window_maximized_set(mEcoreWindow, maximize);
1988 FINISH_DURATION_CHECK("ecore_wl2_window_maximized_set");
1991 bool WindowBaseEcoreWl2::IsMaximized() const
1993 return ecore_wl2_window_maximized_get(mEcoreWindow);
1996 void WindowBaseEcoreWl2::SetMaximumSize(Dali::Window::WindowSize size)
1998 DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
1999 START_DURATION_CHECK();
2000 ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2001 FINISH_DURATION_CHECK("ecore_wl2_window_maximum_size_set");
2002 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2005 void WindowBaseEcoreWl2::Minimize(bool minimize)
2007 START_DURATION_CHECK();
2008 ecore_wl2_window_iconified_set(mEcoreWindow, minimize);
2009 FINISH_DURATION_CHECK("ecore_wl2_window_iconified_set");
2012 bool WindowBaseEcoreWl2::IsMinimized() const
2014 return ecore_wl2_window_iconified_get(mEcoreWindow);
2017 void WindowBaseEcoreWl2::SetMimimumSize(Dali::Window::WindowSize size)
2019 DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2020 START_DURATION_CHECK();
2021 ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2022 FINISH_DURATION_CHECK("ecore_wl2_window_minimum_size_set");
2023 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2026 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
2028 int rotations[4] = {0};
2029 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
2030 for(std::size_t i = 0; i < angles.size(); ++i)
2032 rotations[i] = static_cast<int>(angles[i]);
2033 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
2036 START_DURATION_CHECK();
2037 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
2038 FINISH_DURATION_CHECK("ecore_wl2_window_available_rotations_set");
2041 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
2043 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
2044 START_DURATION_CHECK();
2045 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
2046 FINISH_DURATION_CHECK("ecore_wl2_window_preferred_rotation_set");
2049 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
2051 START_DURATION_CHECK();
2052 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
2053 FINISH_DURATION_CHECK("ecore_wl2_window_focus_skip_set");
2056 void WindowBaseEcoreWl2::Show()
2060 START_DURATION_CHECK();
2061 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
2062 FINISH_DURATION_CHECK("ecore_wl2_window_geometry_set");
2066 ecore_wl2_window_show(mEcoreWindow);
2069 void WindowBaseEcoreWl2::Hide()
2072 ecore_wl2_window_hide(mEcoreWindow);
2075 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
2077 return mSupportedAuxiliaryHints.size();
2080 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
2082 if(index >= GetSupportedAuxiliaryHintCount())
2084 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
2087 return mSupportedAuxiliaryHints[index];
2090 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
2092 bool supported = false;
2094 // Check if the hint is suppported
2095 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
2106 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
2110 // Check if the hint is already added
2111 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2113 if(mAuxiliaryHints[i].first == hint)
2115 // Just change the value
2116 mAuxiliaryHints[i].second = value;
2118 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
2120 return i + 1; // id is index + 1
2125 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
2127 unsigned int id = mAuxiliaryHints.size();
2129 START_DURATION_CHECK();
2130 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
2131 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_add");
2133 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
2138 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
2140 if(id == 0 || id > mAuxiliaryHints.size())
2142 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
2146 mAuxiliaryHints[id - 1].second = std::string();
2148 START_DURATION_CHECK();
2149 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
2150 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_del");
2152 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
2157 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
2159 if(id == 0 || id > mAuxiliaryHints.size())
2161 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
2165 mAuxiliaryHints[id - 1].second = value;
2167 START_DURATION_CHECK();
2168 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
2169 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_change");
2171 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());
2176 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
2178 if(id == 0 || id > mAuxiliaryHints.size())
2180 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
2181 return std::string();
2184 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());
2186 return mAuxiliaryHints[id - 1].second;
2189 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
2191 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2193 if(mAuxiliaryHints[i].first == hint)
2195 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
2200 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
2205 Rect<int> WindowBaseEcoreWl2::RecalculateInputRect(const Rect<int>& rect)
2209 if(mWindowRotationAngle == 90)
2212 newRect.y = mWindowPositionSize.height - (rect.x + rect.width);
2213 newRect.width = rect.height;
2214 newRect.height = rect.width;
2216 else if(mWindowRotationAngle == 180)
2218 newRect.x = mWindowPositionSize.width - (rect.x + rect.width);
2219 newRect.y = mWindowPositionSize.height - (rect.y + rect.height);
2220 newRect.width = rect.width;
2221 newRect.height = rect.height;
2223 else if(mWindowRotationAngle == 270)
2225 newRect.x = mWindowPositionSize.width - (rect.y + rect.height);
2227 newRect.width = rect.height;
2228 newRect.height = rect.width;
2234 newRect.width = rect.width;
2235 newRect.height = rect.height;
2240 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
2242 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
2244 Eina_Rectangle rect;
2245 rect.x = convertRegion.x;
2246 rect.y = convertRegion.y;
2247 rect.w = convertRegion.width;
2248 rect.h = convertRegion.height;
2250 DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2251 START_DURATION_CHECK();
2252 ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
2253 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_set");
2254 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2257 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
2262 Ecore_Wl2_Window_Type windowType;
2266 case Dali::WindowType::NORMAL:
2268 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2271 case Dali::WindowType::NOTIFICATION:
2273 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
2276 case Dali::WindowType::UTILITY:
2278 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
2281 case Dali::WindowType::DIALOG:
2283 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
2286 case Dali::WindowType::IME:
2288 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
2291 case Dali::WindowType::DESKTOP:
2293 windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
2298 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2303 START_DURATION_CHECK();
2304 ecore_wl2_window_type_set(mEcoreWindow, windowType);
2305 FINISH_DURATION_CHECK("ecore_wl2_window_type_set");
2309 Dali::WindowType WindowBaseEcoreWl2::GetType() const
2314 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
2316 START_DURATION_CHECK();
2317 while(!mTizenPolicy)
2319 wl_display_dispatch_queue(mDisplay, mEventQueue);
2322 int notificationLevel;
2326 case Dali::WindowNotificationLevel::NONE:
2328 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
2331 case Dali::WindowNotificationLevel::BASE:
2333 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2336 case Dali::WindowNotificationLevel::MEDIUM:
2338 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
2341 case Dali::WindowNotificationLevel::HIGH:
2343 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
2346 case Dali::WindowNotificationLevel::TOP:
2348 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
2353 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
2354 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2359 mNotificationLevelChangeDone = false;
2360 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2362 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2366 while(!mNotificationLevelChangeDone && count < 3)
2368 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2369 wl_display_dispatch_queue(mDisplay, mEventQueue);
2372 FINISH_DURATION_CHECK("ecore_wl2 & wl_display");
2374 if(!mNotificationLevelChangeDone)
2376 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2377 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2379 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2381 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2382 return Dali::WindowOperationResult::PERMISSION_DENIED;
2385 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2387 return Dali::WindowOperationResult::SUCCEED;
2390 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2392 while(!mTizenPolicy)
2394 wl_display_dispatch_queue(mDisplay, mEventQueue);
2399 while(!mNotificationLevelChangeDone && count < 3)
2401 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2402 wl_display_dispatch_queue(mDisplay, mEventQueue);
2406 if(!mNotificationLevelChangeDone)
2408 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2409 return Dali::WindowNotificationLevel::NONE;
2412 Dali::WindowNotificationLevel level;
2414 switch(mNotificationLevel)
2416 case TIZEN_POLICY_LEVEL_NONE:
2418 level = Dali::WindowNotificationLevel::NONE;
2421 case TIZEN_POLICY_LEVEL_DEFAULT:
2423 level = Dali::WindowNotificationLevel::BASE;
2426 case TIZEN_POLICY_LEVEL_MEDIUM:
2428 level = Dali::WindowNotificationLevel::MEDIUM;
2431 case TIZEN_POLICY_LEVEL_HIGH:
2433 level = Dali::WindowNotificationLevel::HIGH;
2436 case TIZEN_POLICY_LEVEL_TOP:
2438 level = Dali::WindowNotificationLevel::TOP;
2443 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2444 level = Dali::WindowNotificationLevel::NONE;
2449 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2454 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2456 while(!mTizenPolicy)
2458 wl_display_dispatch_queue(mDisplay, mEventQueue);
2461 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2464 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2466 while(!mTizenPolicy)
2468 wl_display_dispatch_queue(mDisplay, mEventQueue);
2471 mScreenOffModeChangeDone = false;
2472 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2474 unsigned int mode = 0;
2476 switch(screenOffMode)
2478 case WindowScreenOffMode::TIMEOUT:
2483 case WindowScreenOffMode::NEVER:
2490 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2494 while(!mScreenOffModeChangeDone && count < 3)
2496 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2497 wl_display_dispatch_queue(mDisplay, mEventQueue);
2501 if(!mScreenOffModeChangeDone)
2503 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2504 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2506 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2508 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2509 return Dali::WindowOperationResult::PERMISSION_DENIED;
2512 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2514 return Dali::WindowOperationResult::SUCCEED;
2517 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2519 while(!mTizenPolicy)
2521 wl_display_dispatch_queue(mDisplay, mEventQueue);
2526 while(!mScreenOffModeChangeDone && count < 3)
2528 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2529 wl_display_dispatch_queue(mDisplay, mEventQueue);
2533 if(!mScreenOffModeChangeDone)
2535 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2536 return WindowScreenOffMode::TIMEOUT;
2539 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2541 switch(mScreenOffMode)
2545 screenMode = WindowScreenOffMode::TIMEOUT;
2550 screenMode = WindowScreenOffMode::NEVER;
2555 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2560 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2562 START_DURATION_CHECK();
2563 while(!mTizenDisplayPolicy)
2565 wl_display_dispatch_queue(mDisplay, mEventQueue);
2568 mBrightnessChangeDone = false;
2569 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2571 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2575 while(!mBrightnessChangeDone && count < 3)
2577 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2578 wl_display_dispatch_queue(mDisplay, mEventQueue);
2581 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2583 if(!mBrightnessChangeDone)
2585 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2586 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2588 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2590 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2591 return Dali::WindowOperationResult::PERMISSION_DENIED;
2594 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2596 return Dali::WindowOperationResult::SUCCEED;
2599 int WindowBaseEcoreWl2::GetBrightness() const
2601 START_DURATION_CHECK();
2602 while(!mTizenDisplayPolicy)
2604 wl_display_dispatch_queue(mDisplay, mEventQueue);
2609 while(!mBrightnessChangeDone && count < 3)
2611 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2612 wl_display_dispatch_queue(mDisplay, mEventQueue);
2615 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2617 if(!mBrightnessChangeDone)
2619 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2623 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2628 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2630 Ecore_Wl2_Window_Keygrab_Mode mode;
2634 case KeyGrab::TOPMOST:
2636 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2639 case KeyGrab::SHARED:
2641 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2644 case KeyGrab::OVERRIDE_EXCLUSIVE:
2646 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2649 case KeyGrab::EXCLUSIVE:
2651 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2660 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2663 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2665 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2668 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2670 int keyCount = key.Count();
2671 int keyGrabModeCount = grabMode.Count();
2673 if(keyCount != keyGrabModeCount || keyCount == 0)
2680 Eina_List* keyList = NULL;
2681 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2683 for(int index = 0; index < keyCount; ++index)
2685 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2687 switch(grabMode[index])
2689 case KeyGrab::TOPMOST:
2691 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2694 case KeyGrab::SHARED:
2696 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2699 case KeyGrab::OVERRIDE_EXCLUSIVE:
2701 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2704 case KeyGrab::EXCLUSIVE:
2706 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2711 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2716 keyList = eina_list_append(keyList, &info);
2719 START_DURATION_CHECK();
2720 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
2721 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_set");
2723 result.Resize(keyCount, true);
2725 Eina_List* l = NULL;
2726 Eina_List* m = NULL;
2727 void* listData = NULL;
2729 if(grabList != NULL)
2731 EINA_LIST_FOREACH(grabList, m, data)
2734 EINA_LIST_FOREACH(keyList, l, listData)
2736 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
2738 DALI_LOG_ERROR("input key list has null data!");
2742 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2744 result[index] = false;
2753 eina_list_free(keyList);
2754 eina_list_free(grabList);
2760 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
2762 int keyCount = key.Count();
2770 Eina_List* keyList = NULL;
2771 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2773 for(int index = 0; index < keyCount; ++index)
2775 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2776 keyList = eina_list_append(keyList, &info);
2779 START_DURATION_CHECK();
2780 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
2781 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_unset");
2783 result.Resize(keyCount, true);
2785 Eina_List* l = NULL;
2786 Eina_List* m = NULL;
2787 void* listData = NULL;
2790 if(ungrabList != NULL)
2792 EINA_LIST_FOREACH(ungrabList, m, data)
2795 EINA_LIST_FOREACH(keyList, l, listData)
2797 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2799 result[index] = false;
2808 eina_list_free(keyList);
2809 eina_list_free(ungrabList);
2815 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2820 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
2822 // 1 inch = 25.4 millimeters
2823 xres = ecore_wl2_output_dpi_get(output);
2824 yres = ecore_wl2_output_dpi_get(output);
2826 dpiHorizontal = int(xres + 0.5f); // rounding
2827 dpiVertical = int(yres + 0.5f);
2830 int WindowBaseEcoreWl2::GetWindowRotationAngle() const
2832 int orientation = mWindowRotationAngle;
2833 if(mSupportedPreProtation)
2840 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2842 if(mSupportedPreProtation)
2844 DALI_LOG_RELEASE_INFO("Support PreRotation and return 0\n");
2848 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
2854 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
2856 mScreenRotationAngle = transform * 90;
2857 return mScreenRotationAngle;
2860 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
2862 mWindowRotationAngle = degree;
2863 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
2866 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
2868 START_DURATION_CHECK();
2869 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
2870 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_change_done_send");
2873 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
2875 START_DURATION_CHECK();
2876 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
2877 FINISH_DURATION_CHECK("ecore_wl2_window_alpha_set");
2880 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
2882 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
2885 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
2888 START_DURATION_CHECK();
2889 ecore_wl2_display_sync(display);
2891 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2893 if(mEcoreWindow == 0)
2895 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2899 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
2900 FINISH_DURATION_CHECK("ecore_wl2 functions");
2903 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
2905 Ecore_Wl2_Window* ecoreParent = NULL;
2908 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
2909 ecoreParent = winBaseEcore2->mEcoreWindow;
2912 START_DURATION_CHECK();
2913 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
2914 FINISH_DURATION_CHECK("ecore_wl2_window_transient_parent_set");
2917 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2919 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
2922 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2924 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
2927 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2929 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);
2930 START_DURATION_CHECK();
2931 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2932 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_geometry_set");
2935 void WindowBaseEcoreWl2::InitializeIme()
2937 Eina_Iterator* globals;
2938 struct wl_registry* registry;
2939 Ecore_Wl2_Global* global;
2940 Ecore_Wl2_Display* ecoreWl2Display;
2942 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
2944 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
2948 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p\n", ecoreWl2Display, mEcoreWindow);
2950 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
2952 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
2956 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
2958 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
2962 START_DURATION_CHECK();
2963 EINA_ITERATOR_FOREACH(globals, global)
2965 #ifdef OVER_TIZEN_VERSION_7
2966 if(strcmp(global->interface, "zwp_input_panel_v1") == 0)
2968 mWlInputPanel = (zwp_input_panel_v1*)wl_registry_bind(registry, global->id, &zwp_input_panel_v1_interface, 1);
2971 if(strcmp(global->interface, "wl_input_panel") == 0)
2973 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
2976 else if(strcmp(global->interface, "wl_output") == 0)
2978 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
2984 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
2990 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
2993 #ifdef OVER_TIZEN_VERSION_7
2994 mWlInputPanelSurface = zwp_input_panel_v1_get_input_panel_surface(mWlInputPanel, mWlSurface);
2996 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
2998 if(!mWlInputPanelSurface)
3000 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
3003 #ifdef OVER_TIZEN_VERSION_7
3004 zwp_input_panel_surface_v1_set_toplevel(mWlInputPanelSurface, mWlOutput, ZWP_INPUT_PANEL_SURFACE_V1_POSITION_CENTER_BOTTOM);
3006 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
3008 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_toplevel");
3011 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
3013 if(!mWlInputPanelSurface)
3015 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
3019 START_DURATION_CHECK();
3020 #ifdef OVER_TIZEN_VERSION_7
3021 zwp_input_panel_surface_v1_set_ready(mWlInputPanelSurface, 1);
3023 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
3025 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_ready");
3028 void WindowBaseEcoreWl2::RequestMoveToServer()
3030 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3033 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
3037 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3040 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
3044 START_DURATION_CHECK();
3045 ecore_wl2_window_move(mEcoreWindow, input);
3046 FINISH_DURATION_CHECK("ecore_wl2_window_move");
3047 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
3050 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
3052 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3055 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
3059 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3062 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
3066 ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
3068 START_DURATION_CHECK();
3069 ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
3070 FINISH_DURATION_CHECK("ecore_wl2_window_resize");
3071 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);
3074 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
3076 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
3077 START_DURATION_CHECK();
3080 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
3084 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
3086 FINISH_DURATION_CHECK("ecore_wl2_window_floating_mode_set");
3089 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
3091 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
3094 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
3096 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
3097 Eina_Rectangle rect;
3099 rect.x = convertRegion.x;
3100 rect.y = convertRegion.y;
3101 rect.w = convertRegion.width;
3102 rect.h = convertRegion.height;
3104 DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3105 START_DURATION_CHECK();
3106 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
3107 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_add");
3108 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3111 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
3113 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
3114 Eina_Rectangle rect;
3116 rect.x = convertRegion.x;
3117 rect.y = convertRegion.y;
3118 rect.w = convertRegion.width;
3119 rect.h = convertRegion.height;
3121 DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3122 START_DURATION_CHECK();
3123 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
3124 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_subtract");
3125 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3128 } // namespace Adaptor
3130 } // namespace Internal
3134 #pragma GCC diagnostic pop