2 * Copyright (c) 2021 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/public-api/adaptor-framework/window-enumerations.h>
35 #include <dali/public-api/events/mouse-button.h>
36 #include <dali/public-api/object/any.h>
37 #include <vconf-keys.h>
39 #include <wayland-egl-tizen.h>
49 #if defined(DEBUG_ENABLED)
50 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
53 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
54 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
56 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
58 #ifdef DALI_ELDBUS_AVAILABLE
60 const char* BUS = "org.enlightenment.wm-screen-reader";
61 const char* INTERFACE = "org.tizen.GestureNavigation";
62 const char* PATH = "/org/tizen/GestureNavigation";
63 #endif // DALI_ELDBUS_AVAILABLE
68 xkb_keycode_t keyCode;
73 * Get the device name from the provided ecore key event
75 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
77 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
81 result = ecoreDeviceName;
86 * Get the device class from the provided ecore event
88 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
90 switch(ecoreDeviceClass)
92 case ECORE_DEVICE_CLASS_SEAT:
94 deviceClass = Device::Class::USER;
97 case ECORE_DEVICE_CLASS_KEYBOARD:
99 deviceClass = Device::Class::KEYBOARD;
102 case ECORE_DEVICE_CLASS_MOUSE:
104 deviceClass = Device::Class::MOUSE;
107 case ECORE_DEVICE_CLASS_TOUCH:
109 deviceClass = Device::Class::TOUCH;
112 case ECORE_DEVICE_CLASS_PEN:
114 deviceClass = Device::Class::PEN;
117 case ECORE_DEVICE_CLASS_POINTER:
119 deviceClass = Device::Class::POINTER;
122 case ECORE_DEVICE_CLASS_GAMEPAD:
124 deviceClass = Device::Class::GAMEPAD;
129 deviceClass = Device::Class::NONE;
135 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
137 switch(ecoreDeviceSubclass)
139 case ECORE_DEVICE_SUBCLASS_FINGER:
141 deviceSubclass = Device::Subclass::FINGER;
144 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
146 deviceSubclass = Device::Subclass::FINGERNAIL;
149 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
151 deviceSubclass = Device::Subclass::KNUCKLE;
154 case ECORE_DEVICE_SUBCLASS_PALM:
156 deviceSubclass = Device::Subclass::PALM;
159 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
161 deviceSubclass = Device::Subclass::HAND_SIDE;
164 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
166 deviceSubclass = Device::Subclass::HAND_FLAT;
169 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
171 deviceSubclass = Device::Subclass::PEN_TIP;
174 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
176 deviceSubclass = Device::Subclass::TRACKPAD;
179 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
181 deviceSubclass = Device::Subclass::TRACKPOINT;
184 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
186 deviceSubclass = Device::Subclass::TRACKBALL;
189 case ECORE_DEVICE_SUBCLASS_REMOCON:
191 deviceSubclass = Device::Subclass::REMOCON;
194 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
196 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
201 deviceSubclass = Device::Subclass::NONE;
207 void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
209 KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
210 if(foundKeyCode->isKeyCode)
215 xkb_keysym_t keySym = foundKeyCode->keySym;
217 const xkb_keysym_t* symsOut = NULL;
219 nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
223 if(*symsOut == keySym)
225 foundKeyCode->keyCode = key;
226 foundKeyCode->isKeyCode = true;
231 /////////////////////////////////////////////////////////////////////////////////////////////////
233 /////////////////////////////////////////////////////////////////////////////////////////////////
235 /// Called when the window iconify state is changed.
236 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
238 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
241 return windowBase->OnIconifyStateChanged(data, type, event);
244 return ECORE_CALLBACK_PASS_ON;
247 /// Called when the window gains focus
248 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
250 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
253 return windowBase->OnFocusIn(data, type, event);
256 return ECORE_CALLBACK_PASS_ON;
259 /// Called when the window loses focus
260 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
262 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
265 return windowBase->OnFocusOut(data, type, event);
268 return ECORE_CALLBACK_PASS_ON;
271 /// Called when the output is transformed
272 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
274 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
277 return windowBase->OnOutputTransform(data, type, event);
280 return ECORE_CALLBACK_PASS_ON;
283 /// Called when the output transform should be ignored
284 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
286 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
289 return windowBase->OnIgnoreOutputTransform(data, type, event);
292 return ECORE_CALLBACK_PASS_ON;
296 * Called when rotate event is recevied.
298 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
300 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
303 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
304 windowBase->OnRotation(data, type, event);
306 return ECORE_CALLBACK_PASS_ON;
310 * Called when configure event is recevied.
312 static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
314 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
317 windowBase->OnConfiguration(data, type, event);
319 return ECORE_CALLBACK_PASS_ON;
322 /////////////////////////////////////////////////////////////////////////////////////////////////
324 /////////////////////////////////////////////////////////////////////////////////////////////////
327 * Called when a touch down is received.
329 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
331 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
334 windowBase->OnMouseButtonDown(data, type, event);
336 return ECORE_CALLBACK_PASS_ON;
340 * Called when a touch up is received.
342 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
344 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
347 windowBase->OnMouseButtonUp(data, type, event);
349 return ECORE_CALLBACK_PASS_ON;
353 * Called when a touch motion is received.
355 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
357 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
360 windowBase->OnMouseButtonMove(data, type, event);
362 return ECORE_CALLBACK_PASS_ON;
366 * Called when a touch is canceled.
368 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
370 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
373 windowBase->OnMouseButtonCancel(data, type, event);
375 return ECORE_CALLBACK_PASS_ON;
379 * Called when a mouse wheel is received.
381 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
383 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
386 windowBase->OnMouseWheel(data, type, event);
388 return ECORE_CALLBACK_PASS_ON;
392 * Called when a detent rotation event is recevied.
394 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
396 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
399 windowBase->OnDetentRotation(data, type, event);
401 return ECORE_CALLBACK_PASS_ON;
404 /////////////////////////////////////////////////////////////////////////////////////////////////
406 /////////////////////////////////////////////////////////////////////////////////////////////////
409 * Called when a key down is received.
411 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
413 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
416 windowBase->OnKeyDown(data, type, event);
418 return ECORE_CALLBACK_PASS_ON;
422 * Called when a key up is received.
424 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
426 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
429 windowBase->OnKeyUp(data, type, event);
431 return ECORE_CALLBACK_PASS_ON;
434 /////////////////////////////////////////////////////////////////////////////////////////////////
435 // Selection Callbacks
436 /////////////////////////////////////////////////////////////////////////////////////////////////
439 * Called when the source window notifies us the content in clipboard is selected.
441 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
443 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
446 windowBase->OnDataSend(data, type, event);
448 return ECORE_CALLBACK_PASS_ON;
452 * Called when the source window sends us about the selected content.
453 * For example, when item is selected in the clipboard.
455 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
457 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
460 windowBase->OnDataReceive(data, type, event);
462 return ECORE_CALLBACK_PASS_ON;
465 /////////////////////////////////////////////////////////////////////////////////////////////////
466 // Effect Start/End Callbacks
467 /////////////////////////////////////////////////////////////////////////////////////////////////
470 * Called when transition animation of the window's shown/hidden is started by window manager.
472 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
474 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
475 Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
476 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
479 if(effectStart->type < 3) // only under restack
481 windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
484 return ECORE_CALLBACK_PASS_ON;
488 * Called when transition animation of the window's shown/hidden is ended by window manager.
490 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
492 Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
493 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
494 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
497 if(effectEnd->type < 3) // only under restack
499 windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
502 return ECORE_CALLBACK_PASS_ON;
505 /////////////////////////////////////////////////////////////////////////////////////////////////
506 // Keyboard Repeat Settings Changed Callbacks
507 /////////////////////////////////////////////////////////////////////////////////////////////////
509 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
511 Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed* keyboardRepeat = static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event);
512 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
513 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", keyboardRepeat->id);
516 windowBase->OnKeyboardRepeatSettingsChanged();
519 return ECORE_CALLBACK_RENEW;
522 /////////////////////////////////////////////////////////////////////////////////////////////////
523 // Keymap Changed Callbacks
524 /////////////////////////////////////////////////////////////////////////////////////////////////
526 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
528 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
531 windowBase->KeymapChanged(data, type, event);
534 return ECORE_CALLBACK_RENEW;
537 /////////////////////////////////////////////////////////////////////////////////////////////////
539 /////////////////////////////////////////////////////////////////////////////////////////////////
542 * Called when a font name is changed.
544 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
546 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
549 windowBase->OnFontNameChanged();
554 * Called when a font size is changed.
556 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
558 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
561 windowBase->OnFontSizeChanged();
565 /////////////////////////////////////////////////////////////////////////////////////////////////
566 // Window Redraw Request Event Callbacks
567 /////////////////////////////////////////////////////////////////////////////////////////////////
569 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
571 Ecore_Wl2_Event_Window_Redraw_Request* windowRedrawRequest = static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event);
572 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
573 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", windowRedrawRequest->win);
576 windowBase->OnEcoreEventWindowRedrawRequest();
579 return ECORE_CALLBACK_RENEW;
582 /////////////////////////////////////////////////////////////////////////////////////////////////
583 // Window Auxiliary Message Callbacks
584 /////////////////////////////////////////////////////////////////////////////////////////////////
585 static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* event)
587 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
590 windowBase->OnEcoreEventWindowAuxiliaryMessage(event);
592 return ECORE_CALLBACK_RENEW;
595 /////////////////////////////////////////////////////////////////////////////////////////////////
596 // ElDBus Accessibility Callbacks
597 /////////////////////////////////////////////////////////////////////////////////////////////////
599 #ifdef DALI_ELDBUS_AVAILABLE
600 // Callback for Ecore ElDBus accessibility events.
601 static void EcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
603 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(context);
606 windowBase->OnEcoreElDBusAccessibilityNotification(context, message);
609 #endif // DALI_ELDBUS_AVAILABLE
611 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
613 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
616 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
620 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
622 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
625 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
629 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
633 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)
637 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
639 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
642 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
646 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
650 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
652 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
655 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
659 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
663 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
667 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
671 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
675 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)
679 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
681 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
684 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
688 const struct wl_registry_listener registryListener =
690 RegistryGlobalCallback,
691 RegistryGlobalCallbackRemove};
693 const struct tizen_policy_listener tizenPolicyListener =
695 TizenPolicyConformant,
696 TizenPolicyConformantArea,
697 TizenPolicyNotificationChangeDone,
698 TizenPolicyTransientForDone,
699 TizenPolicyScreenModeChangeDone,
700 TizenPolicyIconifyStateChanged,
701 TizenPolicySupportedAuxiliaryHints,
702 TizenPolicyAllowedAuxiliaryHint,
703 TizenPolicyAuxiliaryMessage,
704 TizenPolicyConformantRegion};
706 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
708 DisplayPolicyBrightnessChangeDone};
710 } // unnamed namespace
712 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
713 : mEcoreEventHandler(),
714 mEcoreWindow(nullptr),
716 mWlInputPanel(nullptr),
718 mWlInputPanelSurface(nullptr),
721 mEventQueue(nullptr),
722 mTizenPolicy(nullptr),
723 mTizenDisplayPolicy(nullptr),
725 mSupportedAuxiliaryHints(),
726 mWindowPositionSize(positionSize),
728 mType(WindowType::NORMAL),
729 mNotificationLevel(-1),
732 mWindowRotationAngle(0),
733 mScreenRotationAngle(0),
734 mSupportedPreProtation(0),
735 mNotificationChangeState(0),
736 mScreenOffModeChangeState(0),
737 mBrightnessChangeState(0),
738 mLastSubmittedMoveResizeSerial(0),
739 mMoveResizeSerial(0),
740 mNotificationLevelChangeDone(true),
741 mScreenOffModeChangeDone(true),
744 mBrightnessChangeDone(true)
745 #ifdef DALI_ELDBUS_AVAILABLE
747 mSystemConnection(NULL)
750 Initialize(positionSize, surface, isTransparent);
753 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
755 #ifdef DALI_ELDBUS_AVAILABLE
756 // Close down ElDBus connections.
757 if(mSystemConnection)
759 eldbus_connection_unref(mSystemConnection);
761 #endif // DALI_ELDBUS_AVAILABLE
763 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
764 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
766 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
768 ecore_event_handler_del(*iter);
770 mEcoreEventHandler.Clear();
774 wl_event_queue_destroy(mEventQueue);
777 mSupportedAuxiliaryHints.clear();
778 mAuxiliaryHints.clear();
780 if(mEglWindow != NULL)
782 wl_egl_window_destroy(mEglWindow);
788 ecore_wl2_window_free(mEcoreWindow);
790 WindowSystem::Shutdown();
794 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
796 if(surface.Empty() == false)
798 // check we have a valid type
799 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
801 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
805 // we own the surface about to created
806 WindowSystem::Initialize();
809 CreateWindow(positionSize);
812 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
814 SetTransparency(isTransparent);
816 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
817 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
818 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
819 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
820 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
822 // Register Rotate event
823 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
825 // Register Configure event
826 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
828 // Register Touch events
829 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
830 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
831 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
832 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
834 // Register Mouse wheel events
835 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
837 // Register Detent event
838 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
840 // Register Key events
841 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
842 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
844 // Register Selection event - clipboard selection
845 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
846 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
848 // Register Effect Start/End event
849 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
850 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
852 // Register Keyboard repeat event
853 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
855 // Register Window redraw request event
856 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
858 // Register Window auxiliary event
859 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
861 // Register Vconf notify - font name and size
862 vconf_notify_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
863 vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
865 InitializeEcoreElDBus();
867 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
868 mDisplay = ecore_wl2_display_get(display);
872 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
875 mEventQueue = wl_display_create_queue(mDisplay);
878 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
880 wl_registry* registry = wl_display_get_registry(displayWrapper);
881 wl_registry_add_listener(registry, ®istryListener, this);
884 wl_proxy_wrapper_destroy(displayWrapper);
888 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
892 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
894 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
897 // get auxiliary hint
898 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
904 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))))
906 mSupportedAuxiliaryHints.push_back(hint);
908 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
913 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
915 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
916 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
918 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
920 if(iconifyChangedEvent->iconified == EINA_TRUE)
922 mIconifyChangedSignal.Emit(true);
926 mIconifyChangedSignal.Emit(false);
928 handled = ECORE_CALLBACK_DONE;
934 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
936 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
938 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
940 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
942 mFocusChangedSignal.Emit(true);
945 return ECORE_CALLBACK_PASS_ON;
948 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
950 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
952 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
954 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
956 mFocusChangedSignal.Emit(false);
959 return ECORE_CALLBACK_PASS_ON;
962 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
964 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
966 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
968 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
970 mScreenRotationAngle = GetScreenRotationAngle();
972 mOutputTransformedSignal.Emit();
975 return ECORE_CALLBACK_PASS_ON;
978 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
980 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
982 if(ignoreTransformEvent->win == mEcoreWindow)
984 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
986 mScreenRotationAngle = GetScreenRotationAngle();
988 mOutputTransformedSignal.Emit();
991 return ECORE_CALLBACK_PASS_ON;
994 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
996 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
998 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1000 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
1002 RotationEvent rotationEvent;
1003 rotationEvent.angle = ev->angle;
1004 rotationEvent.winResize = 0;
1006 if(ev->w == 0 || ev->h == 0)
1008 // Use previous client side window's size.
1009 if(mWindowRotationAngle == 90 || mWindowRotationAngle == 270)
1011 ev->w = mWindowPositionSize.height;
1012 ev->h = mWindowPositionSize.width;
1016 ev->w = mWindowPositionSize.width;
1017 ev->h = mWindowPositionSize.height;
1021 mWindowRotationAngle = ev->angle;
1023 if(ev->angle == 0 || ev->angle == 180)
1025 rotationEvent.width = ev->w;
1026 rotationEvent.height = ev->h;
1030 rotationEvent.width = ev->h;
1031 rotationEvent.height = ev->w;
1034 mWindowPositionSize.width = rotationEvent.width;
1035 mWindowPositionSize.height = rotationEvent.height;
1037 mRotationSignal.Emit(rotationEvent);
1041 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1043 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1045 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1047 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1048 // by calling ecore_wl2_window_commit
1050 int tempWidth = static_cast<int>(ev->w);
1051 int tempHeight = static_cast<int>(ev->h);
1053 // Initialize with previous size for skip resize when new size is 0.
1054 // When window is just moved or window is resized by client application,
1055 // The configure notification event's size will be 0.
1056 // If new size is 0, the resized work should be skip.
1057 int newWidth = mWindowPositionSize.width;
1058 int newHeight = mWindowPositionSize.height;
1059 bool windowMoved = false, windowResized = false;
1061 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1066 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1068 windowResized = true;
1069 newWidth = tempWidth;
1070 newHeight = tempHeight;
1073 if(windowMoved || windowResized)
1075 Dali::PositionSize newPositionSize(ev->x, ev->y, newWidth, newHeight);
1076 mUpdatePositionSizeSignal.Emit(newPositionSize);
1079 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1083 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1085 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1087 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1089 Device::Class::Type deviceClass;
1090 Device::Subclass::Type deviceSubclass;
1092 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1093 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1095 PointState::Type state(PointState::DOWN);
1097 if(deviceClass != Device::Class::Type::MOUSE)
1099 // Check if the buttons field is set and ensure it's the primary touch button.
1100 // If this event was triggered by buttons other than the primary button (used for touch), then
1101 // just send an interrupted event to Core.
1102 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1104 state = PointState::INTERRUPTED;
1108 Integration::Point point;
1109 point.SetDeviceId(touchEvent->multi.device);
1110 point.SetState(state);
1111 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1112 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1113 point.SetPressure(touchEvent->multi.pressure);
1114 point.SetAngle(Degree(touchEvent->multi.angle));
1115 point.SetDeviceClass(deviceClass);
1116 point.SetDeviceSubclass(deviceSubclass);
1117 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1119 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1123 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1125 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1127 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1129 Device::Class::Type deviceClass;
1130 Device::Subclass::Type deviceSubclass;
1132 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1133 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1135 Integration::Point point;
1136 point.SetDeviceId(touchEvent->multi.device);
1137 point.SetState(PointState::UP);
1138 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1139 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1140 point.SetPressure(touchEvent->multi.pressure);
1141 point.SetAngle(Degree(touchEvent->multi.angle));
1142 point.SetDeviceClass(deviceClass);
1143 point.SetDeviceSubclass(deviceSubclass);
1144 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1146 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1150 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1152 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1154 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1156 Device::Class::Type deviceClass;
1157 Device::Subclass::Type deviceSubclass;
1159 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1160 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1162 Integration::Point point;
1163 point.SetDeviceId(touchEvent->multi.device);
1164 point.SetState(PointState::MOTION);
1165 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1166 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1167 point.SetPressure(touchEvent->multi.pressure);
1168 point.SetAngle(Degree(touchEvent->multi.angle));
1169 point.SetDeviceClass(deviceClass);
1170 point.SetDeviceSubclass(deviceSubclass);
1172 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1176 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1178 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1180 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1182 Integration::Point point;
1183 point.SetDeviceId(touchEvent->multi.device);
1184 point.SetState(PointState::INTERRUPTED);
1185 point.SetScreenPosition(Vector2(0.0f, 0.0f));
1187 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1189 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1193 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1195 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1197 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1199 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);
1201 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1203 mWheelEventSignal.Emit(wheelEvent);
1207 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1209 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1211 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1213 int32_t clockwise = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1215 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, detentEvent->direction, 0, Vector2(0.0f, 0.0f), clockwise, detentEvent->timestamp);
1217 mWheelEventSignal.Emit(wheelEvent);
1220 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1222 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1224 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1226 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n");
1228 std::string keyName(keyEvent->keyname);
1229 std::string logicalKey("");
1230 std::string keyString("");
1231 std::string compose("");
1233 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1234 if(keyEvent->compose)
1236 compose = keyEvent->compose;
1239 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1242 logicalKey = keyEvent->key;
1246 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1250 // Get a specific key code from dali key look up table.
1251 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1254 keyCode = (keyCode == -1) ? 0 : keyCode;
1255 int modifier(keyEvent->modifiers);
1256 unsigned long time = keyEvent->timestamp;
1257 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1259 keyCode = atoi(keyEvent->keyname + 8);
1262 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1263 if(keyEvent->string)
1265 keyString = keyEvent->string;
1268 std::string deviceName;
1269 Device::Class::Type deviceClass;
1270 Device::Subclass::Type deviceSubclass;
1272 GetDeviceName(keyEvent, deviceName);
1273 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1274 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1276 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1278 mKeyEventSignal.Emit(keyEvent);
1282 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1284 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1286 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1288 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n");
1290 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1291 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1292 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1294 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1297 #endif // Since ecore 1.23 version
1299 std::string keyName(keyEvent->keyname);
1300 std::string logicalKey("");
1301 std::string keyString("");
1302 std::string compose("");
1304 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1305 if(keyEvent->compose)
1307 compose = keyEvent->compose;
1310 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1313 logicalKey = keyEvent->key;
1317 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1321 // Get a specific key code from dali key look up table.
1322 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1325 keyCode = (keyCode == -1) ? 0 : keyCode;
1326 int modifier(keyEvent->modifiers);
1327 unsigned long time = keyEvent->timestamp;
1328 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1330 keyCode = atoi(keyEvent->keyname + 8);
1333 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1334 if(keyEvent->string)
1336 keyString = keyEvent->string;
1339 std::string deviceName;
1340 Device::Class::Type deviceClass;
1341 Device::Subclass::Type deviceSubclass;
1343 GetDeviceName(keyEvent, deviceName);
1344 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1345 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1347 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1349 mKeyEventSignal.Emit(keyEvent);
1353 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1355 mSelectionDataSendSignal.Emit(event);
1358 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1360 mSelectionDataReceivedSignal.Emit(event);
1363 void WindowBaseEcoreWl2::OnFontNameChanged()
1365 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1368 void WindowBaseEcoreWl2::OnFontSizeChanged()
1370 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1373 #ifdef DALI_ELDBUS_AVAILABLE
1374 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
1376 AccessibilityInfo info;
1378 // The string defines the arg-list's respective types.
1379 if(!eldbus_message_arguments_get(message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime))
1381 DALI_LOG_ERROR("OnEcoreElDBusAccessibilityNotification: Error getting arguments\n");
1384 mAccessibilitySignal.Emit(info);
1386 #endif // DALI_ELDBUS_AVAILABLE
1388 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1390 mTransitionEffectEventSignal.Emit(state, type);
1393 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1395 mKeyboardRepeatSettingsChangedSignal.Emit();
1398 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1400 mWindowRedrawRequestSignal.Emit();
1403 void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
1405 Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
1408 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
1409 std::string key(message->key);
1410 std::string value(message->val);
1411 Dali::Property::Array options;
1413 if(message->options)
1417 EINA_LIST_FOREACH(message->options, l, data)
1419 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
1420 std::string option(static_cast<char*>(data));
1421 options.Add(option);
1425 mAuxiliaryMessageSignal.Emit(key, value, options);
1429 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1431 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1432 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1433 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1436 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1440 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1442 if(strcmp(interface, tizen_policy_interface.name) == 0)
1444 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1446 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1449 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1453 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1455 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1457 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1459 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1460 if(!mTizenDisplayPolicy)
1462 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1466 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1468 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1472 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1474 mTizenPolicy = NULL;
1475 mTizenDisplayPolicy = NULL;
1478 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1480 mNotificationLevel = level;
1481 mNotificationChangeState = state;
1482 mNotificationLevelChangeDone = true;
1484 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1487 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1489 mScreenOffMode = mode;
1490 mScreenOffModeChangeState = state;
1491 mScreenOffModeChangeDone = true;
1493 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1496 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1498 mBrightness = brightness;
1499 mBrightnessChangeState = state;
1500 mBrightnessChangeDone = true;
1502 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1505 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1507 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1508 KeyCodeMap foundKeyCode;
1510 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1511 if(sym == XKB_KEY_NoSymbol)
1513 DALI_LOG_ERROR("Failed to get keysym in WindowBaseEcoreWl2\n");
1517 foundKeyCode.keySym = sym;
1518 foundKeyCode.isKeyCode = false;
1519 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1520 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1523 Any WindowBaseEcoreWl2::GetNativeWindow()
1525 return mEcoreWindow;
1528 int WindowBaseEcoreWl2::GetNativeWindowId()
1530 return ecore_wl2_window_id_get(mEcoreWindow);
1533 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1535 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1536 if(totalAngle == 90 || totalAngle == 270)
1538 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
1542 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1545 return static_cast<EGLNativeWindowType>(mEglWindow);
1548 void WindowBaseEcoreWl2::DestroyEglWindow()
1550 if(mEglWindow != NULL)
1552 wl_egl_window_destroy(mEglWindow);
1557 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
1559 wl_egl_window_tizen_rotation rotation;
1565 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1570 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1575 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1580 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1585 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1590 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
1593 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
1595 wl_output_transform bufferTransform;
1601 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1606 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1611 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1616 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1621 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1626 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
1629 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
1631 wl_output_transform windowTransform;
1637 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1642 windowTransform = WL_OUTPUT_TRANSFORM_90;
1647 windowTransform = WL_OUTPUT_TRANSFORM_180;
1652 windowTransform = WL_OUTPUT_TRANSFORM_270;
1657 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1662 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
1665 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
1667 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1669 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1670 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
1672 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
1673 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1677 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1680 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
1681 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
1683 mSupportedPreProtation = true;
1686 mSupportedPreProtation = false;
1690 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
1692 mWindowPositionSize = positionSize;
1693 ecore_wl2_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
1696 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
1698 mWindowPositionSize = positionSize;
1699 ecore_wl2_window_geometry_set(mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1702 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
1704 mWindowPositionSize = positionSize;
1705 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1708 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
1710 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
1711 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
1714 void WindowBaseEcoreWl2::Raise()
1716 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1717 ecore_wl2_window_activate(mEcoreWindow);
1720 void WindowBaseEcoreWl2::Lower()
1722 ecore_wl2_window_lower(mEcoreWindow);
1725 void WindowBaseEcoreWl2::Activate()
1727 ecore_wl2_window_activate(mEcoreWindow);
1730 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
1732 int rotations[4] = {0};
1733 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
1734 for(std::size_t i = 0; i < angles.size(); ++i)
1736 rotations[i] = static_cast<int>(angles[i]);
1737 DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
1739 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
1742 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
1744 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
1745 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
1748 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
1750 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
1753 void WindowBaseEcoreWl2::Show()
1757 // Ecore-wl2 has the original window size
1758 // and he always sends the window rotation event with the swapped size.
1759 // So, to restore, dali should set the reswapped size(original window size) to ecore-wl2 for restoring.
1760 if(mWindowRotationAngle == 0 || mWindowRotationAngle == 180)
1762 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1766 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.height, mWindowPositionSize.width);
1771 ecore_wl2_window_show(mEcoreWindow);
1774 void WindowBaseEcoreWl2::Hide()
1777 ecore_wl2_window_hide(mEcoreWindow);
1780 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
1782 return mSupportedAuxiliaryHints.size();
1785 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
1787 if(index >= GetSupportedAuxiliaryHintCount())
1789 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
1792 return mSupportedAuxiliaryHints[index];
1795 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
1797 bool supported = false;
1799 // Check if the hint is suppported
1800 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
1811 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
1815 // Check if the hint is already added
1816 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1818 if(mAuxiliaryHints[i].first == hint)
1820 // Just change the value
1821 mAuxiliaryHints[i].second = value;
1823 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
1825 return i + 1; // id is index + 1
1830 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
1832 unsigned int id = mAuxiliaryHints.size();
1834 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
1836 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
1841 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
1843 if(id == 0 || id > mAuxiliaryHints.size())
1845 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
1849 mAuxiliaryHints[id - 1].second = std::string();
1851 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
1853 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
1858 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
1860 if(id == 0 || id > mAuxiliaryHints.size())
1862 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
1866 mAuxiliaryHints[id - 1].second = value;
1868 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
1870 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());
1875 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
1877 if(id == 0 || id > mAuxiliaryHints.size())
1879 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
1880 return std::string();
1883 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());
1885 return mAuxiliaryHints[id - 1].second;
1888 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
1890 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1892 if(mAuxiliaryHints[i].first == hint)
1894 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
1899 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
1904 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
1906 ecore_wl2_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1909 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
1914 Ecore_Wl2_Window_Type windowType;
1918 case Dali::WindowType::NORMAL:
1920 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1923 case Dali::WindowType::NOTIFICATION:
1925 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1928 case Dali::WindowType::UTILITY:
1930 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1933 case Dali::WindowType::DIALOG:
1935 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1938 case Dali::WindowType::IME:
1940 windowType = ECORE_WL2_WINDOW_TYPE_NONE;
1945 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1949 ecore_wl2_window_type_set(mEcoreWindow, windowType);
1953 Dali::WindowType WindowBaseEcoreWl2::GetType() const
1958 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
1960 while(!mTizenPolicy)
1962 wl_display_dispatch_queue(mDisplay, mEventQueue);
1965 int notificationLevel;
1969 case Dali::WindowNotificationLevel::NONE:
1971 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1974 case Dali::WindowNotificationLevel::BASE:
1976 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1979 case Dali::WindowNotificationLevel::MEDIUM:
1981 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1984 case Dali::WindowNotificationLevel::HIGH:
1986 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1989 case Dali::WindowNotificationLevel::TOP:
1991 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1996 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
1997 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
2002 mNotificationLevelChangeDone = false;
2003 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2005 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
2009 while(!mNotificationLevelChangeDone && count < 3)
2011 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2012 wl_display_dispatch_queue(mDisplay, mEventQueue);
2016 if(!mNotificationLevelChangeDone)
2018 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
2019 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2021 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2023 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
2024 return Dali::WindowOperationResult::PERMISSION_DENIED;
2027 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
2029 return Dali::WindowOperationResult::SUCCEED;
2032 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
2034 while(!mTizenPolicy)
2036 wl_display_dispatch_queue(mDisplay, mEventQueue);
2041 while(!mNotificationLevelChangeDone && count < 3)
2043 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2044 wl_display_dispatch_queue(mDisplay, mEventQueue);
2048 if(!mNotificationLevelChangeDone)
2050 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
2051 return Dali::WindowNotificationLevel::NONE;
2054 Dali::WindowNotificationLevel level;
2056 switch(mNotificationLevel)
2058 case TIZEN_POLICY_LEVEL_NONE:
2060 level = Dali::WindowNotificationLevel::NONE;
2063 case TIZEN_POLICY_LEVEL_DEFAULT:
2065 level = Dali::WindowNotificationLevel::BASE;
2068 case TIZEN_POLICY_LEVEL_MEDIUM:
2070 level = Dali::WindowNotificationLevel::MEDIUM;
2073 case TIZEN_POLICY_LEVEL_HIGH:
2075 level = Dali::WindowNotificationLevel::HIGH;
2078 case TIZEN_POLICY_LEVEL_TOP:
2080 level = Dali::WindowNotificationLevel::TOP;
2085 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2086 level = Dali::WindowNotificationLevel::NONE;
2091 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2096 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2098 while(!mTizenPolicy)
2100 wl_display_dispatch_queue(mDisplay, mEventQueue);
2103 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2106 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2108 while(!mTizenPolicy)
2110 wl_display_dispatch_queue(mDisplay, mEventQueue);
2113 mScreenOffModeChangeDone = false;
2114 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2116 unsigned int mode = 0;
2118 switch(screenOffMode)
2120 case WindowScreenOffMode::TIMEOUT:
2125 case WindowScreenOffMode::NEVER:
2132 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2136 while(!mScreenOffModeChangeDone && count < 3)
2138 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2139 wl_display_dispatch_queue(mDisplay, mEventQueue);
2143 if(!mScreenOffModeChangeDone)
2145 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2146 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2148 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2150 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2151 return Dali::WindowOperationResult::PERMISSION_DENIED;
2154 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2156 return Dali::WindowOperationResult::SUCCEED;
2159 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2161 while(!mTizenPolicy)
2163 wl_display_dispatch_queue(mDisplay, mEventQueue);
2168 while(!mScreenOffModeChangeDone && count < 3)
2170 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2171 wl_display_dispatch_queue(mDisplay, mEventQueue);
2175 if(!mScreenOffModeChangeDone)
2177 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2178 return WindowScreenOffMode::TIMEOUT;
2181 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2183 switch(mScreenOffMode)
2187 screenMode = WindowScreenOffMode::TIMEOUT;
2192 screenMode = WindowScreenOffMode::NEVER;
2197 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2202 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2204 while(!mTizenDisplayPolicy)
2206 wl_display_dispatch_queue(mDisplay, mEventQueue);
2209 mBrightnessChangeDone = false;
2210 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2212 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2216 while(!mBrightnessChangeDone && count < 3)
2218 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2219 wl_display_dispatch_queue(mDisplay, mEventQueue);
2223 if(!mBrightnessChangeDone)
2225 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2226 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2228 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2230 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2231 return Dali::WindowOperationResult::PERMISSION_DENIED;
2234 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2236 return Dali::WindowOperationResult::SUCCEED;
2239 int WindowBaseEcoreWl2::GetBrightness() const
2241 while(!mTizenDisplayPolicy)
2243 wl_display_dispatch_queue(mDisplay, mEventQueue);
2248 while(!mBrightnessChangeDone && count < 3)
2250 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2251 wl_display_dispatch_queue(mDisplay, mEventQueue);
2255 if(!mBrightnessChangeDone)
2257 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2261 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2266 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2268 Ecore_Wl2_Window_Keygrab_Mode mode;
2272 case KeyGrab::TOPMOST:
2274 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2277 case KeyGrab::SHARED:
2279 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2282 case KeyGrab::OVERRIDE_EXCLUSIVE:
2284 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2287 case KeyGrab::EXCLUSIVE:
2289 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2298 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2301 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2303 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2306 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2308 int keyCount = key.Count();
2309 int keyGrabModeCount = grabMode.Count();
2311 if(keyCount != keyGrabModeCount || keyCount == 0)
2318 Eina_List* keyList = NULL;
2319 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2321 for(int index = 0; index < keyCount; ++index)
2323 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2325 switch(grabMode[index])
2327 case KeyGrab::TOPMOST:
2329 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2332 case KeyGrab::SHARED:
2334 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2337 case KeyGrab::OVERRIDE_EXCLUSIVE:
2339 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2342 case KeyGrab::EXCLUSIVE:
2344 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2349 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2354 keyList = eina_list_append(keyList, &info);
2357 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
2359 result.Resize(keyCount, true);
2361 Eina_List* l = NULL;
2362 Eina_List* m = NULL;
2363 void* listData = NULL;
2365 if(grabList != NULL)
2367 EINA_LIST_FOREACH(grabList, m, data)
2370 EINA_LIST_FOREACH(keyList, l, listData)
2372 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
2374 DALI_LOG_ERROR("input key list has null data!");
2378 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2380 result[index] = false;
2389 eina_list_free(keyList);
2390 eina_list_free(grabList);
2396 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
2398 int keyCount = key.Count();
2406 Eina_List* keyList = NULL;
2407 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2409 for(int index = 0; index < keyCount; ++index)
2411 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2412 keyList = eina_list_append(keyList, &info);
2415 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
2417 result.Resize(keyCount, true);
2419 Eina_List* l = NULL;
2420 Eina_List* m = NULL;
2421 void* listData = NULL;
2424 if(ungrabList != NULL)
2426 EINA_LIST_FOREACH(ungrabList, m, data)
2429 EINA_LIST_FOREACH(keyList, l, listData)
2431 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2433 result[index] = false;
2442 eina_list_free(keyList);
2443 eina_list_free(ungrabList);
2449 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2454 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
2456 // 1 inch = 25.4 millimeters
2457 xres = ecore_wl2_output_dpi_get(output);
2458 yres = ecore_wl2_output_dpi_get(output);
2460 dpiHorizontal = int(xres + 0.5f); // rounding
2461 dpiVertical = int(yres + 0.5f);
2464 int WindowBaseEcoreWl2::GetOrientation() const
2466 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2467 if(mSupportedPreProtation)
2474 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2478 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
2484 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
2486 mScreenRotationAngle = transform * 90;
2487 return mScreenRotationAngle;
2490 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
2492 mWindowRotationAngle = degree;
2493 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
2496 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
2498 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
2501 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
2503 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
2506 void WindowBaseEcoreWl2::InitializeEcoreElDBus()
2508 #ifdef DALI_ELDBUS_AVAILABLE
2509 Eldbus_Object* object;
2510 Eldbus_Proxy* manager;
2512 if(!(mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM)))
2514 DALI_LOG_ERROR("Unable to get system bus\n");
2517 object = eldbus_object_get(mSystemConnection, BUS, PATH);
2520 DALI_LOG_ERROR("Getting object failed\n");
2524 manager = eldbus_proxy_get(object, INTERFACE);
2527 DALI_LOG_ERROR("Getting proxy failed\n");
2531 if(!eldbus_proxy_signal_handler_add(manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this))
2533 DALI_LOG_ERROR("No signal handler returned\n");
2538 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
2540 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
2543 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
2546 ecore_wl2_display_sync(display);
2548 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2550 if(mEcoreWindow == 0)
2552 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2556 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
2559 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
2561 Ecore_Wl2_Window* ecoreParent = NULL;
2564 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
2565 ecoreParent = winBaseEcore2->mEcoreWindow;
2567 ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
2570 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2572 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
2575 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2577 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
2580 void WindowBaseEcoreWl2::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
2582 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);
2583 ecore_wl2_window_rotation_geometry_set(mEcoreWindow, angle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2586 void WindowBaseEcoreWl2::InitializeIme()
2588 Eina_Iterator* globals;
2589 struct wl_registry* registry;
2590 Ecore_Wl2_Global* global;
2591 Ecore_Wl2_Display* ecoreWl2Display;
2593 if(!(ecoreWl2Display = ecore_wl2_connected_display_get(NULL)))
2595 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 connected display\n");
2599 DALI_LOG_RELEASE_INFO("InitializeIme: Ecore_Wl2_Display: %p, ecore wl window: %p\n", ecoreWl2Display, mEcoreWindow);
2601 if(!(registry = ecore_wl2_display_registry_get(ecoreWl2Display)))
2603 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 display registry\n");
2607 if(!(globals = ecore_wl2_display_globals_get(ecoreWl2Display)))
2609 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get ecore_wl2 globals\n");
2613 EINA_ITERATOR_FOREACH(globals, global)
2615 if(strcmp(global->interface, "wl_input_panel") == 0)
2617 mWlInputPanel = (wl_input_panel*)wl_registry_bind(registry, global->id, &wl_input_panel_interface, 1);
2619 else if(strcmp(global->interface, "wl_output") == 0)
2621 mWlOutput = (wl_output*)wl_registry_bind(registry, global->id, &wl_output_interface, 1);
2627 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel interface\n");
2633 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland output panel interface\n");
2637 mWlInputPanelSurface = wl_input_panel_get_input_panel_surface(mWlInputPanel, mWlSurface);
2638 if(!mWlInputPanelSurface)
2640 DALI_LOG_ERROR("WindowBaseEcoreWl2::InitializeIme(), fail to get wayland input panel surface\n");
2644 wl_input_panel_surface_set_toplevel(mWlInputPanelSurface, mWlOutput, WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
2647 void WindowBaseEcoreWl2::ImeWindowReadyToRender()
2649 if(!mWlInputPanelSurface)
2651 DALI_LOG_ERROR("WindowBaseEcoreWl2::ImeWindowReadyToRender(), wayland input panel surface is null\n");
2655 wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
2658 void WindowBaseEcoreWl2::RequestMoveToServer()
2660 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
2663 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
2667 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
2670 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
2674 ecore_wl2_window_move(mEcoreWindow, input);
2675 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
2678 void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
2680 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
2683 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
2687 Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
2690 DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
2697 case WindowResizeDirection::TOP_LEFT:
2702 case WindowResizeDirection::TOP:
2707 case WindowResizeDirection::TOP_RIGHT:
2712 case WindowResizeDirection::LEFT:
2717 case WindowResizeDirection::RIGHT:
2722 case WindowResizeDirection::BOTTOM_LEFT:
2727 case WindowResizeDirection::BOTTOM:
2732 case WindowResizeDirection::BOTTOM_RIGHT:
2744 ecore_wl2_window_resize(mEcoreWindow, input, location);
2745 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestResizeToServer, starts the window[%p] is resized by server, mode:%d\n", mEcoreWindow, location);
2748 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
2750 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
2753 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
2757 ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
2761 bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
2763 return ecore_wl2_window_floating_mode_get(mEcoreWindow);
2766 void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
2768 Eina_Rectangle rect;
2769 rect.x = inputRegion.x;
2770 rect.y = inputRegion.y;
2771 rect.w = inputRegion.width;
2772 rect.h = inputRegion.height;
2774 ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
2775 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2778 void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
2780 Eina_Rectangle rect;
2781 rect.x = inputRegion.x;
2782 rect.y = inputRegion.y;
2783 rect.w = inputRegion.width;
2784 rect.h = inputRegion.height;
2786 ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
2787 ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
2790 } // namespace Adaptor
2792 } // namespace Internal
2796 #pragma GCC diagnostic pop