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 windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::OUT);
496 return ECORE_CALLBACK_PASS_ON;
500 * Called when a detent rotation event is recevied.
502 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
504 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
507 windowBase->OnDetentRotation(data, type, event);
509 return ECORE_CALLBACK_PASS_ON;
512 /////////////////////////////////////////////////////////////////////////////////////////////////
514 /////////////////////////////////////////////////////////////////////////////////////////////////
517 * Called when a key down is received.
519 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
521 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
524 windowBase->OnKeyDown(data, type, event);
526 return ECORE_CALLBACK_PASS_ON;
530 * Called when a key up is received.
532 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
534 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
537 windowBase->OnKeyUp(data, type, event);
539 return ECORE_CALLBACK_PASS_ON;
542 /////////////////////////////////////////////////////////////////////////////////////////////////
543 // Selection Callbacks
544 /////////////////////////////////////////////////////////////////////////////////////////////////
547 * Called when the source window notifies us the content in clipboard is selected.
549 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
551 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
554 windowBase->OnDataSend(data, type, event);
556 return ECORE_CALLBACK_PASS_ON;
560 * Called when the source window sends us about the selected content.
561 * For example, when item is selected in the clipboard.
563 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
565 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
568 windowBase->OnDataReceive(data, type, event);
570 return ECORE_CALLBACK_PASS_ON;
573 /////////////////////////////////////////////////////////////////////////////////////////////////
574 // Effect Start/End Callbacks
575 /////////////////////////////////////////////////////////////////////////////////////////////////
578 * Called when transition animation of the window's shown/hidden is started by window manager.
580 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
582 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
583 Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
584 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
587 if(effectStart->type < 3) // only under restack
589 windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
592 return ECORE_CALLBACK_PASS_ON;
596 * Called when transition animation of the window's shown/hidden is ended by window manager.
598 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
600 Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
601 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
602 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
605 if(effectEnd->type < 3) // only under restack
607 windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
610 return ECORE_CALLBACK_PASS_ON;
613 /////////////////////////////////////////////////////////////////////////////////////////////////
614 // Keyboard Repeat Settings Changed Callbacks
615 /////////////////////////////////////////////////////////////////////////////////////////////////
617 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
619 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
620 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event)->id);
623 windowBase->OnKeyboardRepeatSettingsChanged();
626 return ECORE_CALLBACK_RENEW;
629 /////////////////////////////////////////////////////////////////////////////////////////////////
630 // Keymap Changed Callbacks
631 /////////////////////////////////////////////////////////////////////////////////////////////////
633 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
635 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
638 windowBase->KeymapChanged(data, type, event);
641 return ECORE_CALLBACK_RENEW;
644 /////////////////////////////////////////////////////////////////////////////////////////////////
646 /////////////////////////////////////////////////////////////////////////////////////////////////
648 #if defined(VCONF_ENABLED)
650 * Called when a font name is changed.
652 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
654 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
657 windowBase->OnFontNameChanged();
662 * Called when a font size is changed.
664 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
666 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
669 windowBase->OnFontSizeChanged();
674 /////////////////////////////////////////////////////////////////////////////////////////////////
675 // Window Redraw Request Event Callbacks
676 /////////////////////////////////////////////////////////////////////////////////////////////////
678 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
680 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
681 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event)->win);
684 windowBase->OnEcoreEventWindowRedrawRequest();
687 return ECORE_CALLBACK_RENEW;
690 /////////////////////////////////////////////////////////////////////////////////////////////////
691 // Window Auxiliary Message Callbacks
692 /////////////////////////////////////////////////////////////////////////////////////////////////
693 static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* event)
695 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
698 windowBase->OnEcoreEventWindowAuxiliaryMessage(event);
700 return ECORE_CALLBACK_RENEW;
703 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
705 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
708 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
712 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
714 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
717 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
721 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
725 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)
729 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
731 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
734 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
738 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
742 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
744 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
747 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
751 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
755 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
759 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
763 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
767 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)
771 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
773 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
776 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
780 const struct wl_registry_listener registryListener =
782 RegistryGlobalCallback,
783 RegistryGlobalCallbackRemove};
785 const struct tizen_policy_listener tizenPolicyListener =
787 TizenPolicyConformant,
788 TizenPolicyConformantArea,
789 TizenPolicyNotificationChangeDone,
790 TizenPolicyTransientForDone,
791 TizenPolicyScreenModeChangeDone,
792 TizenPolicyIconifyStateChanged,
793 TizenPolicySupportedAuxiliaryHints,
794 TizenPolicyAllowedAuxiliaryHint,
795 TizenPolicyAuxiliaryMessage,
796 TizenPolicyConformantRegion};
798 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
800 DisplayPolicyBrightnessChangeDone};
802 } // unnamed namespace
804 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
805 : mEcoreEventHandler(),
806 mEcoreWindow(nullptr),
808 mWlInputPanel(nullptr),
810 mWlInputPanelSurface(nullptr),
813 mEventQueue(nullptr),
814 mTizenPolicy(nullptr),
815 mTizenDisplayPolicy(nullptr),
817 mSupportedAuxiliaryHints(),
818 mWindowPositionSize(positionSize),
820 mType(WindowType::NORMAL),
821 mNotificationLevel(-1),
824 mWindowRotationAngle(0),
825 mScreenRotationAngle(0),
826 mSupportedPreProtation(0),
827 mNotificationChangeState(0),
828 mScreenOffModeChangeState(0),
829 mBrightnessChangeState(0),
830 mLastSubmittedMoveResizeSerial(0),
831 mMoveResizeSerial(0),
832 mNotificationLevelChangeDone(true),
833 mScreenOffModeChangeDone(true),
836 mBrightnessChangeDone(true)
838 Initialize(positionSize, surface, isTransparent);
841 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
843 #if defined(VCONF_ENABLED)
844 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
845 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
848 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
850 ecore_event_handler_del(*iter);
852 mEcoreEventHandler.Clear();
856 wl_event_queue_destroy(mEventQueue);
859 mSupportedAuxiliaryHints.clear();
860 mAuxiliaryHints.clear();
862 if(mEglWindow != NULL)
864 wl_egl_window_destroy(mEglWindow);
870 ecore_wl2_window_free(mEcoreWindow);
874 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
876 if(surface.Empty() == false)
878 // check we have a valid type
879 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
881 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
885 // we own the surface about to created
887 CreateWindow(positionSize);
890 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
892 SetTransparency(isTransparent);
894 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
895 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
896 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
897 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
898 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
900 // Register Rotate event
901 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
903 // Register Configure event
904 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
906 // Register Touch events
907 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
908 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
909 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
910 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
912 // Register Mouse wheel events
913 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
915 // Register Mouse IO events
916 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
917 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
919 // Register Detent event
920 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
922 // Register Key events
923 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
924 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
926 // Register Selection event - clipboard selection
927 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
928 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
930 // Register Effect Start/End event
931 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
932 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
934 // Register Keyboard repeat event
935 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
937 // Register Window redraw request event
938 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
940 // Register Window auxiliary event
941 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
943 #if defined(VCONF_ENABLED)
944 // Register Vconf notify - font name and size
945 vconf_notify_key_changed_for_ui_thread(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
946 vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
949 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
950 mDisplay = ecore_wl2_display_get(display);
954 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
957 mEventQueue = wl_display_create_queue(mDisplay);
960 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
962 wl_registry* registry = wl_display_get_registry(displayWrapper);
963 wl_registry_add_listener(registry, ®istryListener, this);
966 wl_proxy_wrapper_destroy(displayWrapper);
970 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
974 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
976 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
979 // get auxiliary hint
980 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
986 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))))
988 mSupportedAuxiliaryHints.push_back(hint);
990 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
995 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
997 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
998 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
1000 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1002 if(iconifyChangedEvent->iconified == EINA_TRUE)
1004 mIconifyChangedSignal.Emit(true);
1008 mIconifyChangedSignal.Emit(false);
1010 handled = ECORE_CALLBACK_DONE;
1016 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
1018 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
1020 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1022 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
1024 mFocusChangedSignal.Emit(true);
1027 return ECORE_CALLBACK_PASS_ON;
1030 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
1032 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
1034 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1036 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
1038 mFocusChangedSignal.Emit(false);
1041 return ECORE_CALLBACK_PASS_ON;
1044 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
1046 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
1048 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
1050 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
1052 mScreenRotationAngle = GetScreenRotationAngle();
1054 mOutputTransformedSignal.Emit();
1057 return ECORE_CALLBACK_PASS_ON;
1060 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
1062 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
1064 if(ignoreTransformEvent->win == mEcoreWindow)
1066 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
1068 mScreenRotationAngle = GetScreenRotationAngle();
1070 mOutputTransformedSignal.Emit();
1073 return ECORE_CALLBACK_PASS_ON;
1076 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
1078 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
1080 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1082 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
1084 RotationEvent rotationEvent;
1085 rotationEvent.angle = ev->angle;
1086 rotationEvent.winResize = 0;
1088 if(ev->w == 0 || ev->h == 0)
1090 // When rotation event does not have the window width or height,
1091 // previous DALi side window's size are used.
1092 ev->w = mWindowPositionSize.width;
1093 ev->h = mWindowPositionSize.height;
1096 mWindowRotationAngle = ev->angle;
1098 mWindowPositionSize.width = ev->w;
1099 mWindowPositionSize.height = ev->h;
1101 PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1103 rotationEvent.x = newPositionSize.x;
1104 rotationEvent.y = newPositionSize.y;
1105 rotationEvent.width = newPositionSize.width;
1106 rotationEvent.height = newPositionSize.height;
1108 mRotationSignal.Emit(rotationEvent);
1112 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1114 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1116 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1118 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1119 // by calling ecore_wl2_window_commit
1121 int tempWidth = ev->w;
1122 int tempHeight = ev->h;
1124 // Initialize with previous size for skip resize when new size is 0.
1125 // When window is just moved or window is resized by client application,
1126 // The configure notification event's size will be 0.
1127 // If new size is 0, the resized work should be skip.
1128 int newWidth = mWindowPositionSize.width;
1129 int newHeight = mWindowPositionSize.height;
1130 bool windowMoved = false, windowResized = false;
1132 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1137 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1139 windowResized = true;
1140 newWidth = tempWidth;
1141 newHeight = tempHeight;
1144 if(windowMoved || windowResized)
1146 mWindowPositionSize.x = ev->x;
1147 mWindowPositionSize.y = ev->y;
1148 mWindowPositionSize.width = newWidth;
1149 mWindowPositionSize.height = newHeight;
1150 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);
1152 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1154 Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
1155 mUpdatePositionSizeSignal.Emit(newPositionSize);
1158 mMaximizeChangedSignal.Emit(static_cast<bool>(ev->states & ECORE_WL2_WINDOW_STATE_MAXIMIZED));
1160 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1164 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1166 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1168 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1170 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
1172 Device::Class::Type deviceClass;
1173 Device::Subclass::Type deviceSubclass;
1175 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1176 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1178 PointState::Type state(PointState::DOWN);
1180 if(deviceClass != Device::Class::Type::MOUSE)
1182 // Check if the buttons field is set and ensure it's the primary touch button.
1183 // If this event was triggered by buttons other than the primary button (used for touch), then
1184 // just send an interrupted event to Core.
1185 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1187 state = PointState::INTERRUPTED;
1191 Integration::Point point;
1192 point.SetDeviceId(touchEvent->multi.device);
1193 point.SetState(state);
1194 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1195 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1196 point.SetPressure(touchEvent->multi.pressure);
1197 point.SetAngle(Degree(touchEvent->multi.angle));
1198 point.SetDeviceClass(deviceClass);
1199 point.SetDeviceSubclass(deviceSubclass);
1200 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1202 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1206 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1208 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1210 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1212 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
1214 Device::Class::Type deviceClass;
1215 Device::Subclass::Type deviceSubclass;
1217 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1218 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1220 Integration::Point point;
1221 point.SetDeviceId(touchEvent->multi.device);
1222 point.SetState(PointState::UP);
1223 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1224 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1225 point.SetPressure(touchEvent->multi.pressure);
1226 point.SetAngle(Degree(touchEvent->multi.angle));
1227 point.SetDeviceClass(deviceClass);
1228 point.SetDeviceSubclass(deviceSubclass);
1229 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1231 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1235 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1237 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1239 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1241 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
1243 Device::Class::Type deviceClass;
1244 Device::Subclass::Type deviceSubclass;
1246 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1247 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1249 Integration::Point point;
1250 point.SetDeviceId(touchEvent->multi.device);
1251 point.SetState(PointState::MOTION);
1252 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1253 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1254 point.SetPressure(touchEvent->multi.pressure);
1255 point.SetAngle(Degree(touchEvent->multi.angle));
1256 point.SetDeviceClass(deviceClass);
1257 point.SetDeviceSubclass(deviceSubclass);
1259 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1263 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1265 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1267 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1269 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
1271 Integration::Point point;
1272 point.SetDeviceId(touchEvent->multi.device);
1273 point.SetState(PointState::INTERRUPTED);
1274 point.SetScreenPosition(Vector2(0.0f, 0.0f));
1276 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1278 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1282 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1284 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1286 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1288 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
1290 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);
1292 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1294 mWheelEventSignal.Emit(wheelEvent);
1298 void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
1300 Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
1302 if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1304 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
1306 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);
1308 Device::Class::Type deviceClass;
1309 Device::Subclass::Type deviceSubclass;
1311 GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
1312 GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
1314 Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
1316 mMouseInOutEventSignal.Emit(inOutEvent);
1320 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1322 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1324 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1326 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1328 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1330 mWheelEventSignal.Emit(wheelEvent);
1333 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1335 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1337 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1339 std::string keyName(keyEvent->keyname);
1340 std::string logicalKey("");
1341 std::string keyString("");
1342 std::string compose("");
1344 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_DOWN");
1346 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1347 if(keyEvent->compose)
1349 compose = keyEvent->compose;
1352 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1355 logicalKey = keyEvent->key;
1359 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1363 // Get a specific key code from dali key look up table.
1364 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1367 keyCode = (keyCode == -1) ? 0 : keyCode;
1368 int modifier(keyEvent->modifiers);
1369 unsigned long time = keyEvent->timestamp;
1370 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1372 keyCode = atoi(keyEvent->keyname + 8);
1375 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1376 if(keyEvent->string)
1378 keyString = keyEvent->string;
1381 std::string deviceName;
1382 Device::Class::Type deviceClass;
1383 Device::Subclass::Type deviceSubclass;
1385 GetDeviceName(keyEvent, deviceName);
1386 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1387 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1389 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1391 mKeyEventSignal.Emit(keyEvent);
1395 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1397 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1399 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1401 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1402 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1403 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1405 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1408 #endif // Since ecore 1.23 version
1410 std::string keyName(keyEvent->keyname);
1411 std::string logicalKey("");
1412 std::string keyString("");
1413 std::string compose("");
1415 DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_UP");
1417 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1418 if(keyEvent->compose)
1420 compose = keyEvent->compose;
1423 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1426 logicalKey = keyEvent->key;
1430 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1434 // Get a specific key code from dali key look up table.
1435 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1438 keyCode = (keyCode == -1) ? 0 : keyCode;
1439 int modifier(keyEvent->modifiers);
1440 unsigned long time = keyEvent->timestamp;
1441 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1443 keyCode = atoi(keyEvent->keyname + 8);
1446 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1447 if(keyEvent->string)
1449 keyString = keyEvent->string;
1452 std::string deviceName;
1453 Device::Class::Type deviceClass;
1454 Device::Subclass::Type deviceSubclass;
1456 GetDeviceName(keyEvent, deviceName);
1457 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1458 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1460 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1462 mKeyEventSignal.Emit(keyEvent);
1466 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1468 mSelectionDataSendSignal.Emit(event);
1471 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1473 mSelectionDataReceivedSignal.Emit(event);
1476 void WindowBaseEcoreWl2::OnFontNameChanged()
1478 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1481 void WindowBaseEcoreWl2::OnFontSizeChanged()
1483 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1486 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1488 mTransitionEffectEventSignal.Emit(state, type);
1491 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1493 mKeyboardRepeatSettingsChangedSignal.Emit();
1496 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1498 mWindowRedrawRequestSignal.Emit();
1501 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1503 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1506 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
1507 std::string key(message->key);
1508 std::string value(message->val);
1509 Dali::Property::Array options;
1511 if(message->options)
1515 EINA_LIST_FOREACH(message->options, l, data)
1517 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
1518 std::string option(static_cast<char*>(data));
1519 options.Add(option);
1523 mAuxiliaryMessageSignal.Emit(key, value, options);
1527 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1529 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1530 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1531 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1534 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1538 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1540 if(strcmp(interface, tizen_policy_interface.name) == 0)
1542 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1544 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1547 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1551 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1553 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1555 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1557 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1558 if(!mTizenDisplayPolicy)
1560 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1564 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1566 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1570 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1572 mTizenPolicy = NULL;
1573 mTizenDisplayPolicy = NULL;
1576 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1578 mNotificationLevel = level;
1579 mNotificationChangeState = state;
1580 mNotificationLevelChangeDone = true;
1582 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1585 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1587 mScreenOffMode = mode;
1588 mScreenOffModeChangeState = state;
1589 mScreenOffModeChangeDone = true;
1591 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1594 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1596 mBrightness = brightness;
1597 mBrightnessChangeState = state;
1598 mBrightnessChangeDone = true;
1600 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1603 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1605 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1606 KeyCodeMap foundKeyCode;
1608 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1609 if(sym == XKB_KEY_NoSymbol)
1611 DALI_LOG_ERROR("Failed to get keysym in WindowBaseEcoreWl2\n");
1615 foundKeyCode.keySym = sym;
1616 foundKeyCode.isKeyCode = false;
1617 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1618 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1621 Any WindowBaseEcoreWl2::GetNativeWindow()
1623 return mEcoreWindow;
1626 int WindowBaseEcoreWl2::GetNativeWindowId()
1628 return ecore_wl2_window_id_get(mEcoreWindow);
1631 std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
1633 #ifdef OVER_TIZEN_VERSION_7
1634 return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
1636 return std::string();
1640 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1642 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1643 if(totalAngle == 90 || totalAngle == 270)
1645 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
1649 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1652 return static_cast<EGLNativeWindowType>(mEglWindow);
1655 void WindowBaseEcoreWl2::DestroyEglWindow()
1657 if(mEglWindow != NULL)
1659 wl_egl_window_destroy(mEglWindow);
1664 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
1666 wl_egl_window_tizen_rotation rotation;
1672 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1677 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1682 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1687 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1692 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1697 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
1700 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
1702 wl_output_transform bufferTransform;
1708 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1713 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1718 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1723 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1728 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1733 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_buffer_transform() with buffer Transform [%d]\n", bufferTransform);
1734 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
1737 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
1739 wl_output_transform windowTransform;
1745 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1750 windowTransform = WL_OUTPUT_TRANSFORM_90;
1755 windowTransform = WL_OUTPUT_TRANSFORM_180;
1760 windowTransform = WL_OUTPUT_TRANSFORM_270;
1765 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1770 DALI_LOG_RELEASE_INFO("wl_egl_window_tizen_set_window_transform() with window Transform [%d]\n", windowTransform);
1771 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
1774 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
1776 DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1777 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1779 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1780 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
1782 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
1783 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1787 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1790 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
1791 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
1793 mSupportedPreProtation = true;
1796 mSupportedPreProtation = false;
1800 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
1802 PositionSize newPositionSize;
1803 int32_t screenWidth, screenHeight;
1804 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1806 if(mWindowRotationAngle == 90)
1808 newPositionSize.x = positionSize.y;
1809 newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
1810 newPositionSize.width = positionSize.height;
1811 newPositionSize.height = positionSize.width;
1813 else if(mWindowRotationAngle == 180)
1815 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1816 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1817 newPositionSize.width = positionSize.width;
1818 newPositionSize.height = positionSize.height;
1820 else if(mWindowRotationAngle == 270)
1822 newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
1823 newPositionSize.y = positionSize.x;
1824 newPositionSize.width = positionSize.height;
1825 newPositionSize.height = positionSize.width;
1829 newPositionSize.x = positionSize.x;
1830 newPositionSize.y = positionSize.y;
1831 newPositionSize.width = positionSize.width;
1832 newPositionSize.height = positionSize.height;
1835 return newPositionSize;
1838 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
1840 PositionSize newPositionSize;
1841 int32_t screenWidth, screenHeight;
1842 WindowSystem::GetScreenSize(screenWidth, screenHeight);
1844 if(mWindowRotationAngle == 90)
1846 newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
1847 newPositionSize.y = positionSize.x;
1848 newPositionSize.width = positionSize.height;
1849 newPositionSize.height = positionSize.width;
1851 else if(mWindowRotationAngle == 180)
1853 newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
1854 newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
1855 newPositionSize.width = positionSize.width;
1856 newPositionSize.height = positionSize.height;
1858 else if(mWindowRotationAngle == 270)
1860 newPositionSize.x = positionSize.y;
1861 newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
1862 newPositionSize.width = positionSize.height;
1863 newPositionSize.height = positionSize.width;
1867 newPositionSize.x = positionSize.x;
1868 newPositionSize.y = positionSize.y;
1869 newPositionSize.width = positionSize.width;
1870 newPositionSize.height = positionSize.height;
1873 return newPositionSize;
1876 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
1878 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1880 mWindowPositionSize = newPositionSize;
1881 DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
1882 ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
1885 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
1887 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1889 mWindowPositionSize = newPositionSize;
1890 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);
1891 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1894 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
1896 PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
1898 mWindowPositionSize = newPositionSize;
1899 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);
1900 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
1903 void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
1905 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);
1906 ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
1909 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
1911 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
1912 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
1915 void WindowBaseEcoreWl2::Raise()
1917 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1918 ecore_wl2_window_activate(mEcoreWindow);
1921 void WindowBaseEcoreWl2::Lower()
1923 ecore_wl2_window_lower(mEcoreWindow);
1926 void WindowBaseEcoreWl2::Activate()
1928 ecore_wl2_window_activate(mEcoreWindow);
1931 void WindowBaseEcoreWl2::Maximize(bool maximize)
1933 ecore_wl2_window_maximized_set(mEcoreWindow, maximize);
1936 bool WindowBaseEcoreWl2::IsMaximized() const
1938 return ecore_wl2_window_maximized_get(mEcoreWindow);
1941 void WindowBaseEcoreWl2::SetMaximumSize(Dali::Window::WindowSize size)
1943 DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
1944 ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
1945 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
1948 void WindowBaseEcoreWl2::Minimize(bool minimize)
1950 ecore_wl2_window_iconified_set(mEcoreWindow, minimize);
1953 bool WindowBaseEcoreWl2::IsMinimized() const
1955 return ecore_wl2_window_iconified_get(mEcoreWindow);
1958 void WindowBaseEcoreWl2::SetMimimumSize(Dali::Window::WindowSize size)
1960 DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
1961 ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
1962 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
1965 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
1967 int rotations[4] = {0};
1968 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
1969 for(std::size_t i = 0; i < angles.size(); ++i)
1971 rotations[i] = static_cast<int>(angles[i]);
1972 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
1974 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
1977 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
1979 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
1980 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
1983 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
1985 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
1988 void WindowBaseEcoreWl2::Show()
1992 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1996 ecore_wl2_window_show(mEcoreWindow);
1999 void WindowBaseEcoreWl2::Hide()
2002 ecore_wl2_window_hide(mEcoreWindow);
2005 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
2007 return mSupportedAuxiliaryHints.size();
2010 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
2012 if(index >= GetSupportedAuxiliaryHintCount())
2014 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
2017 return mSupportedAuxiliaryHints[index];
2020 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
2022 bool supported = false;
2024 // Check if the hint is suppported
2025 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
2036 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
2040 // Check if the hint is already added
2041 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2043 if(mAuxiliaryHints[i].first == hint)
2045 // Just change the value
2046 mAuxiliaryHints[i].second = value;
2048 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
2050 return i + 1; // id is index + 1
2055 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
2057 unsigned int id = mAuxiliaryHints.size();
2059 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
2061 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
2066 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
2068 if(id == 0 || id > mAuxiliaryHints.size())
2070 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
2074 mAuxiliaryHints[id - 1].second = std::string();
2076 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
2078 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
2083 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
2085 if(id == 0 || id > mAuxiliaryHints.size())
2087 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
2091 mAuxiliaryHints[id - 1].second = value;
2093 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
2095 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());
2100 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
2102 if(id == 0 || id > mAuxiliaryHints.size())
2104 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
2105 return std::string();
2108 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());
2110 return mAuxiliaryHints[id - 1].second;
2113 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
2115 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
2117 if(mAuxiliaryHints[i].first == hint)
2119 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
2124 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
2129 Rect<int> WindowBaseEcoreWl2::RecalculateInputRect(const Rect<int>& rect)
2133 if(mWindowRotationAngle == 90)
2136 newRect.y = mWindowPositionSize.height - (rect.x + rect.width);
2137 newRect.width = rect.height;
2138 newRect.height = rect.width;
2140 else if(mWindowRotationAngle == 180)
2142 newRect.x = mWindowPositionSize.width - (rect.x + rect.width);
2143 newRect.y = mWindowPositionSize.height - (rect.y + rect.height);
2144 newRect.width = rect.width;
2145 newRect.height = rect.height;
2147 else if(mWindowRotationAngle == 270)
2149 newRect.x = mWindowPositionSize.width - (rect.y + rect.height);
2151 newRect.width = rect.height;
2152 newRect.height = rect.width;
2158 newRect.width = rect.width;
2159 newRect.height = rect.height;
2164 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
2166 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
2168 Eina_Rectangle rect;
2169 rect.x = convertRegion.x;
2170 rect.y = convertRegion.y;
2171 rect.w = convertRegion.width;
2172 rect.h = convertRegion.height;
2174 DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2175 ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
2176 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2179 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
2184 Ecore_Wl2_Window_Type windowType;
2188 case Dali::WindowType::NORMAL:
2190 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2193 case Dali::WindowType::NOTIFICATION:
2195 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
2198 case Dali::WindowType::UTILITY:
2200 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
2203 case Dali::WindowType::DIALOG:
2205 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
2208 case Dali::WindowType::IME:
2210 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
2213 case Dali::WindowType::DESKTOP:
2215 windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
2220 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
2224 ecore_wl2_window_type_set(mEcoreWindow, windowType);
2228 Dali::WindowType WindowBaseEcoreWl2::GetType() const
2233 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
2235 while(!mTizenPolicy)
2237 wl_display_dispatch_queue(mDisplay, mEventQueue);
2240 int notificationLevel;
2244 case Dali::WindowNotificationLevel::NONE:
2246 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
2249 case Dali::WindowNotificationLevel::BASE:
2251 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2254 case Dali::WindowNotificationLevel::MEDIUM:
2256 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
2259 case Dali::WindowNotificationLevel::HIGH:
2261 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
2264 case Dali::WindowNotificationLevel::TOP:
2266 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
2271 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
2272 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2277 mNotificationLevelChangeDone = false;
2278 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2280 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2284 while(!mNotificationLevelChangeDone && count < 3)
2286 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2287 wl_display_dispatch_queue(mDisplay, mEventQueue);
2291 if(!mNotificationLevelChangeDone)
2293 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2294 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2296 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2298 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2299 return Dali::WindowOperationResult::PERMISSION_DENIED;
2302 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2304 return Dali::WindowOperationResult::SUCCEED;
2307 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2309 while(!mTizenPolicy)
2311 wl_display_dispatch_queue(mDisplay, mEventQueue);
2316 while(!mNotificationLevelChangeDone && count < 3)
2318 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2319 wl_display_dispatch_queue(mDisplay, mEventQueue);
2323 if(!mNotificationLevelChangeDone)
2325 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2326 return Dali::WindowNotificationLevel::NONE;
2329 Dali::WindowNotificationLevel level;
2331 switch(mNotificationLevel)
2333 case TIZEN_POLICY_LEVEL_NONE:
2335 level = Dali::WindowNotificationLevel::NONE;
2338 case TIZEN_POLICY_LEVEL_DEFAULT:
2340 level = Dali::WindowNotificationLevel::BASE;
2343 case TIZEN_POLICY_LEVEL_MEDIUM:
2345 level = Dali::WindowNotificationLevel::MEDIUM;
2348 case TIZEN_POLICY_LEVEL_HIGH:
2350 level = Dali::WindowNotificationLevel::HIGH;
2353 case TIZEN_POLICY_LEVEL_TOP:
2355 level = Dali::WindowNotificationLevel::TOP;
2360 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2361 level = Dali::WindowNotificationLevel::NONE;
2366 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2371 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2373 while(!mTizenPolicy)
2375 wl_display_dispatch_queue(mDisplay, mEventQueue);
2378 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2381 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2383 while(!mTizenPolicy)
2385 wl_display_dispatch_queue(mDisplay, mEventQueue);
2388 mScreenOffModeChangeDone = false;
2389 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2391 unsigned int mode = 0;
2393 switch(screenOffMode)
2395 case WindowScreenOffMode::TIMEOUT:
2400 case WindowScreenOffMode::NEVER:
2407 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2411 while(!mScreenOffModeChangeDone && count < 3)
2413 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2414 wl_display_dispatch_queue(mDisplay, mEventQueue);
2418 if(!mScreenOffModeChangeDone)
2420 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2421 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2423 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2425 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2426 return Dali::WindowOperationResult::PERMISSION_DENIED;
2429 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2431 return Dali::WindowOperationResult::SUCCEED;
2434 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2436 while(!mTizenPolicy)
2438 wl_display_dispatch_queue(mDisplay, mEventQueue);
2443 while(!mScreenOffModeChangeDone && count < 3)
2445 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2446 wl_display_dispatch_queue(mDisplay, mEventQueue);
2450 if(!mScreenOffModeChangeDone)
2452 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2453 return WindowScreenOffMode::TIMEOUT;
2456 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2458 switch(mScreenOffMode)
2462 screenMode = WindowScreenOffMode::TIMEOUT;
2467 screenMode = WindowScreenOffMode::NEVER;
2472 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2477 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2479 while(!mTizenDisplayPolicy)
2481 wl_display_dispatch_queue(mDisplay, mEventQueue);
2484 mBrightnessChangeDone = false;
2485 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2487 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2491 while(!mBrightnessChangeDone && count < 3)
2493 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2494 wl_display_dispatch_queue(mDisplay, mEventQueue);
2498 if(!mBrightnessChangeDone)
2500 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2501 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2503 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2505 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2506 return Dali::WindowOperationResult::PERMISSION_DENIED;
2509 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2511 return Dali::WindowOperationResult::SUCCEED;
2514 int WindowBaseEcoreWl2::GetBrightness() const
2516 while(!mTizenDisplayPolicy)
2518 wl_display_dispatch_queue(mDisplay, mEventQueue);
2523 while(!mBrightnessChangeDone && count < 3)
2525 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2526 wl_display_dispatch_queue(mDisplay, mEventQueue);
2530 if(!mBrightnessChangeDone)
2532 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2536 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2541 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2543 Ecore_Wl2_Window_Keygrab_Mode mode;
2547 case KeyGrab::TOPMOST:
2549 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2552 case KeyGrab::SHARED:
2554 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2557 case KeyGrab::OVERRIDE_EXCLUSIVE:
2559 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2562 case KeyGrab::EXCLUSIVE:
2564 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2573 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2576 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2578 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2581 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2583 int keyCount = key.Count();
2584 int keyGrabModeCount = grabMode.Count();
2586 if(keyCount != keyGrabModeCount || keyCount == 0)
2593 Eina_List* keyList = NULL;
2594 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2596 for(int index = 0; index < keyCount; ++index)
2598 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2600 switch(grabMode[index])
2602 case KeyGrab::TOPMOST:
2604 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2607 case KeyGrab::SHARED:
2609 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2612 case KeyGrab::OVERRIDE_EXCLUSIVE:
2614 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2617 case KeyGrab::EXCLUSIVE:
2619 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2624 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2629 keyList = eina_list_append(keyList, &info);
2632 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
2634 result.Resize(keyCount, true);
2636 Eina_List* l = NULL;
2637 Eina_List* m = NULL;
2638 void* listData = NULL;
2640 if(grabList != NULL)
2642 EINA_LIST_FOREACH(grabList, m, data)
2645 EINA_LIST_FOREACH(keyList, l, listData)
2647 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
2649 DALI_LOG_ERROR("input key list has null data!");
2653 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2655 result[index] = false;
2664 eina_list_free(keyList);
2665 eina_list_free(grabList);
2671 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
2673 int keyCount = key.Count();
2681 Eina_List* keyList = NULL;
2682 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2684 for(int index = 0; index < keyCount; ++index)
2686 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2687 keyList = eina_list_append(keyList, &info);
2690 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
2692 result.Resize(keyCount, true);
2694 Eina_List* l = NULL;
2695 Eina_List* m = NULL;
2696 void* listData = NULL;
2699 if(ungrabList != NULL)
2701 EINA_LIST_FOREACH(ungrabList, m, data)
2704 EINA_LIST_FOREACH(keyList, l, listData)
2706 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2708 result[index] = false;
2717 eina_list_free(keyList);
2718 eina_list_free(ungrabList);
2724 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2729 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
2731 // 1 inch = 25.4 millimeters
2732 xres = ecore_wl2_output_dpi_get(output);
2733 yres = ecore_wl2_output_dpi_get(output);
2735 dpiHorizontal = int(xres + 0.5f); // rounding
2736 dpiVertical = int(yres + 0.5f);
2739 int WindowBaseEcoreWl2::GetWindowRotationAngle() const
2741 int orientation = mWindowRotationAngle;
2742 if(mSupportedPreProtation)
2749 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2751 if(mSupportedPreProtation)
2753 DALI_LOG_RELEASE_INFO("Support PreRotation and return 0\n");
2757 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
2763 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
2765 mScreenRotationAngle = transform * 90;
2766 return mScreenRotationAngle;
2769 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
2771 mWindowRotationAngle = degree;
2772 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
2775 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
2777 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
2780 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
2782 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
2785 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
2787 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
2790 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
2793 ecore_wl2_display_sync(display);
2795 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2797 if(mEcoreWindow == 0)
2799 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2803 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
2806 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
2808 Ecore_Wl2_Window* ecoreParent = NULL;
2811 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
2812 ecoreParent = winBaseEcore2->mEcoreWindow;
2814 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
2817 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2819 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
2822 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2824 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
2827 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2829 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);
2830 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2833 void WindowBaseEcoreWl2::InitializeIme()
2835 Eina_Iterator* globals;
2836 struct wl_registry* registry;
2837 Ecore_Wl2_Global* global;
2838 Ecore_Wl2_Display* ecoreWl2Display;
2840 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
2842 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
2846 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p\n", ecoreWl2Display, mEcoreWindow);
2848 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
2850 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
2854 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
2856 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
2860 EINA_ITERATOR_FOREACH(globals, global)
2862 #ifdef OVER_TIZEN_VERSION_7
2863 if(strcmp(global->interface, "zwp_input_panel_v1") == 0)
2865 mWlInputPanel = (zwp_input_panel_v1*)wl_registry_bind(registry, global->id, &zwp_input_panel_v1_interface, 1);
2868 if(strcmp(global->interface, "wl_input_panel") == 0)
2870 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
2873 else if(strcmp(global->interface, "wl_output") == 0)
2875 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
2881 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
2887 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
2890 #ifdef OVER_TIZEN_VERSION_7
2891 mWlInputPanelSurface = zwp_input_panel_v1_get_input_panel_surface(mWlInputPanel, mWlSurface);
2893 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
2895 if(!mWlInputPanelSurface)
2897 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
2900 #ifdef OVER_TIZEN_VERSION_7
2901 zwp_input_panel_surface_v1_set_toplevel(mWlInputPanelSurface, mWlOutput, ZWP_INPUT_PANEL_SURFACE_V1_POSITION_CENTER_BOTTOM);
2903 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
2907 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
2909 if(!mWlInputPanelSurface)
2911 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
2914 #ifdef OVER_TIZEN_VERSION_7
2915 zwp_input_panel_surface_v1_set_ready(mWlInputPanelSurface, 1);
2917 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
2921 void WindowBaseEcoreWl2::RequestMoveToServer()
2923 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
2926 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
2930 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
2933 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
2937 ecore_wl2_window_move(mEcoreWindow, input);
2938 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
2941 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
2943 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
2946 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
2950 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
2953 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
2957 ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
2959 ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
2960 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);
2963 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
2965 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
2968 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
2972 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
2976 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
2978 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
2981 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
2983 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
2984 Eina_Rectangle rect;
2986 rect.x = convertRegion.x;
2987 rect.y = convertRegion.y;
2988 rect.w = convertRegion.width;
2989 rect.h = convertRegion.height;
2991 DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
2992 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
2993 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2996 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
2998 Rect<int> convertRegion = RecalculateInputRect(inputRegion);
2999 Eina_Rectangle rect;
3001 rect.x = convertRegion.x;
3002 rect.y = convertRegion.y;
3003 rect.w = convertRegion.width;
3004 rect.h = convertRegion.height;
3006 DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
3007 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
3008 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
3011 } // namespace Adaptor
3013 } // namespace Internal
3017 #pragma GCC diagnostic pop