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/window-system/common/window-impl.h>
28 #include <dali/internal/window-system/common/window-render-surface.h>
29 #include <dali/internal/window-system/common/window-system.h>
32 #include <Ecore_Input.h>
33 #include <dali/integration-api/debug.h>
34 #include <dali/integration-api/trace.h>
35 #include <dali/public-api/adaptor-framework/window-enumerations.h>
36 #include <dali/public-api/events/mouse-button.h>
37 #include <dali/public-api/object/any.h>
39 #if defined(VCONF_ENABLED)
40 #include <vconf-keys.h>
44 #include <wayland-egl-tizen.h>
54 #if defined(DEBUG_ENABLED)
55 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
58 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
61 * @brief Enumeration of location for window resized by display server.
63 enum class ResizeLocation
65 INVALID = 0, ///< Invalid value
66 TOP_LEFT = 5, ///< Start resizing window to the top-left edge.
67 LEFT = 4, ///< Start resizing window to the left side.
68 BOTTOM_LEFT = 6, ///< Start resizing window to the bottom-left edge.
69 BOTTOM = 2, ///< Start resizing window to the bottom side.
70 BOTTOM_RIGHT = 10, ///< Start resizing window to the bottom-right edge.
71 RIGHT = 8, ///< Start resizing window to the right side.
72 TOP_RIGHT = 9, ///< Start resizing window to the top-right edge.
73 TOP = 1 ///< Start resizing window to the top side.
76 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
77 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
78 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};
80 #if defined(VCONF_ENABLED)
81 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
87 xkb_keycode_t keyCode;
92 * Get the device name from the provided ecore key event
94 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
96 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
100 result = ecoreDeviceName;
105 * Get the device class from the provided ecore event
107 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
109 switch(ecoreDeviceClass)
111 case ECORE_DEVICE_CLASS_SEAT:
113 deviceClass = Device::Class::USER;
116 case ECORE_DEVICE_CLASS_KEYBOARD:
118 deviceClass = Device::Class::KEYBOARD;
121 case ECORE_DEVICE_CLASS_MOUSE:
123 deviceClass = Device::Class::MOUSE;
126 case ECORE_DEVICE_CLASS_TOUCH:
128 deviceClass = Device::Class::TOUCH;
131 case ECORE_DEVICE_CLASS_PEN:
133 deviceClass = Device::Class::PEN;
136 case ECORE_DEVICE_CLASS_POINTER:
138 deviceClass = Device::Class::POINTER;
141 case ECORE_DEVICE_CLASS_GAMEPAD:
143 deviceClass = Device::Class::GAMEPAD;
148 deviceClass = Device::Class::NONE;
154 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
156 switch(ecoreDeviceSubclass)
158 case ECORE_DEVICE_SUBCLASS_FINGER:
160 deviceSubclass = Device::Subclass::FINGER;
163 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
165 deviceSubclass = Device::Subclass::FINGERNAIL;
168 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
170 deviceSubclass = Device::Subclass::KNUCKLE;
173 case ECORE_DEVICE_SUBCLASS_PALM:
175 deviceSubclass = Device::Subclass::PALM;
178 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
180 deviceSubclass = Device::Subclass::HAND_SIDE;
183 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
185 deviceSubclass = Device::Subclass::HAND_FLAT;
188 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
190 deviceSubclass = Device::Subclass::PEN_TIP;
193 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
195 deviceSubclass = Device::Subclass::TRACKPAD;
198 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
200 deviceSubclass = Device::Subclass::TRACKPOINT;
203 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
205 deviceSubclass = Device::Subclass::TRACKBALL;
208 case ECORE_DEVICE_SUBCLASS_REMOCON:
210 deviceSubclass = Device::Subclass::REMOCON;
213 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
215 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
220 deviceSubclass = Device::Subclass::NONE;
226 void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
228 KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
229 if(foundKeyCode->isKeyCode)
234 xkb_keysym_t keySym = foundKeyCode->keySym;
236 const xkb_keysym_t* symsOut = NULL;
238 nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
242 if(*symsOut == keySym)
244 foundKeyCode->keyCode = key;
245 foundKeyCode->isKeyCode = true;
251 * Return the recalculated window resizing location according to the current orientation.
253 ResizeLocation RecalculateLocationToCurrentOrientation(WindowResizeDirection direction, int windowRotationAngle)
258 case WindowResizeDirection::TOP_LEFT:
263 case WindowResizeDirection::LEFT:
268 case WindowResizeDirection::BOTTOM_LEFT:
273 case WindowResizeDirection::BOTTOM:
278 case WindowResizeDirection::BOTTOM_RIGHT:
283 case WindowResizeDirection::RIGHT:
288 case WindowResizeDirection::TOP_RIGHT:
293 case WindowResizeDirection::TOP:
305 if(index != 8 && windowRotationAngle != 0)
307 index = (index + (windowRotationAngle / 90) * 2) % 8;
310 return RESIZE_LOCATIONS[index];
313 /////////////////////////////////////////////////////////////////////////////////////////////////
315 /////////////////////////////////////////////////////////////////////////////////////////////////
317 /// Called when the window iconify state is changed.
318 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
320 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
323 return windowBase->OnIconifyStateChanged(data, type, event);
326 return ECORE_CALLBACK_PASS_ON;
329 /// Called when the window gains focus
330 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
332 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
335 return windowBase->OnFocusIn(data, type, event);
338 return ECORE_CALLBACK_PASS_ON;
341 /// Called when the window loses focus
342 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
344 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
347 return windowBase->OnFocusOut(data, type, event);
350 return ECORE_CALLBACK_PASS_ON;
353 /// Called when the output is transformed
354 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
356 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
359 return windowBase->OnOutputTransform(data, type, event);
362 return ECORE_CALLBACK_PASS_ON;
365 /// Called when the output transform should be ignored
366 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
368 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
371 return windowBase->OnIgnoreOutputTransform(data, type, event);
374 return ECORE_CALLBACK_PASS_ON;
378 * Called when rotate event is recevied.
380 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
382 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
385 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
386 windowBase->OnRotation(data, type, event);
388 return ECORE_CALLBACK_PASS_ON;
392 * Called when configure event is recevied.
394 static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
396 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
399 windowBase->OnConfiguration(data, type, event);
401 return ECORE_CALLBACK_PASS_ON;
404 /////////////////////////////////////////////////////////////////////////////////////////////////
406 /////////////////////////////////////////////////////////////////////////////////////////////////
409 * Called when a touch down is received.
411 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
413 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
416 windowBase->OnMouseButtonDown(data, type, event);
418 return ECORE_CALLBACK_PASS_ON;
422 * Called when a touch up is received.
424 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
426 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
429 windowBase->OnMouseButtonUp(data, type, event);
431 return ECORE_CALLBACK_PASS_ON;
435 * Called when a touch motion is received.
437 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
439 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
442 windowBase->OnMouseButtonMove(data, type, event);
444 return ECORE_CALLBACK_PASS_ON;
448 * Called when a touch is canceled.
450 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
452 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
455 windowBase->OnMouseButtonCancel(data, type, event);
457 return ECORE_CALLBACK_PASS_ON;
461 * Called when a mouse wheel is received.
463 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
465 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
468 windowBase->OnMouseWheel(data, type, event);
470 return ECORE_CALLBACK_PASS_ON;
474 * Called when a mouse in is received.
476 static Eina_Bool EcoreEventMouseIn(void* data, int type, void* event)
478 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
481 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::IN);
483 return ECORE_CALLBACK_PASS_ON;
487 * Called when a mouse out is received.
489 static Eina_Bool EcoreEventMouseOut(void* data, int type, void* event)
491 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
494 // When the mouse is out, the previous mouse must be canceled.
495 windowBase->OnMouseButtonCancel(data, type, event);
496 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::OUT);
498 return ECORE_CALLBACK_PASS_ON;
502 * Called when a detent rotation event is recevied.
504 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
506 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
509 windowBase->OnDetentRotation(data, type, event);
511 return ECORE_CALLBACK_PASS_ON;
514 /////////////////////////////////////////////////////////////////////////////////////////////////
516 /////////////////////////////////////////////////////////////////////////////////////////////////
519 * Called when a key down is received.
521 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
523 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
526 windowBase->OnKeyDown(data, type, event);
528 return ECORE_CALLBACK_PASS_ON;
532 * Called when a key up is received.
534 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
536 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
539 windowBase->OnKeyUp(data, type, event);
541 return ECORE_CALLBACK_PASS_ON;
544 /////////////////////////////////////////////////////////////////////////////////////////////////
545 // Selection Callbacks
546 /////////////////////////////////////////////////////////////////////////////////////////////////
549 * Called when the source window notifies us the content in clipboard is selected.
551 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
553 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
556 windowBase->OnDataSend(data, type, event);
558 return ECORE_CALLBACK_PASS_ON;
562 * Called when the source window sends us about the selected content.
563 * For example, when item is selected in the clipboard.
565 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
567 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
570 windowBase->OnDataReceive(data, type, event);
572 return ECORE_CALLBACK_PASS_ON;
575 /////////////////////////////////////////////////////////////////////////////////////////////////
576 // Effect Start/End Callbacks
577 /////////////////////////////////////////////////////////////////////////////////////////////////
580 * Called when transition animation of the window's shown/hidden is started by window manager.
582 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
584 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
585 Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
586 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
589 if(effectStart->type < 3) // only under restack
591 windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
594 return ECORE_CALLBACK_PASS_ON;
598 * Called when transition animation of the window's shown/hidden is ended by window manager.
600 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
602 Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
603 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
604 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
607 if(effectEnd->type < 3) // only under restack
609 windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
612 return ECORE_CALLBACK_PASS_ON;
615 /////////////////////////////////////////////////////////////////////////////////////////////////
616 // Keyboard Repeat Settings Changed Callbacks
617 /////////////////////////////////////////////////////////////////////////////////////////////////
619 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
621 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
622 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event)->id);
625 windowBase->OnKeyboardRepeatSettingsChanged();
628 return ECORE_CALLBACK_RENEW;
631 /////////////////////////////////////////////////////////////////////////////////////////////////
632 // Keymap Changed Callbacks
633 /////////////////////////////////////////////////////////////////////////////////////////////////
635 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
637 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
640 windowBase->KeymapChanged(data, type, event);
643 return ECORE_CALLBACK_RENEW;
646 /////////////////////////////////////////////////////////////////////////////////////////////////
648 /////////////////////////////////////////////////////////////////////////////////////////////////
650 #if defined(VCONF_ENABLED)
652 * Called when a font name is changed.
654 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
656 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
659 windowBase->OnFontNameChanged();
664 * Called when a font size is changed.
666 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
668 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
671 windowBase->OnFontSizeChanged();
676 /////////////////////////////////////////////////////////////////////////////////////////////////
677 // Window Redraw Request Event Callbacks
678 /////////////////////////////////////////////////////////////////////////////////////////////////
680 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
682 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
683 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event)->win);
686 windowBase->OnEcoreEventWindowRedrawRequest();
689 return ECORE_CALLBACK_RENEW;
692 /////////////////////////////////////////////////////////////////////////////////////////////////
693 // Window Auxiliary Message Callbacks
694 /////////////////////////////////////////////////////////////////////////////////////////////////
695 static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* event)
697 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
700 windowBase->OnEcoreEventWindowAuxiliaryMessage(event);
702 return ECORE_CALLBACK_RENEW;
705 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
707 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
710 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
714 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
716 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
719 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
723 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
727 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)
731 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
733 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
736 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
740 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
744 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
746 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
749 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
753 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
757 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
761 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
765 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
769 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)
773 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
775 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
778 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
782 const struct wl_registry_listener registryListener =
784 RegistryGlobalCallback,
785 RegistryGlobalCallbackRemove};
787 const struct tizen_policy_listener tizenPolicyListener =
789 TizenPolicyConformant,
790 TizenPolicyConformantArea,
791 TizenPolicyNotificationChangeDone,
792 TizenPolicyTransientForDone,
793 TizenPolicyScreenModeChangeDone,
794 TizenPolicyIconifyStateChanged,
795 TizenPolicySupportedAuxiliaryHints,
796 TizenPolicyAllowedAuxiliaryHint,
797 TizenPolicyAuxiliaryMessage,
798 TizenPolicyConformantRegion};
800 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
802 DisplayPolicyBrightnessChangeDone};
804 } // unnamed namespace
806 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
807 : mEcoreEventHandler(),
808 mEcoreWindow(nullptr),
810 mWlInputPanel(nullptr),
812 mWlInputPanelSurface(nullptr),
815 mEventQueue(nullptr),
816 mTizenPolicy(nullptr),
817 mTizenDisplayPolicy(nullptr),
819 mSupportedAuxiliaryHints(),
820 mWindowPositionSize(positionSize),
822 mType(WindowType::NORMAL),
823 mNotificationLevel(-1),
826 mWindowRotationAngle(0),
827 mScreenRotationAngle(0),
828 mSupportedPreProtation(0),
829 mNotificationChangeState(0),
830 mScreenOffModeChangeState(0),
831 mBrightnessChangeState(0),
832 mLastSubmittedMoveResizeSerial(0),
833 mMoveResizeSerial(0),
834 mNotificationLevelChangeDone(true),
835 mScreenOffModeChangeDone(true),
838 mBrightnessChangeDone(true)
840 Initialize(positionSize, surface, isTransparent);
843 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
845 #if defined(VCONF_ENABLED)
846 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
847 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
850 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
852 ecore_event_handler_del(*iter);
854 mEcoreEventHandler.Clear();
858 wl_event_queue_destroy(mEventQueue);
861 mSupportedAuxiliaryHints.clear();
862 mAuxiliaryHints.clear();
864 if(mEglWindow != NULL)
866 wl_egl_window_destroy(mEglWindow);
872 ecore_wl2_window_free(mEcoreWindow);
874 WindowSystem::Shutdown();
878 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
880 if(surface.Empty() == false)
882 // check we have a valid type
883 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
885 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
889 // we own the surface about to created
890 WindowSystem::Initialize();
893 CreateWindow(positionSize);
896 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
898 SetTransparency(isTransparent);
900 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
901 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
902 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
903 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
904 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
906 // Register Rotate event
907 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
909 // Register Configure event
910 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
912 // Register Touch events
913 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
914 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
915 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
916 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
918 // Register Mouse wheel events
919 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
921 // Register Mouse IO events
922 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
923 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
925 // Register Detent event
926 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
928 // Register Key events
929 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
930 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
932 // Register Selection event - clipboard selection
933 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
934 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
936 // Register Effect Start/End event
937 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
938 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
940 // Register Keyboard repeat event
941 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
943 // Register Window redraw request event
944 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
946 // Register Window auxiliary event
947 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
949 #if defined(VCONF_ENABLED)
950 // Register Vconf notify - font name and size
951 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
952 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
955 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
956 mDisplay = ecore_wl2_display_get(display);
960 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
963 mEventQueue = wl_display_create_queue(mDisplay);
966 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
968 wl_registry* registry = wl_display_get_registry(displayWrapper);
969 wl_registry_add_listener(registry, ®istryListener, this);
972 wl_proxy_wrapper_destroy(displayWrapper);
976 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
980 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
982 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
985 // get auxiliary hint
986 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
992 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))))
994 mSupportedAuxiliaryHints.push_back(hint);
996 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
1001 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
1003 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
1004 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
1006 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1008 if(iconifyChangedEvent->iconified == EINA_TRUE)
1010 mIconifyChangedSignal.Emit(true);
1014 mIconifyChangedSignal.Emit(false);
1016 handled = ECORE_CALLBACK_DONE;
1022 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
1024 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
1026 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1028 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
1030 mFocusChangedSignal.Emit(true);
1033 return ECORE_CALLBACK_PASS_ON;
1036 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
1038 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
1040 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1042 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
1044 mFocusChangedSignal.Emit(false);
1047 return ECORE_CALLBACK_PASS_ON;
1050 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
1052 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
1054 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
1056 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
1058 mScreenRotationAngle = GetScreenRotationAngle();
1060 mOutputTransformedSignal.Emit();
1063 return ECORE_CALLBACK_PASS_ON;
1066 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
1068 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
1070 if(ignoreTransformEvent->win == mEcoreWindow)
1072 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
1074 mScreenRotationAngle = GetScreenRotationAngle();
1076 mOutputTransformedSignal.Emit();
1079 return ECORE_CALLBACK_PASS_ON;
1082 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
1084 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
1086 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1088 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
1090 RotationEvent rotationEvent;
1091 rotationEvent.angle = ev->angle;
1092 rotationEvent.winResize = 0;
1094 if(ev->w == 0 || ev->h == 0)
1096 // When rotation event does not have the window width or height,
1097 // previous DALi side window's size are used.
1098 ev->w = mWindowPositionSize.width;
1099 ev->h = mWindowPositionSize.height;
1102 mWindowRotationAngle = ev->angle;
1104 mWindowPositionSize.width = ev->w;
1105 mWindowPositionSize.height = ev->h;
1107 PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1109 rotationEvent.x = newPositionSize.x;
1110 rotationEvent.y = newPositionSize.y;
1111 rotationEvent.width = newPositionSize.width;
1112 rotationEvent.height = newPositionSize.height;
1114 mRotationSignal.Emit(rotationEvent);
1118 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1120 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1122 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1124 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1125 // by calling ecore_wl2_window_commit
1127 int tempWidth = static_cast<int>(ev->w);
1128 int tempHeight = static_cast<int>(ev->h);
1130 // Initialize with previous size for skip resize when new size is 0.
1131 // When window is just moved or window is resized by client application,
1132 // The configure notification event's size will be 0.
1133 // If new size is 0, the resized work should be skip.
1134 int newWidth = mWindowPositionSize.width;
1135 int newHeight = mWindowPositionSize.height;
1136 bool windowMoved = false, windowResized = false;
1138 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1143 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1145 windowResized = true;
1146 newWidth = tempWidth;
1147 newHeight = tempHeight;
1150 if(windowMoved || windowResized)
1152 mWindowPositionSize.x = ev->x;
1153 mWindowPositionSize.y = ev->y;
1154 mWindowPositionSize.width = newWidth;
1155 mWindowPositionSize.height = newHeight;
1156 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);
1158 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1160 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1161 mUpdatePositionSizeSignal.Emit(newPositionSize);
1164 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1168 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1170 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1172 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1174 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
1176 Device::Class::Type deviceClass;
1177 Device::Subclass::Type deviceSubclass;
1179 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1180 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1182 PointState::Type state(PointState::DOWN);
1184 if(deviceClass != Device::Class::Type::MOUSE)
1186 // Check if the buttons field is set and ensure it's the primary touch button.
1187 // If this event was triggered by buttons other than the primary button (used for touch), then
1188 // just send an interrupted event to Core.
1189 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1191 state = PointState::INTERRUPTED;
1195 Integration::Point point;
1196 point.SetDeviceId(touchEvent->multi.device);
1197 point.SetState(state);
1198 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1199 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1200 point.SetPressure(touchEvent->multi.pressure);
1201 point.SetAngle(Degree(touchEvent->multi.angle));
1202 point.SetDeviceClass(deviceClass);
1203 point.SetDeviceSubclass(deviceSubclass);
1204 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1206 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1210 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1212 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1214 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1216 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
1218 Device::Class::Type deviceClass;
1219 Device::Subclass::Type deviceSubclass;
1221 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1222 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1224 Integration::Point point;
1225 point.SetDeviceId(touchEvent->multi.device);
1226 point.SetState(PointState::UP);
1227 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1228 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1229 point.SetPressure(touchEvent->multi.pressure);
1230 point.SetAngle(Degree(touchEvent->multi.angle));
1231 point.SetDeviceClass(deviceClass);
1232 point.SetDeviceSubclass(deviceSubclass);
1233 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1235 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1239 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1241 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1243 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1245 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
1247 Device::Class::Type deviceClass;
1248 Device::Subclass::Type deviceSubclass;
1250 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1251 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1253 Integration::Point point;
1254 point.SetDeviceId(touchEvent->multi.device);
1255 point.SetState(PointState::MOTION);
1256 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1257 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1258 point.SetPressure(touchEvent->multi.pressure);
1259 point.SetAngle(Degree(touchEvent->multi.angle));
1260 point.SetDeviceClass(deviceClass);
1261 point.SetDeviceSubclass(deviceSubclass);
1263 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1267 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1269 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1271 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1273 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
1275 Integration::Point point;
1276 point.SetDeviceId(touchEvent->multi.device);
1277 point.SetState(PointState::INTERRUPTED);
1278 point.SetScreenPosition(Vector2(0.0f, 0.0f));
1280 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1282 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1286 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1288 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1290 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1292 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
1294 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);
1296 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1298 mWheelEventSignal.Emit(wheelEvent);
1302 void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
1304 Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
1306 if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1308 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
1310 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);
1312 Device::Class::Type deviceClass;
1313 Device::Subclass::Type deviceSubclass;
1315 GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
1316 GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
1318 Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
1320 mMouseInOutEventSignal.Emit(inOutEvent);
1324 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1326 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1328 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1330 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1332 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1334 mWheelEventSignal.Emit(wheelEvent);
1337 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1339 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1341 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1343 std::string keyName(keyEvent->keyname);
1344 std::string logicalKey("");
1345 std::string keyString("");
1346 std::string compose("");
1348 DALI_TRACE_BEGIN(gTraceFilter, "DALI_ON_KEY_DOWN");
1350 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1351 if(keyEvent->compose)
1353 compose = keyEvent->compose;
1356 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1359 logicalKey = keyEvent->key;
1363 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1367 // Get a specific key code from dali key look up table.
1368 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1371 keyCode = (keyCode == -1) ? 0 : keyCode;
1372 int modifier(keyEvent->modifiers);
1373 unsigned long time = keyEvent->timestamp;
1374 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1376 keyCode = atoi(keyEvent->keyname + 8);
1379 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1380 if(keyEvent->string)
1382 keyString = keyEvent->string;
1385 std::string deviceName;
1386 Device::Class::Type deviceClass;
1387 Device::Subclass::Type deviceSubclass;
1389 GetDeviceName(keyEvent, deviceName);
1390 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1391 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1393 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1395 mKeyEventSignal.Emit(keyEvent);
1397 DALI_TRACE_END(gTraceFilter, "DALI_ON_KEY_DOWN");
1401 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1403 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1405 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1407 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1408 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1409 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1411 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1414 #endif // Since ecore 1.23 version
1416 std::string keyName(keyEvent->keyname);
1417 std::string logicalKey("");
1418 std::string keyString("");
1419 std::string compose("");
1421 DALI_TRACE_BEGIN(gTraceFilter, "DALI_ON_KEY_UP");
1423 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1424 if(keyEvent->compose)
1426 compose = keyEvent->compose;
1429 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1432 logicalKey = keyEvent->key;
1436 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1440 // Get a specific key code from dali key look up table.
1441 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1444 keyCode = (keyCode == -1) ? 0 : keyCode;
1445 int modifier(keyEvent->modifiers);
1446 unsigned long time = keyEvent->timestamp;
1447 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1449 keyCode = atoi(keyEvent->keyname + 8);
1452 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1453 if(keyEvent->string)
1455 keyString = keyEvent->string;
1458 std::string deviceName;
1459 Device::Class::Type deviceClass;
1460 Device::Subclass::Type deviceSubclass;
1462 GetDeviceName(keyEvent, deviceName);
1463 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1464 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1466 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1468 mKeyEventSignal.Emit(keyEvent);
1470 DALI_TRACE_END(gTraceFilter, "DALI_ON_KEY_UP");
1474 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1476 mSelectionDataSendSignal.Emit(event);
1479 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1481 mSelectionDataReceivedSignal.Emit(event);
1484 void WindowBaseEcoreWl2::OnFontNameChanged()
1486 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1489 void WindowBaseEcoreWl2::OnFontSizeChanged()
1491 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1494 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1496 mTransitionEffectEventSignal.Emit(state, type);
1499 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1501 mKeyboardRepeatSettingsChangedSignal.Emit();
1504 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1506 mWindowRedrawRequestSignal.Emit();
1509 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1511 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1514 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
1515 std::string key(message->key);
1516 std::string value(message->val);
1517 Dali::Property::Array options;
1519 if(message->options)
1523 EINA_LIST_FOREACH(message->options, l, data)
1525 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
1526 std::string option(static_cast<char*>(data));
1527 options.Add(option);
1531 mAuxiliaryMessageSignal.Emit(key, value, options);
1535 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1537 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1538 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1539 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1542 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1546 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1548 if(strcmp(interface, tizen_policy_interface.name) == 0)
1550 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1552 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1555 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1559 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1561 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1563 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1565 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1566 if(!mTizenDisplayPolicy)
1568 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1572 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1574 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1578 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1580 mTizenPolicy = NULL;
1581 mTizenDisplayPolicy = NULL;
1584 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1586 mNotificationLevel = level;
1587 mNotificationChangeState = state;
1588 mNotificationLevelChangeDone = true;
1590 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1593 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1595 mScreenOffMode = mode;
1596 mScreenOffModeChangeState = state;
1597 mScreenOffModeChangeDone = true;
1599 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1602 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1604 mBrightness = brightness;
1605 mBrightnessChangeState = state;
1606 mBrightnessChangeDone = true;
1608 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1611 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1613 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1614 KeyCodeMap foundKeyCode;
1616 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1617 if(sym == XKB_KEY_NoSymbol)
1619 DALI_LOG_ERROR("Failed to get keysym in WindowBaseEcoreWl2\n");
1623 foundKeyCode.keySym = sym;
1624 foundKeyCode.isKeyCode = false;
1625 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1626 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1629 Any WindowBaseEcoreWl2::GetNativeWindow()
1631 return mEcoreWindow;
1634 int WindowBaseEcoreWl2::GetNativeWindowId()
1636 return ecore_wl2_window_id_get(mEcoreWindow);
1639 std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
1641 #ifdef OVER_TIZEN_VERSION_7
1642 return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
1644 return std::string();
1648 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1650 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1651 if(totalAngle == 90 || totalAngle == 270)
1653 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
1657 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1660 return static_cast<EGLNativeWindowType>(mEglWindow);
1663 void WindowBaseEcoreWl2::DestroyEglWindow()
1665 if(mEglWindow != NULL)
1667 wl_egl_window_destroy(mEglWindow);
1672 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
1674 wl_egl_window_tizen_rotation rotation;
1680 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1685 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1690 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1695 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1700 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1705 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
1708 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
1710 wl_output_transform bufferTransform;
1716 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1721 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1726 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1731 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1736 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1741 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_buffer_transform() with buffer Transform [%d]\n", bufferTransform);
1742 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
1745 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
1747 wl_output_transform windowTransform;
1753 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1758 windowTransform = WL_OUTPUT_TRANSFORM_90;
1763 windowTransform = WL_OUTPUT_TRANSFORM_180;
1768 windowTransform = WL_OUTPUT_TRANSFORM_270;
1773 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1778 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_window_transform() with window Transform [%d]\n", windowTransform);
1779 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
1782 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
1784 DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1785 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1787 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1788 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
1790 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
1791 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1795 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1798 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
1799 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
1801 mSupportedPreProtation = true;
1804 mSupportedPreProtation = false;
1808 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
1810 PositionSize newPositionSize;
1811 int32_t screenWidth, screenHeight;
1812 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1814 if(mWindowRotationAngle == 90)
1816 newPositionSize.x = positionSize.y;
1817 newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
1818 newPositionSize.width = positionSize.height;
1819 newPositionSize.height = positionSize.width;
1821 else if(mWindowRotationAngle == 180)
1823 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1824 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1825 newPositionSize.width = positionSize.width;
1826 newPositionSize.height = positionSize.height;
1828 else if(mWindowRotationAngle == 270)
1830 newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
1831 newPositionSize.y = positionSize.x;
1832 newPositionSize.width = positionSize.height;
1833 newPositionSize.height = positionSize.width;
1837 newPositionSize.x = positionSize.x;
1838 newPositionSize.y = positionSize.y;
1839 newPositionSize.width = positionSize.width;
1840 newPositionSize.height = positionSize.height;
1843 return newPositionSize;
1846 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
1848 PositionSize newPositionSize;
1849 int32_t screenWidth, screenHeight;
1850 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1852 if(mWindowRotationAngle == 90)
1854 newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
1855 newPositionSize.y = positionSize.x;
1856 newPositionSize.width = positionSize.height;
1857 newPositionSize.height = positionSize.width;
1859 else if(mWindowRotationAngle == 180)
1861 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1862 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1863 newPositionSize.width = positionSize.width;
1864 newPositionSize.height = positionSize.height;
1866 else if(mWindowRotationAngle == 270)
1868 newPositionSize.x = positionSize.y;
1869 newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
1870 newPositionSize.width = positionSize.height;
1871 newPositionSize.height = positionSize.width;
1875 newPositionSize.x = positionSize.x;
1876 newPositionSize.y = positionSize.y;
1877 newPositionSize.width = positionSize.width;
1878 newPositionSize.height = positionSize.height;
1881 return newPositionSize;
1884 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
1886 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1888 mWindowPositionSize = newPositionSize;
1889 DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
1890 ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
1893 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
1895 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1897 mWindowPositionSize = newPositionSize;
1898 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);
1899 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1902 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
1904 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1906 mWindowPositionSize = newPositionSize;
1907 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);
1908 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1911 void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
1913 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);
1914 ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
1917 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
1919 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
1920 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
1923 void WindowBaseEcoreWl2::Raise()
1925 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1926 ecore_wl2_window_activate(mEcoreWindow);
1929 void WindowBaseEcoreWl2::Lower()
1931 ecore_wl2_window_lower(mEcoreWindow);
1934 void WindowBaseEcoreWl2::Activate()
1936 ecore_wl2_window_activate(mEcoreWindow);
1939 void WindowBaseEcoreWl2::Maximize(bool maximize)
1941 ecore_wl2_window_maximized_set(mEcoreWindow, maximize);
1944 bool WindowBaseEcoreWl2::IsMaximized() const
1946 return ecore_wl2_window_maximized_get(mEcoreWindow);
1949 void WindowBaseEcoreWl2::SetMaximumSize(Dali::Window::WindowSize size)
1951 DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
1952 ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
1953 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
1956 void WindowBaseEcoreWl2::Minimize(bool minimize)
1958 ecore_wl2_window_iconified_set(mEcoreWindow, minimize);
1961 bool WindowBaseEcoreWl2::IsMinimized() const
1963 return ecore_wl2_window_iconified_get(mEcoreWindow);
1966 void WindowBaseEcoreWl2::SetMimimumSize(Dali::Window::WindowSize size)
1968 DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
1969 ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
1970 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
1973 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
1975 int rotations[4] = {0};
1976 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
1977 for(std::size_t i = 0; i < angles.size(); ++i)
1979 rotations[i] = static_cast<int>(angles[i]);
1980 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
1982 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
1985 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
1987 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
1988 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
1991 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
1993 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
1996 void WindowBaseEcoreWl2::Show()
2000 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
2004 ecore_wl2_window_show(mEcoreWindow);
2007 void WindowBaseEcoreWl2::Hide()
2010 ecore_wl2_window_hide(mEcoreWindow);
2013 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
2015 return mSupportedAuxiliaryHints.size();
2018 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
2020 if(index >= GetSupportedAuxiliaryHintCount())
2022 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
2025 return mSupportedAuxiliaryHints[index];
2028 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
2030 bool supported = false;
2032 // Check if the hint is suppported
2033 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
2044 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
2048 // Check if the hint is already added
2049 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2051 if(mAuxiliaryHints[i].first == hint)
2053 // Just change the value
2054 mAuxiliaryHints[i].second = value;
2056 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
2058 return i + 1; // id is index + 1
2063 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
2065 unsigned int id = mAuxiliaryHints.size();
2067 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
2069 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
2074 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
2076 if(id == 0 || id > mAuxiliaryHints.size())
2078 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
2082 mAuxiliaryHints[id - 1].second = std::string();
2084 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
2086 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
2091 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
2093 if(id == 0 || id > mAuxiliaryHints.size())
2095 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
2099 mAuxiliaryHints[id - 1].second = value;
2101 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
2103 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());
2108 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
2110 if(id == 0 || id > mAuxiliaryHints.size())
2112 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
2113 return std::string();
2116 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());
2118 return mAuxiliaryHints[id - 1].second;
2121 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
2123 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2125 if(mAuxiliaryHints[i].first == hint)
2127 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
2132 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
2137 Rect<int> WindowBaseEcoreWl2::RecalculateInputRect(const Rect<int>& rect)
2141 if(mWindowRotationAngle == 90)
2144 newRect.y = mWindowPositionSize.height - (rect.x + rect.width);
2145 newRect.width = rect.height;
2146 newRect.height = rect.width;
2148 else if(mWindowRotationAngle == 180)
2150 newRect.x = mWindowPositionSize.width - (rect.x + rect.width);
2151 newRect.y = mWindowPositionSize.height - (rect.y + rect.height);
2152 newRect.width = rect.width;
2153 newRect.height = rect.height;
2155 else if(mWindowRotationAngle == 270)
2157 newRect.x = mWindowPositionSize.width - (rect.y + rect.height);
2159 newRect.width = rect.height;
2160 newRect.height = rect.width;
2166 newRect.width = rect.width;
2167 newRect.height = rect.height;
2172 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
2174 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
2176 Eina_Rectangle rect;
2177 rect.x = convertRegion.x;
2178 rect.y = convertRegion.y;
2179 rect.w = convertRegion.width;
2180 rect.h = convertRegion.height;
2182 DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2183 ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
2184 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2187 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
2192 Ecore_Wl2_Window_Type windowType;
2196 case Dali::WindowType::NORMAL:
2198 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2201 case Dali::WindowType::NOTIFICATION:
2203 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
2206 case Dali::WindowType::UTILITY:
2208 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
2211 case Dali::WindowType::DIALOG:
2213 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
2216 case Dali::WindowType::IME:
2218 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
2221 case Dali::WindowType::DESKTOP:
2223 windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
2228 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2232 ecore_wl2_window_type_set(mEcoreWindow, windowType);
2236 Dali::WindowType WindowBaseEcoreWl2::GetType() const
2241 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
2243 while(!mTizenPolicy)
2245 wl_display_dispatch_queue(mDisplay, mEventQueue);
2248 int notificationLevel;
2252 case Dali::WindowNotificationLevel::NONE:
2254 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
2257 case Dali::WindowNotificationLevel::BASE:
2259 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2262 case Dali::WindowNotificationLevel::MEDIUM:
2264 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
2267 case Dali::WindowNotificationLevel::HIGH:
2269 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
2272 case Dali::WindowNotificationLevel::TOP:
2274 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
2279 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
2280 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2285 mNotificationLevelChangeDone = false;
2286 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2288 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2292 while(!mNotificationLevelChangeDone && count < 3)
2294 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2295 wl_display_dispatch_queue(mDisplay, mEventQueue);
2299 if(!mNotificationLevelChangeDone)
2301 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2302 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2304 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2306 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2307 return Dali::WindowOperationResult::PERMISSION_DENIED;
2310 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2312 return Dali::WindowOperationResult::SUCCEED;
2315 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2317 while(!mTizenPolicy)
2319 wl_display_dispatch_queue(mDisplay, mEventQueue);
2324 while(!mNotificationLevelChangeDone && count < 3)
2326 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2327 wl_display_dispatch_queue(mDisplay, mEventQueue);
2331 if(!mNotificationLevelChangeDone)
2333 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2334 return Dali::WindowNotificationLevel::NONE;
2337 Dali::WindowNotificationLevel level;
2339 switch(mNotificationLevel)
2341 case TIZEN_POLICY_LEVEL_NONE:
2343 level = Dali::WindowNotificationLevel::NONE;
2346 case TIZEN_POLICY_LEVEL_DEFAULT:
2348 level = Dali::WindowNotificationLevel::BASE;
2351 case TIZEN_POLICY_LEVEL_MEDIUM:
2353 level = Dali::WindowNotificationLevel::MEDIUM;
2356 case TIZEN_POLICY_LEVEL_HIGH:
2358 level = Dali::WindowNotificationLevel::HIGH;
2361 case TIZEN_POLICY_LEVEL_TOP:
2363 level = Dali::WindowNotificationLevel::TOP;
2368 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2369 level = Dali::WindowNotificationLevel::NONE;
2374 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2379 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2381 while(!mTizenPolicy)
2383 wl_display_dispatch_queue(mDisplay, mEventQueue);
2386 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2389 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2391 while(!mTizenPolicy)
2393 wl_display_dispatch_queue(mDisplay, mEventQueue);
2396 mScreenOffModeChangeDone = false;
2397 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2399 unsigned int mode = 0;
2401 switch(screenOffMode)
2403 case WindowScreenOffMode::TIMEOUT:
2408 case WindowScreenOffMode::NEVER:
2415 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2419 while(!mScreenOffModeChangeDone && count < 3)
2421 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2422 wl_display_dispatch_queue(mDisplay, mEventQueue);
2426 if(!mScreenOffModeChangeDone)
2428 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2429 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2431 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2433 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2434 return Dali::WindowOperationResult::PERMISSION_DENIED;
2437 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2439 return Dali::WindowOperationResult::SUCCEED;
2442 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2444 while(!mTizenPolicy)
2446 wl_display_dispatch_queue(mDisplay, mEventQueue);
2451 while(!mScreenOffModeChangeDone && count < 3)
2453 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2454 wl_display_dispatch_queue(mDisplay, mEventQueue);
2458 if(!mScreenOffModeChangeDone)
2460 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2461 return WindowScreenOffMode::TIMEOUT;
2464 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2466 switch(mScreenOffMode)
2470 screenMode = WindowScreenOffMode::TIMEOUT;
2475 screenMode = WindowScreenOffMode::NEVER;
2480 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2485 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2487 while(!mTizenDisplayPolicy)
2489 wl_display_dispatch_queue(mDisplay, mEventQueue);
2492 mBrightnessChangeDone = false;
2493 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2495 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2499 while(!mBrightnessChangeDone && count < 3)
2501 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2502 wl_display_dispatch_queue(mDisplay, mEventQueue);
2506 if(!mBrightnessChangeDone)
2508 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2509 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2511 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2513 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2514 return Dali::WindowOperationResult::PERMISSION_DENIED;
2517 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2519 return Dali::WindowOperationResult::SUCCEED;
2522 int WindowBaseEcoreWl2::GetBrightness() const
2524 while(!mTizenDisplayPolicy)
2526 wl_display_dispatch_queue(mDisplay, mEventQueue);
2531 while(!mBrightnessChangeDone && count < 3)
2533 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2534 wl_display_dispatch_queue(mDisplay, mEventQueue);
2538 if(!mBrightnessChangeDone)
2540 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2544 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2549 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2551 Ecore_Wl2_Window_Keygrab_Mode mode;
2555 case KeyGrab::TOPMOST:
2557 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2560 case KeyGrab::SHARED:
2562 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2565 case KeyGrab::OVERRIDE_EXCLUSIVE:
2567 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2570 case KeyGrab::EXCLUSIVE:
2572 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2581 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2584 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2586 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2589 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2591 int keyCount = key.Count();
2592 int keyGrabModeCount = grabMode.Count();
2594 if(keyCount != keyGrabModeCount || keyCount == 0)
2601 Eina_List* keyList = NULL;
2602 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2604 for(int index = 0; index < keyCount; ++index)
2606 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2608 switch(grabMode[index])
2610 case KeyGrab::TOPMOST:
2612 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2615 case KeyGrab::SHARED:
2617 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2620 case KeyGrab::OVERRIDE_EXCLUSIVE:
2622 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2625 case KeyGrab::EXCLUSIVE:
2627 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2632 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2637 keyList = eina_list_append(keyList, &info);
2640 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
2642 result.Resize(keyCount, true);
2644 Eina_List* l = NULL;
2645 Eina_List* m = NULL;
2646 void* listData = NULL;
2648 if(grabList != NULL)
2650 EINA_LIST_FOREACH(grabList, m, data)
2653 EINA_LIST_FOREACH(keyList, l, listData)
2655 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
2657 DALI_LOG_ERROR("input key list has null data!");
2661 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2663 result[index] = false;
2672 eina_list_free(keyList);
2673 eina_list_free(grabList);
2679 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
2681 int keyCount = key.Count();
2689 Eina_List* keyList = NULL;
2690 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2692 for(int index = 0; index < keyCount; ++index)
2694 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2695 keyList = eina_list_append(keyList, &info);
2698 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
2700 result.Resize(keyCount, true);
2702 Eina_List* l = NULL;
2703 Eina_List* m = NULL;
2704 void* listData = NULL;
2707 if(ungrabList != NULL)
2709 EINA_LIST_FOREACH(ungrabList, m, data)
2712 EINA_LIST_FOREACH(keyList, l, listData)
2714 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2716 result[index] = false;
2725 eina_list_free(keyList);
2726 eina_list_free(ungrabList);
2732 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2737 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
2739 // 1 inch = 25.4 millimeters
2740 xres = ecore_wl2_output_dpi_get(output);
2741 yres = ecore_wl2_output_dpi_get(output);
2743 dpiHorizontal = int(xres + 0.5f); // rounding
2744 dpiVertical = int(yres + 0.5f);
2747 int WindowBaseEcoreWl2::GetWindowRotationAngle() const
2749 int orientation = mWindowRotationAngle;
2750 if(mSupportedPreProtation)
2757 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2759 if(mSupportedPreProtation)
2761 DALI_LOG_RELEASE_INFO("Support PreRotation and return 0\n");
2765 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
2771 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
2773 mScreenRotationAngle = transform * 90;
2774 return mScreenRotationAngle;
2777 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
2779 mWindowRotationAngle = degree;
2780 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
2783 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
2785 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
2788 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
2790 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
2793 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
2795 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
2798 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
2801 ecore_wl2_display_sync(display);
2803 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2805 if(mEcoreWindow == 0)
2807 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2811 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
2814 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
2816 Ecore_Wl2_Window* ecoreParent = NULL;
2819 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
2820 ecoreParent = winBaseEcore2->mEcoreWindow;
2822 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
2825 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2827 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
2830 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2832 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
2835 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2837 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);
2838 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2841 void WindowBaseEcoreWl2::InitializeIme()
2843 Eina_Iterator* globals;
2844 struct wl_registry* registry;
2845 Ecore_Wl2_Global* global;
2846 Ecore_Wl2_Display* ecoreWl2Display;
2848 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
2850 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
2854 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p\n", ecoreWl2Display, mEcoreWindow);
2856 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
2858 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
2862 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
2864 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
2868 EINA_ITERATOR_FOREACH(globals, global)
2870 #ifdef OVER_TIZEN_VERSION_7
2871 if(strcmp(global->interface, "zwp_input_panel_v1") == 0)
2873 mWlInputPanel = (zwp_input_panel_v1*)wl_registry_bind(registry, global->id, &zwp_input_panel_v1_interface, 1);
2876 if(strcmp(global->interface, "wl_input_panel") == 0)
2878 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
2881 else if(strcmp(global->interface, "wl_output") == 0)
2883 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
2889 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
2895 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
2898 #ifdef OVER_TIZEN_VERSION_7
2899 mWlInputPanelSurface = zwp_input_panel_v1_get_input_panel_surface(mWlInputPanel, mWlSurface);
2901 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
2903 if(!mWlInputPanelSurface)
2905 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
2908 #ifdef OVER_TIZEN_VERSION_7
2909 zwp_input_panel_surface_v1_set_toplevel(mWlInputPanelSurface, mWlOutput, ZWP_INPUT_PANEL_SURFACE_V1_POSITION_CENTER_BOTTOM);
2911 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
2915 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
2917 if(!mWlInputPanelSurface)
2919 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
2922 #ifdef OVER_TIZEN_VERSION_7
2923 zwp_input_panel_surface_v1_set_ready(mWlInputPanelSurface, 1);
2925 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
2929 void WindowBaseEcoreWl2::RequestMoveToServer()
2931 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
2934 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
2938 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
2941 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
2945 ecore_wl2_window_move(mEcoreWindow, input);
2946 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
2949 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
2951 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
2954 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
2958 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
2961 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
2965 ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
2967 ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
2968 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);
2971 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
2973 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
2976 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
2980 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
2984 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
2986 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
2989 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
2991 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
2992 Eina_Rectangle rect;
2994 rect.x = convertRegion.x;
2995 rect.y = convertRegion.y;
2996 rect.w = convertRegion.width;
2997 rect.h = convertRegion.height;
2999 DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3000 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
3001 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3004 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
3006 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
3007 Eina_Rectangle rect;
3009 rect.x = convertRegion.x;
3010 rect.y = convertRegion.y;
3011 rect.w = convertRegion.width;
3012 rect.h = convertRegion.height;
3014 DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3015 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
3016 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3019 } // namespace Adaptor
3021 } // namespace Internal
3025 #pragma GCC diagnostic pop