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);
890 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
892 if(surface.Empty() == false)
894 // check we have a valid type
895 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
897 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
901 // we own the surface about to created
903 CreateWindow(positionSize);
906 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
908 SetTransparency(isTransparent);
910 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
911 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
912 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
913 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
914 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
916 // Register Rotate event
917 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
919 // Register Configure event
920 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
922 // Register Touch events
923 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
924 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
925 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
926 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
928 // Register Mouse wheel events
929 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
931 // Register Mouse IO events
932 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
933 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
935 // Register Detent event
936 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
938 // Register Key events
939 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
940 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
942 // Register Selection event - clipboard selection
943 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
944 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
946 // Register Effect Start/End event
947 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
948 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
950 // Register Keyboard repeat event
951 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
953 // Register Window redraw request event
954 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
956 // Register Window auxiliary event
957 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
959 #if defined(VCONF_ENABLED)
960 // Register Vconf notify - font name and size
961 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
962 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
965 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
966 mDisplay = ecore_wl2_display_get(display);
970 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
973 mEventQueue = wl_display_create_queue(mDisplay);
976 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
978 wl_registry* registry = wl_display_get_registry(displayWrapper);
979 wl_registry_add_listener(registry, ®istryListener, this);
982 wl_proxy_wrapper_destroy(displayWrapper);
986 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
990 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
992 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
995 // get auxiliary hint
996 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
1002 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))))
1004 mSupportedAuxiliaryHints.push_back(hint);
1006 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
1011 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
1013 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
1014 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
1016 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1018 if(iconifyChangedEvent->iconified == EINA_TRUE)
1020 mIconifyChangedSignal.Emit(true);
1024 mIconifyChangedSignal.Emit(false);
1026 handled = ECORE_CALLBACK_DONE;
1032 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
1034 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
1036 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1038 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
1040 mFocusChangedSignal.Emit(true);
1043 return ECORE_CALLBACK_PASS_ON;
1046 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
1048 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
1050 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1052 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
1054 mFocusChangedSignal.Emit(false);
1057 return ECORE_CALLBACK_PASS_ON;
1060 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
1062 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
1064 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
1066 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
1068 mScreenRotationAngle = GetScreenRotationAngle();
1070 mOutputTransformedSignal.Emit();
1073 return ECORE_CALLBACK_PASS_ON;
1076 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
1078 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
1080 if(ignoreTransformEvent->win == mEcoreWindow)
1082 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
1084 mScreenRotationAngle = GetScreenRotationAngle();
1086 mOutputTransformedSignal.Emit();
1089 return ECORE_CALLBACK_PASS_ON;
1092 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
1094 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
1096 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1098 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
1100 RotationEvent rotationEvent;
1101 rotationEvent.angle = ev->angle;
1102 rotationEvent.winResize = 0;
1104 if(ev->w == 0 || ev->h == 0)
1106 // When rotation event does not have the window width or height,
1107 // previous DALi side window's size are used.
1108 ev->w = mWindowPositionSize.width;
1109 ev->h = mWindowPositionSize.height;
1112 mWindowRotationAngle = ev->angle;
1114 mWindowPositionSize.width = ev->w;
1115 mWindowPositionSize.height = ev->h;
1117 PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1119 rotationEvent.x = newPositionSize.x;
1120 rotationEvent.y = newPositionSize.y;
1121 rotationEvent.width = newPositionSize.width;
1122 rotationEvent.height = newPositionSize.height;
1124 mRotationSignal.Emit(rotationEvent);
1128 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1130 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1132 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1134 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1135 // by calling ecore_wl2_window_commit
1137 int tempWidth = ev->w;
1138 int tempHeight = ev->h;
1140 // Initialize with previous size for skip resize when new size is 0.
1141 // When window is just moved or window is resized by client application,
1142 // The configure notification event's size will be 0.
1143 // If new size is 0, the resized work should be skip.
1144 int newWidth = mWindowPositionSize.width;
1145 int newHeight = mWindowPositionSize.height;
1146 bool windowMoved = false, windowResized = false;
1148 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1153 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1155 windowResized = true;
1156 newWidth = tempWidth;
1157 newHeight = tempHeight;
1160 if(windowMoved || windowResized)
1162 mWindowPositionSize.x = ev->x;
1163 mWindowPositionSize.y = ev->y;
1164 mWindowPositionSize.width = newWidth;
1165 mWindowPositionSize.height = newHeight;
1166 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);
1168 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1170 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1171 mUpdatePositionSizeSignal.Emit(newPositionSize);
1174 mMaximizeChangedSignal.Emit(static_cast<bool>(ev->states & ECORE_WL2_WINDOW_STATE_MAXIMIZED));
1176 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1180 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1182 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1184 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1186 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
1188 Device::Class::Type deviceClass;
1189 Device::Subclass::Type deviceSubclass;
1191 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1192 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1194 PointState::Type state(PointState::DOWN);
1196 if(deviceClass != Device::Class::Type::MOUSE)
1198 // Check if the buttons field is set and ensure it's the primary touch button.
1199 // If this event was triggered by buttons other than the primary button (used for touch), then
1200 // just send an interrupted event to Core.
1201 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1203 state = PointState::INTERRUPTED;
1207 Integration::Point point;
1208 point.SetDeviceId(touchEvent->multi.device);
1209 point.SetState(state);
1210 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1211 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1212 point.SetPressure(touchEvent->multi.pressure);
1213 point.SetAngle(Degree(touchEvent->multi.angle));
1214 point.SetDeviceClass(deviceClass);
1215 point.SetDeviceSubclass(deviceSubclass);
1216 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1218 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1222 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1224 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1226 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1228 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
1230 Device::Class::Type deviceClass;
1231 Device::Subclass::Type deviceSubclass;
1233 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1234 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1236 Integration::Point point;
1237 point.SetDeviceId(touchEvent->multi.device);
1238 point.SetState(PointState::UP);
1239 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1240 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1241 point.SetPressure(touchEvent->multi.pressure);
1242 point.SetAngle(Degree(touchEvent->multi.angle));
1243 point.SetDeviceClass(deviceClass);
1244 point.SetDeviceSubclass(deviceSubclass);
1245 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1247 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1251 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1253 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1255 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1257 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
1259 Device::Class::Type deviceClass;
1260 Device::Subclass::Type deviceSubclass;
1262 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1263 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1265 Integration::Point point;
1266 point.SetDeviceId(touchEvent->multi.device);
1267 point.SetState(PointState::MOTION);
1268 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1269 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1270 point.SetPressure(touchEvent->multi.pressure);
1271 point.SetAngle(Degree(touchEvent->multi.angle));
1272 point.SetDeviceClass(deviceClass);
1273 point.SetDeviceSubclass(deviceSubclass);
1275 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1279 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1281 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1283 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1285 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
1287 Integration::Point point;
1288 point.SetDeviceId(touchEvent->multi.device);
1289 point.SetState(PointState::INTERRUPTED);
1290 point.SetScreenPosition(Vector2(0.0f, 0.0f));
1292 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1294 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1298 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1300 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1302 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1304 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
1306 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);
1308 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1310 mWheelEventSignal.Emit(wheelEvent);
1314 void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
1316 Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
1318 if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1320 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
1322 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);
1324 Device::Class::Type deviceClass;
1325 Device::Subclass::Type deviceSubclass;
1327 GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
1328 GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
1330 Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
1332 mMouseInOutEventSignal.Emit(inOutEvent);
1336 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1338 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1340 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1342 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1344 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1346 mWheelEventSignal.Emit(wheelEvent);
1349 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1351 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1353 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1355 std::string keyName(keyEvent->keyname);
1356 std::string logicalKey("");
1357 std::string keyString("");
1358 std::string compose("");
1360 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_DOWN");
1362 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1363 if(keyEvent->compose)
1365 compose = keyEvent->compose;
1368 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1371 logicalKey = keyEvent->key;
1375 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1379 // Get a specific key code from dali key look up table.
1380 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1383 keyCode = (keyCode == -1) ? 0 : keyCode;
1384 int modifier(keyEvent->modifiers);
1385 unsigned long time = keyEvent->timestamp;
1386 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1388 keyCode = atoi(keyEvent->keyname + 8);
1391 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1392 if(keyEvent->string)
1394 keyString = keyEvent->string;
1397 std::string deviceName;
1398 Device::Class::Type deviceClass;
1399 Device::Subclass::Type deviceSubclass;
1401 GetDeviceName(keyEvent, deviceName);
1402 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1403 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1405 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1407 mKeyEventSignal.Emit(keyEvent);
1411 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1413 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1415 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1417 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1418 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1419 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1421 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1424 #endif // Since ecore 1.23 version
1426 std::string keyName(keyEvent->keyname);
1427 std::string logicalKey("");
1428 std::string keyString("");
1429 std::string compose("");
1431 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_UP");
1433 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1434 if(keyEvent->compose)
1436 compose = keyEvent->compose;
1439 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1442 logicalKey = keyEvent->key;
1446 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1450 // Get a specific key code from dali key look up table.
1451 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1454 keyCode = (keyCode == -1) ? 0 : keyCode;
1455 int modifier(keyEvent->modifiers);
1456 unsigned long time = keyEvent->timestamp;
1457 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1459 keyCode = atoi(keyEvent->keyname + 8);
1462 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1463 if(keyEvent->string)
1465 keyString = keyEvent->string;
1468 std::string deviceName;
1469 Device::Class::Type deviceClass;
1470 Device::Subclass::Type deviceSubclass;
1472 GetDeviceName(keyEvent, deviceName);
1473 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1474 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1476 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1478 mKeyEventSignal.Emit(keyEvent);
1482 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1484 mSelectionDataSendSignal.Emit(event);
1487 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1489 mSelectionDataReceivedSignal.Emit(event);
1492 void WindowBaseEcoreWl2::OnFontNameChanged()
1494 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1497 void WindowBaseEcoreWl2::OnFontSizeChanged()
1499 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1502 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1504 mTransitionEffectEventSignal.Emit(state, type);
1507 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1509 mKeyboardRepeatSettingsChangedSignal.Emit();
1512 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1514 mWindowRedrawRequestSignal.Emit();
1517 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1519 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1522 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
1523 std::string key(message->key);
1524 std::string value(message->val);
1525 Dali::Property::Array options;
1527 if(message->options)
1531 EINA_LIST_FOREACH(message->options, l, data)
1533 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
1534 std::string option(static_cast<char*>(data));
1535 options.Add(option);
1539 mAuxiliaryMessageSignal.Emit(key, value, options);
1543 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1545 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1546 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1547 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1550 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1554 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1556 if(strcmp(interface, tizen_policy_interface.name) == 0)
1558 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1560 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1563 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1567 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1569 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1571 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1573 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1574 if(!mTizenDisplayPolicy)
1576 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1580 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1582 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1586 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1588 mTizenPolicy = NULL;
1589 mTizenDisplayPolicy = NULL;
1592 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1594 mNotificationLevel = level;
1595 mNotificationChangeState = state;
1596 mNotificationLevelChangeDone = true;
1598 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1601 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1603 mScreenOffMode = mode;
1604 mScreenOffModeChangeState = state;
1605 mScreenOffModeChangeDone = true;
1607 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1610 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1612 mBrightness = brightness;
1613 mBrightnessChangeState = state;
1614 mBrightnessChangeDone = true;
1616 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1619 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1621 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1622 KeyCodeMap foundKeyCode;
1624 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1625 if(sym == XKB_KEY_NoSymbol)
1627 DALI_LOG_ERROR("Failed to get keysym in WindowBaseEcoreWl2\n");
1631 foundKeyCode.keySym = sym;
1632 foundKeyCode.isKeyCode = false;
1633 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1634 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1637 Any WindowBaseEcoreWl2::GetNativeWindow()
1639 return mEcoreWindow;
1642 int WindowBaseEcoreWl2::GetNativeWindowId()
1644 return ecore_wl2_window_id_get(mEcoreWindow);
1647 std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
1649 #ifdef OVER_TIZEN_VERSION_7
1650 return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
1652 return std::string();
1656 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1658 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1660 START_DURATION_CHECK();
1661 if(totalAngle == 90 || totalAngle == 270)
1663 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
1667 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1669 FINISH_DURATION_CHECK("wl_egl_window_create");
1671 return static_cast<EGLNativeWindowType>(mEglWindow);
1674 void WindowBaseEcoreWl2::DestroyEglWindow()
1676 if(mEglWindow != NULL)
1678 START_DURATION_CHECK();
1679 wl_egl_window_destroy(mEglWindow);
1680 FINISH_DURATION_CHECK("wl_egl_window_destroy");
1686 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
1688 wl_egl_window_tizen_rotation rotation;
1694 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1699 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1704 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1709 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1714 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1719 START_DURATION_CHECK();
1720 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
1721 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_rotation");
1724 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
1726 wl_output_transform bufferTransform;
1732 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1737 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1742 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1747 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1752 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1757 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_buffer_transform() with buffer Transform [%d]\n", bufferTransform);
1758 START_DURATION_CHECK();
1759 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
1760 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_buffer_transform");
1763 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
1765 wl_output_transform windowTransform;
1771 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1776 windowTransform = WL_OUTPUT_TRANSFORM_90;
1781 windowTransform = WL_OUTPUT_TRANSFORM_180;
1786 windowTransform = WL_OUTPUT_TRANSFORM_270;
1791 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1796 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_window_transform() with window Transform [%d]\n", windowTransform);
1797 START_DURATION_CHECK();
1798 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
1799 FINISH_DURATION_CHECK("wl_egl_window_tizen_set_window_transform");
1802 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
1804 DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1805 START_DURATION_CHECK();
1806 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1808 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1809 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
1811 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
1812 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1814 FINISH_DURATION_CHECK("wl_egl_window functions");
1817 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1819 START_DURATION_CHECK();
1821 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
1822 FINISH_DURATION_CHECK("wl_egl_window_tizen_get_capabilities");
1824 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
1826 mSupportedPreProtation = true;
1829 mSupportedPreProtation = false;
1833 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
1835 PositionSize newPositionSize;
1836 int32_t screenWidth, screenHeight;
1837 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1839 if(mWindowRotationAngle == 90)
1841 newPositionSize.x = positionSize.y;
1842 newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
1843 newPositionSize.width = positionSize.height;
1844 newPositionSize.height = positionSize.width;
1846 else if(mWindowRotationAngle == 180)
1848 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1849 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1850 newPositionSize.width = positionSize.width;
1851 newPositionSize.height = positionSize.height;
1853 else if(mWindowRotationAngle == 270)
1855 newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
1856 newPositionSize.y = positionSize.x;
1857 newPositionSize.width = positionSize.height;
1858 newPositionSize.height = positionSize.width;
1862 newPositionSize.x = positionSize.x;
1863 newPositionSize.y = positionSize.y;
1864 newPositionSize.width = positionSize.width;
1865 newPositionSize.height = positionSize.height;
1868 return newPositionSize;
1871 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
1873 PositionSize newPositionSize;
1874 int32_t screenWidth, screenHeight;
1875 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1877 if(mWindowRotationAngle == 90)
1879 newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
1880 newPositionSize.y = positionSize.x;
1881 newPositionSize.width = positionSize.height;
1882 newPositionSize.height = positionSize.width;
1884 else if(mWindowRotationAngle == 180)
1886 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1887 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1888 newPositionSize.width = positionSize.width;
1889 newPositionSize.height = positionSize.height;
1891 else if(mWindowRotationAngle == 270)
1893 newPositionSize.x = positionSize.y;
1894 newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
1895 newPositionSize.width = positionSize.height;
1896 newPositionSize.height = positionSize.width;
1900 newPositionSize.x = positionSize.x;
1901 newPositionSize.y = positionSize.y;
1902 newPositionSize.width = positionSize.width;
1903 newPositionSize.height = positionSize.height;
1906 return newPositionSize;
1909 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
1911 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1913 mWindowPositionSize = newPositionSize;
1914 DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
1915 START_DURATION_CHECK();
1916 ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
1917 FINISH_DURATION_CHECK("ecore_wl2_window_position_set");
1920 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
1922 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1924 mWindowPositionSize = newPositionSize;
1925 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);
1926 START_DURATION_CHECK();
1927 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1928 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
1931 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
1933 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1935 mWindowPositionSize = newPositionSize;
1936 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);
1937 START_DURATION_CHECK();
1938 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1939 FINISH_DURATION_CHECK("ecore_wl2_window_sync_geometry_set");
1942 void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
1944 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);
1945 START_DURATION_CHECK();
1946 ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
1947 FINISH_DURATION_CHECK("ecore_wl2_window_layout_set");
1950 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
1952 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
1953 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
1956 void WindowBaseEcoreWl2::Raise()
1958 START_DURATION_CHECK();
1959 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1960 ecore_wl2_window_activate(mEcoreWindow);
1961 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
1964 void WindowBaseEcoreWl2::Lower()
1966 START_DURATION_CHECK();
1967 ecore_wl2_window_lower(mEcoreWindow);
1968 FINISH_DURATION_CHECK("ecore_wl2_window_lower");
1971 void WindowBaseEcoreWl2::Activate()
1973 START_DURATION_CHECK();
1974 ecore_wl2_window_activate(mEcoreWindow);
1975 FINISH_DURATION_CHECK("ecore_wl2_window_activate");
1978 void WindowBaseEcoreWl2::Maximize(bool maximize)
1980 START_DURATION_CHECK();
1981 ecore_wl2_window_maximized_set(mEcoreWindow, maximize);
1982 FINISH_DURATION_CHECK("ecore_wl2_window_maximized_set");
1985 bool WindowBaseEcoreWl2::IsMaximized() const
1987 return ecore_wl2_window_maximized_get(mEcoreWindow);
1990 void WindowBaseEcoreWl2::SetMaximumSize(Dali::Window::WindowSize size)
1992 DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
1993 START_DURATION_CHECK();
1994 ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
1995 FINISH_DURATION_CHECK("ecore_wl2_window_maximum_size_set");
1996 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
1999 void WindowBaseEcoreWl2::Minimize(bool minimize)
2001 START_DURATION_CHECK();
2002 ecore_wl2_window_iconified_set(mEcoreWindow, minimize);
2003 FINISH_DURATION_CHECK("ecore_wl2_window_iconified_set");
2006 bool WindowBaseEcoreWl2::IsMinimized() const
2008 return ecore_wl2_window_iconified_get(mEcoreWindow);
2011 void WindowBaseEcoreWl2::SetMimimumSize(Dali::Window::WindowSize size)
2013 DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
2014 START_DURATION_CHECK();
2015 ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
2016 FINISH_DURATION_CHECK("ecore_wl2_window_minimum_size_set");
2017 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2020 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
2022 int rotations[4] = {0};
2023 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
2024 for(std::size_t i = 0; i < angles.size(); ++i)
2026 rotations[i] = static_cast<int>(angles[i]);
2027 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
2030 START_DURATION_CHECK();
2031 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
2032 FINISH_DURATION_CHECK("ecore_wl2_window_available_rotations_set");
2035 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
2037 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
2038 START_DURATION_CHECK();
2039 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
2040 FINISH_DURATION_CHECK("ecore_wl2_window_preferred_rotation_set");
2043 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
2045 START_DURATION_CHECK();
2046 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
2047 FINISH_DURATION_CHECK("ecore_wl2_window_focus_skip_set");
2050 void WindowBaseEcoreWl2::Show()
2054 START_DURATION_CHECK();
2055 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
2056 FINISH_DURATION_CHECK("ecore_wl2_window_geometry_set");
2060 ecore_wl2_window_show(mEcoreWindow);
2063 void WindowBaseEcoreWl2::Hide()
2066 ecore_wl2_window_hide(mEcoreWindow);
2069 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
2071 return mSupportedAuxiliaryHints.size();
2074 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
2076 if(index >= GetSupportedAuxiliaryHintCount())
2078 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
2081 return mSupportedAuxiliaryHints[index];
2084 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
2086 bool supported = false;
2088 // Check if the hint is suppported
2089 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
2100 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
2104 // Check if the hint is already added
2105 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2107 if(mAuxiliaryHints[i].first == hint)
2109 // Just change the value
2110 mAuxiliaryHints[i].second = value;
2112 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
2114 return i + 1; // id is index + 1
2119 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
2121 unsigned int id = mAuxiliaryHints.size();
2123 START_DURATION_CHECK();
2124 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
2125 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_add");
2127 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
2132 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
2134 if(id == 0 || id > mAuxiliaryHints.size())
2136 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
2140 mAuxiliaryHints[id - 1].second = std::string();
2142 START_DURATION_CHECK();
2143 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
2144 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_del");
2146 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
2151 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
2153 if(id == 0 || id > mAuxiliaryHints.size())
2155 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
2159 mAuxiliaryHints[id - 1].second = value;
2161 START_DURATION_CHECK();
2162 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
2163 FINISH_DURATION_CHECK("ecore_wl2_window_aux_hint_change");
2165 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());
2170 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
2172 if(id == 0 || id > mAuxiliaryHints.size())
2174 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
2175 return std::string();
2178 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());
2180 return mAuxiliaryHints[id - 1].second;
2183 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
2185 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2187 if(mAuxiliaryHints[i].first == hint)
2189 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
2194 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
2199 Rect<int> WindowBaseEcoreWl2::RecalculateInputRect(const Rect<int>& rect)
2203 if(mWindowRotationAngle == 90)
2206 newRect.y = mWindowPositionSize.height - (rect.x + rect.width);
2207 newRect.width = rect.height;
2208 newRect.height = rect.width;
2210 else if(mWindowRotationAngle == 180)
2212 newRect.x = mWindowPositionSize.width - (rect.x + rect.width);
2213 newRect.y = mWindowPositionSize.height - (rect.y + rect.height);
2214 newRect.width = rect.width;
2215 newRect.height = rect.height;
2217 else if(mWindowRotationAngle == 270)
2219 newRect.x = mWindowPositionSize.width - (rect.y + rect.height);
2221 newRect.width = rect.height;
2222 newRect.height = rect.width;
2228 newRect.width = rect.width;
2229 newRect.height = rect.height;
2234 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
2236 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
2238 Eina_Rectangle rect;
2239 rect.x = convertRegion.x;
2240 rect.y = convertRegion.y;
2241 rect.w = convertRegion.width;
2242 rect.h = convertRegion.height;
2244 DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2245 START_DURATION_CHECK();
2246 ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
2247 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_set");
2248 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2251 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
2256 Ecore_Wl2_Window_Type windowType;
2260 case Dali::WindowType::NORMAL:
2262 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2265 case Dali::WindowType::NOTIFICATION:
2267 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
2270 case Dali::WindowType::UTILITY:
2272 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
2275 case Dali::WindowType::DIALOG:
2277 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
2280 case Dali::WindowType::IME:
2282 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
2285 case Dali::WindowType::DESKTOP:
2287 windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
2292 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2297 START_DURATION_CHECK();
2298 ecore_wl2_window_type_set(mEcoreWindow, windowType);
2299 FINISH_DURATION_CHECK("ecore_wl2_window_type_set");
2303 Dali::WindowType WindowBaseEcoreWl2::GetType() const
2308 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
2310 START_DURATION_CHECK();
2311 while(!mTizenPolicy)
2313 wl_display_dispatch_queue(mDisplay, mEventQueue);
2316 int notificationLevel;
2320 case Dali::WindowNotificationLevel::NONE:
2322 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
2325 case Dali::WindowNotificationLevel::BASE:
2327 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2330 case Dali::WindowNotificationLevel::MEDIUM:
2332 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
2335 case Dali::WindowNotificationLevel::HIGH:
2337 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
2340 case Dali::WindowNotificationLevel::TOP:
2342 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
2347 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
2348 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2353 mNotificationLevelChangeDone = false;
2354 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2356 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2360 while(!mNotificationLevelChangeDone && count < 3)
2362 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2363 wl_display_dispatch_queue(mDisplay, mEventQueue);
2366 FINISH_DURATION_CHECK("ecore_wl2 & wl_display");
2368 if(!mNotificationLevelChangeDone)
2370 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2371 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2373 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2375 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2376 return Dali::WindowOperationResult::PERMISSION_DENIED;
2379 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2381 return Dali::WindowOperationResult::SUCCEED;
2384 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2386 while(!mTizenPolicy)
2388 wl_display_dispatch_queue(mDisplay, mEventQueue);
2393 while(!mNotificationLevelChangeDone && count < 3)
2395 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2396 wl_display_dispatch_queue(mDisplay, mEventQueue);
2400 if(!mNotificationLevelChangeDone)
2402 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2403 return Dali::WindowNotificationLevel::NONE;
2406 Dali::WindowNotificationLevel level;
2408 switch(mNotificationLevel)
2410 case TIZEN_POLICY_LEVEL_NONE:
2412 level = Dali::WindowNotificationLevel::NONE;
2415 case TIZEN_POLICY_LEVEL_DEFAULT:
2417 level = Dali::WindowNotificationLevel::BASE;
2420 case TIZEN_POLICY_LEVEL_MEDIUM:
2422 level = Dali::WindowNotificationLevel::MEDIUM;
2425 case TIZEN_POLICY_LEVEL_HIGH:
2427 level = Dali::WindowNotificationLevel::HIGH;
2430 case TIZEN_POLICY_LEVEL_TOP:
2432 level = Dali::WindowNotificationLevel::TOP;
2437 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2438 level = Dali::WindowNotificationLevel::NONE;
2443 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2448 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2450 while(!mTizenPolicy)
2452 wl_display_dispatch_queue(mDisplay, mEventQueue);
2455 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2458 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2460 while(!mTizenPolicy)
2462 wl_display_dispatch_queue(mDisplay, mEventQueue);
2465 mScreenOffModeChangeDone = false;
2466 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2468 unsigned int mode = 0;
2470 switch(screenOffMode)
2472 case WindowScreenOffMode::TIMEOUT:
2477 case WindowScreenOffMode::NEVER:
2484 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2488 while(!mScreenOffModeChangeDone && count < 3)
2490 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2491 wl_display_dispatch_queue(mDisplay, mEventQueue);
2495 if(!mScreenOffModeChangeDone)
2497 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2498 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2500 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2502 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2503 return Dali::WindowOperationResult::PERMISSION_DENIED;
2506 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2508 return Dali::WindowOperationResult::SUCCEED;
2511 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2513 while(!mTizenPolicy)
2515 wl_display_dispatch_queue(mDisplay, mEventQueue);
2520 while(!mScreenOffModeChangeDone && count < 3)
2522 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2523 wl_display_dispatch_queue(mDisplay, mEventQueue);
2527 if(!mScreenOffModeChangeDone)
2529 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2530 return WindowScreenOffMode::TIMEOUT;
2533 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2535 switch(mScreenOffMode)
2539 screenMode = WindowScreenOffMode::TIMEOUT;
2544 screenMode = WindowScreenOffMode::NEVER;
2549 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2554 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2556 START_DURATION_CHECK();
2557 while(!mTizenDisplayPolicy)
2559 wl_display_dispatch_queue(mDisplay, mEventQueue);
2562 mBrightnessChangeDone = false;
2563 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2565 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2569 while(!mBrightnessChangeDone && count < 3)
2571 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2572 wl_display_dispatch_queue(mDisplay, mEventQueue);
2575 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2577 if(!mBrightnessChangeDone)
2579 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2580 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2582 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2584 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2585 return Dali::WindowOperationResult::PERMISSION_DENIED;
2588 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2590 return Dali::WindowOperationResult::SUCCEED;
2593 int WindowBaseEcoreWl2::GetBrightness() const
2595 START_DURATION_CHECK();
2596 while(!mTizenDisplayPolicy)
2598 wl_display_dispatch_queue(mDisplay, mEventQueue);
2603 while(!mBrightnessChangeDone && count < 3)
2605 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2606 wl_display_dispatch_queue(mDisplay, mEventQueue);
2609 FINISH_DURATION_CHECK("ecore_wl2_display_flush");
2611 if(!mBrightnessChangeDone)
2613 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2617 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2622 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2624 Ecore_Wl2_Window_Keygrab_Mode mode;
2628 case KeyGrab::TOPMOST:
2630 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2633 case KeyGrab::SHARED:
2635 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2638 case KeyGrab::OVERRIDE_EXCLUSIVE:
2640 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2643 case KeyGrab::EXCLUSIVE:
2645 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2654 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2657 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2659 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2662 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2664 int keyCount = key.Count();
2665 int keyGrabModeCount = grabMode.Count();
2667 if(keyCount != keyGrabModeCount || keyCount == 0)
2674 Eina_List* keyList = NULL;
2675 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2677 for(int index = 0; index < keyCount; ++index)
2679 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2681 switch(grabMode[index])
2683 case KeyGrab::TOPMOST:
2685 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2688 case KeyGrab::SHARED:
2690 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2693 case KeyGrab::OVERRIDE_EXCLUSIVE:
2695 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2698 case KeyGrab::EXCLUSIVE:
2700 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2705 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2710 keyList = eina_list_append(keyList, &info);
2713 START_DURATION_CHECK();
2714 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
2715 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_set");
2717 result.Resize(keyCount, true);
2719 Eina_List* l = NULL;
2720 Eina_List* m = NULL;
2721 void* listData = NULL;
2723 if(grabList != NULL)
2725 EINA_LIST_FOREACH(grabList, m, data)
2728 EINA_LIST_FOREACH(keyList, l, listData)
2730 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
2732 DALI_LOG_ERROR("input key list has null data!");
2736 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2738 result[index] = false;
2747 eina_list_free(keyList);
2748 eina_list_free(grabList);
2754 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
2756 int keyCount = key.Count();
2764 Eina_List* keyList = NULL;
2765 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2767 for(int index = 0; index < keyCount; ++index)
2769 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2770 keyList = eina_list_append(keyList, &info);
2773 START_DURATION_CHECK();
2774 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
2775 FINISH_DURATION_CHECK("ecore_wl2_window_keygrab_list_unset");
2777 result.Resize(keyCount, true);
2779 Eina_List* l = NULL;
2780 Eina_List* m = NULL;
2781 void* listData = NULL;
2784 if(ungrabList != NULL)
2786 EINA_LIST_FOREACH(ungrabList, m, data)
2789 EINA_LIST_FOREACH(keyList, l, listData)
2791 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2793 result[index] = false;
2802 eina_list_free(keyList);
2803 eina_list_free(ungrabList);
2809 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2814 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
2816 // 1 inch = 25.4 millimeters
2817 xres = ecore_wl2_output_dpi_get(output);
2818 yres = ecore_wl2_output_dpi_get(output);
2820 dpiHorizontal = int(xres + 0.5f); // rounding
2821 dpiVertical = int(yres + 0.5f);
2824 int WindowBaseEcoreWl2::GetWindowRotationAngle() const
2826 int orientation = mWindowRotationAngle;
2827 if(mSupportedPreProtation)
2834 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2836 if(mSupportedPreProtation)
2838 DALI_LOG_RELEASE_INFO("Support PreRotation and return 0\n");
2842 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
2848 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
2850 mScreenRotationAngle = transform * 90;
2851 return mScreenRotationAngle;
2854 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
2856 mWindowRotationAngle = degree;
2857 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
2860 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
2862 START_DURATION_CHECK();
2863 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
2864 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_change_done_send");
2867 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
2869 START_DURATION_CHECK();
2870 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
2871 FINISH_DURATION_CHECK("ecore_wl2_window_alpha_set");
2874 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
2876 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
2879 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
2882 START_DURATION_CHECK();
2883 ecore_wl2_display_sync(display);
2885 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2887 if(mEcoreWindow == 0)
2889 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2893 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
2894 FINISH_DURATION_CHECK("ecore_wl2 functions");
2897 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
2899 Ecore_Wl2_Window* ecoreParent = NULL;
2902 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
2903 ecoreParent = winBaseEcore2->mEcoreWindow;
2906 START_DURATION_CHECK();
2907 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
2908 FINISH_DURATION_CHECK("ecore_wl2_window_transient_parent_set");
2911 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2913 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
2916 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2918 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
2921 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2923 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);
2924 START_DURATION_CHECK();
2925 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2926 FINISH_DURATION_CHECK("ecore_wl2_window_rotation_geometry_set");
2929 void WindowBaseEcoreWl2::InitializeIme()
2931 Eina_Iterator* globals;
2932 struct wl_registry* registry;
2933 Ecore_Wl2_Global* global;
2934 Ecore_Wl2_Display* ecoreWl2Display;
2936 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
2938 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
2942 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p\n", ecoreWl2Display, mEcoreWindow);
2944 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
2946 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
2950 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
2952 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
2956 START_DURATION_CHECK();
2957 EINA_ITERATOR_FOREACH(globals, global)
2959 #ifdef OVER_TIZEN_VERSION_7
2960 if(strcmp(global->interface, "zwp_input_panel_v1") == 0)
2962 mWlInputPanel = (zwp_input_panel_v1*)wl_registry_bind(registry, global->id, &zwp_input_panel_v1_interface, 1);
2965 if(strcmp(global->interface, "wl_input_panel") == 0)
2967 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
2970 else if(strcmp(global->interface, "wl_output") == 0)
2972 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
2978 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
2984 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
2987 #ifdef OVER_TIZEN_VERSION_7
2988 mWlInputPanelSurface = zwp_input_panel_v1_get_input_panel_surface(mWlInputPanel, mWlSurface);
2990 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
2992 if(!mWlInputPanelSurface)
2994 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
2997 #ifdef OVER_TIZEN_VERSION_7
2998 zwp_input_panel_surface_v1_set_toplevel(mWlInputPanelSurface, mWlOutput, ZWP_INPUT_PANEL_SURFACE_V1_POSITION_CENTER_BOTTOM);
3000 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
3002 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_toplevel");
3005 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
3007 if(!mWlInputPanelSurface)
3009 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
3013 START_DURATION_CHECK();
3014 #ifdef OVER_TIZEN_VERSION_7
3015 zwp_input_panel_surface_v1_set_ready(mWlInputPanelSurface, 1);
3017 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
3019 FINISH_DURATION_CHECK("zwp_input_panel_surface_v1_set_ready");
3022 void WindowBaseEcoreWl2::RequestMoveToServer()
3024 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3027 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
3031 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3034 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
3038 START_DURATION_CHECK();
3039 ecore_wl2_window_move(mEcoreWindow, input);
3040 FINISH_DURATION_CHECK("ecore_wl2_window_move");
3041 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
3044 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
3046 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
3049 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
3053 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
3056 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
3060 ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
3062 START_DURATION_CHECK();
3063 ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
3064 FINISH_DURATION_CHECK("ecore_wl2_window_resize");
3065 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);
3068 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
3070 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
3071 START_DURATION_CHECK();
3074 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
3078 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
3080 FINISH_DURATION_CHECK("ecore_wl2_window_floating_mode_set");
3083 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
3085 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
3088 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
3090 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
3091 Eina_Rectangle rect;
3093 rect.x = convertRegion.x;
3094 rect.y = convertRegion.y;
3095 rect.w = convertRegion.width;
3096 rect.h = convertRegion.height;
3098 DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3099 START_DURATION_CHECK();
3100 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
3101 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_add");
3102 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3105 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
3107 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
3108 Eina_Rectangle rect;
3110 rect.x = convertRegion.x;
3111 rect.y = convertRegion.y;
3112 rect.w = convertRegion.width;
3113 rect.h = convertRegion.height;
3115 DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3116 START_DURATION_CHECK();
3117 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
3118 FINISH_DURATION_CHECK("ecore_wl2_window_input_rect_subtract");
3119 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3122 } // namespace Adaptor
3124 } // namespace Internal
3128 #pragma GCC diagnostic pop