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.
59 const char* BUS = "org.enlightenment.wm-screen-reader";
60 const char* INTERFACE = "org.tizen.GestureNavigation";
61 const char* PATH = "/org/tizen/GestureNavigation";
66 xkb_keycode_t keyCode;
71 * Get the device name from the provided ecore key event
73 void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
75 const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
79 result = ecoreDeviceName;
84 * Get the device class from the provided ecore event
86 void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
88 switch(ecoreDeviceClass)
90 case ECORE_DEVICE_CLASS_SEAT:
92 deviceClass = Device::Class::USER;
95 case ECORE_DEVICE_CLASS_KEYBOARD:
97 deviceClass = Device::Class::KEYBOARD;
100 case ECORE_DEVICE_CLASS_MOUSE:
102 deviceClass = Device::Class::MOUSE;
105 case ECORE_DEVICE_CLASS_TOUCH:
107 deviceClass = Device::Class::TOUCH;
110 case ECORE_DEVICE_CLASS_PEN:
112 deviceClass = Device::Class::PEN;
115 case ECORE_DEVICE_CLASS_POINTER:
117 deviceClass = Device::Class::POINTER;
120 case ECORE_DEVICE_CLASS_GAMEPAD:
122 deviceClass = Device::Class::GAMEPAD;
127 deviceClass = Device::Class::NONE;
133 void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
135 switch(ecoreDeviceSubclass)
137 case ECORE_DEVICE_SUBCLASS_FINGER:
139 deviceSubclass = Device::Subclass::FINGER;
142 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
144 deviceSubclass = Device::Subclass::FINGERNAIL;
147 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
149 deviceSubclass = Device::Subclass::KNUCKLE;
152 case ECORE_DEVICE_SUBCLASS_PALM:
154 deviceSubclass = Device::Subclass::PALM;
157 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
159 deviceSubclass = Device::Subclass::HAND_SIDE;
162 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
164 deviceSubclass = Device::Subclass::HAND_FLAT;
167 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
169 deviceSubclass = Device::Subclass::PEN_TIP;
172 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
174 deviceSubclass = Device::Subclass::TRACKPAD;
177 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
179 deviceSubclass = Device::Subclass::TRACKPOINT;
182 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
184 deviceSubclass = Device::Subclass::TRACKBALL;
187 case ECORE_DEVICE_SUBCLASS_REMOCON:
189 deviceSubclass = Device::Subclass::REMOCON;
192 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
194 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
199 deviceSubclass = Device::Subclass::NONE;
205 void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
207 KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
208 if(foundKeyCode->isKeyCode)
213 xkb_keysym_t keySym = foundKeyCode->keySym;
215 const xkb_keysym_t* symsOut = NULL;
217 nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
221 if(*symsOut == keySym)
223 foundKeyCode->keyCode = key;
224 foundKeyCode->isKeyCode = true;
229 /////////////////////////////////////////////////////////////////////////////////////////////////
231 /////////////////////////////////////////////////////////////////////////////////////////////////
233 /// Called when the window iconify state is changed.
234 static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
236 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
239 return windowBase->OnIconifyStateChanged(data, type, event);
242 return ECORE_CALLBACK_PASS_ON;
245 /// Called when the window gains focus
246 static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
248 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
251 return windowBase->OnFocusIn(data, type, event);
254 return ECORE_CALLBACK_PASS_ON;
257 /// Called when the window loses focus
258 static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
260 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
263 return windowBase->OnFocusOut(data, type, event);
266 return ECORE_CALLBACK_PASS_ON;
269 /// Called when the output is transformed
270 static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
272 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
275 return windowBase->OnOutputTransform(data, type, event);
278 return ECORE_CALLBACK_PASS_ON;
281 /// Called when the output transform should be ignored
282 static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
284 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
287 return windowBase->OnIgnoreOutputTransform(data, type, event);
290 return ECORE_CALLBACK_PASS_ON;
294 * Called when rotate event is recevied.
296 static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
298 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
301 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
302 windowBase->OnRotation(data, type, event);
304 return ECORE_CALLBACK_PASS_ON;
308 * Called when configure event is recevied.
310 static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
312 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
315 windowBase->OnConfiguration(data, type, event);
317 return ECORE_CALLBACK_PASS_ON;
320 /////////////////////////////////////////////////////////////////////////////////////////////////
322 /////////////////////////////////////////////////////////////////////////////////////////////////
325 * Called when a touch down is received.
327 static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
329 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
332 windowBase->OnMouseButtonDown(data, type, event);
334 return ECORE_CALLBACK_PASS_ON;
338 * Called when a touch up is received.
340 static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
342 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
345 windowBase->OnMouseButtonUp(data, type, event);
347 return ECORE_CALLBACK_PASS_ON;
351 * Called when a touch motion is received.
353 static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
355 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
358 windowBase->OnMouseButtonMove(data, type, event);
360 return ECORE_CALLBACK_PASS_ON;
364 * Called when a touch is canceled.
366 static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
368 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
371 windowBase->OnMouseButtonCancel(data, type, event);
373 return ECORE_CALLBACK_PASS_ON;
377 * Called when a mouse wheel is received.
379 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
381 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
384 windowBase->OnMouseWheel(data, type, event);
386 return ECORE_CALLBACK_PASS_ON;
390 * Called when a detent rotation event is recevied.
392 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
394 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
397 windowBase->OnDetentRotation(data, type, event);
399 return ECORE_CALLBACK_PASS_ON;
402 /////////////////////////////////////////////////////////////////////////////////////////////////
404 /////////////////////////////////////////////////////////////////////////////////////////////////
407 * Called when a key down is received.
409 static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
411 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
414 windowBase->OnKeyDown(data, type, event);
416 return ECORE_CALLBACK_PASS_ON;
420 * Called when a key up is received.
422 static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
424 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
427 windowBase->OnKeyUp(data, type, event);
429 return ECORE_CALLBACK_PASS_ON;
432 /////////////////////////////////////////////////////////////////////////////////////////////////
433 // Selection Callbacks
434 /////////////////////////////////////////////////////////////////////////////////////////////////
437 * Called when the source window notifies us the content in clipboard is selected.
439 static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
441 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
444 windowBase->OnDataSend(data, type, event);
446 return ECORE_CALLBACK_PASS_ON;
450 * Called when the source window sends us about the selected content.
451 * For example, when item is selected in the clipboard.
453 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
455 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
458 windowBase->OnDataReceive(data, type, event);
460 return ECORE_CALLBACK_PASS_ON;
463 /////////////////////////////////////////////////////////////////////////////////////////////////
464 // Effect Start/End Callbacks
465 /////////////////////////////////////////////////////////////////////////////////////////////////
468 * Called when transition animation of the window's shown/hidden is started by window manager.
470 static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
472 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
473 Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
474 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
477 if(effectStart->type < 3) // only under restack
479 windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
482 return ECORE_CALLBACK_PASS_ON;
486 * Called when transition animation of the window's shown/hidden is ended by window manager.
488 static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
490 Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
491 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
492 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
495 if(effectEnd->type < 3) // only under restack
497 windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
500 return ECORE_CALLBACK_PASS_ON;
503 /////////////////////////////////////////////////////////////////////////////////////////////////
504 // Keyboard Repeat Settings Changed Callbacks
505 /////////////////////////////////////////////////////////////////////////////////////////////////
507 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
509 Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed* keyboardRepeat = static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event);
510 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
511 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", keyboardRepeat->id);
514 windowBase->OnKeyboardRepeatSettingsChanged();
517 return ECORE_CALLBACK_RENEW;
520 /////////////////////////////////////////////////////////////////////////////////////////////////
521 // Keymap Changed Callbacks
522 /////////////////////////////////////////////////////////////////////////////////////////////////
524 static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
526 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
529 windowBase->KeymapChanged(data, type, event);
532 return ECORE_CALLBACK_RENEW;
535 /////////////////////////////////////////////////////////////////////////////////////////////////
537 /////////////////////////////////////////////////////////////////////////////////////////////////
540 * Called when a font name is changed.
542 static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
544 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
547 windowBase->OnFontNameChanged();
552 * Called when a font size is changed.
554 static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
556 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
559 windowBase->OnFontSizeChanged();
563 /////////////////////////////////////////////////////////////////////////////////////////////////
564 // Window Redraw Request Event Callbacks
565 /////////////////////////////////////////////////////////////////////////////////////////////////
567 static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
569 Ecore_Wl2_Event_Window_Redraw_Request* windowRedrawRequest = static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event);
570 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
571 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", windowRedrawRequest->win);
574 windowBase->OnEcoreEventWindowRedrawRequest();
577 return ECORE_CALLBACK_RENEW;
580 /////////////////////////////////////////////////////////////////////////////////////////////////
581 // ElDBus Accessibility Callbacks
582 /////////////////////////////////////////////////////////////////////////////////////////////////
584 #ifdef DALI_ELDBUS_AVAILABLE
585 // Callback for Ecore ElDBus accessibility events.
586 static void EcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
588 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(context);
591 windowBase->OnEcoreElDBusAccessibilityNotification(context, message);
594 #endif // DALI_ELDBUS_AVAILABLE
596 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
598 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
601 windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
605 static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
607 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
610 windowBase->RegistryGlobalCallbackRemove(data, registry, id);
614 static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
618 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)
622 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
624 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
627 windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
631 static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
635 static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
637 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
640 windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
644 static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
648 static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
652 static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
656 static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
660 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)
664 static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
666 WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
669 windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
673 const struct wl_registry_listener registryListener =
675 RegistryGlobalCallback,
676 RegistryGlobalCallbackRemove};
678 const struct tizen_policy_listener tizenPolicyListener =
680 TizenPolicyConformant,
681 TizenPolicyConformantArea,
682 TizenPolicyNotificationChangeDone,
683 TizenPolicyTransientForDone,
684 TizenPolicyScreenModeChangeDone,
685 TizenPolicyIconifyStateChanged,
686 TizenPolicySupportedAuxiliaryHints,
687 TizenPolicyAllowedAuxiliaryHint,
688 TizenPolicyAuxiliaryMessage,
689 TizenPolicyConformantRegion};
691 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
693 DisplayPolicyBrightnessChangeDone};
695 } // unnamed namespace
697 WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surface, bool isTransparent)
698 : mEcoreEventHandler(),
699 mEcoreWindow(nullptr),
703 mEventQueue(nullptr),
704 mTizenPolicy(nullptr),
705 mTizenDisplayPolicy(nullptr),
707 mSupportedAuxiliaryHints(),
709 mNotificationLevel(-1),
710 mNotificationChangeState(0),
711 mNotificationLevelChangeDone(true),
713 mScreenOffModeChangeState(0),
714 mScreenOffModeChangeDone(true),
716 mBrightnessChangeState(0),
717 mBrightnessChangeDone(true),
719 mWindowPositionSize(positionSize),
721 mMoveResizeSerial(0),
722 mLastSubmittedMoveResizeSerial(0),
723 mWindowRotationAngle(0),
724 mScreenRotationAngle(0),
725 mSupportedPreProtation(0)
726 #ifdef DALI_ELDBUS_AVAILABLE
728 mSystemConnection(NULL)
731 Initialize(positionSize, surface, isTransparent);
734 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
736 #ifdef DALI_ELDBUS_AVAILABLE
737 // Close down ElDBus connections.
738 if(mSystemConnection)
740 eldbus_connection_unref(mSystemConnection);
742 #endif // DALI_ELDBUS_AVAILABLE
744 vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
745 vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
747 for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
749 ecore_event_handler_del(*iter);
751 mEcoreEventHandler.Clear();
755 wl_event_queue_destroy(mEventQueue);
758 mSupportedAuxiliaryHints.clear();
759 mAuxiliaryHints.clear();
761 if(mEglWindow != NULL)
763 wl_egl_window_destroy(mEglWindow);
769 ecore_wl2_window_free(mEcoreWindow);
771 WindowSystem::Shutdown();
775 void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
777 if(surface.Empty() == false)
779 // check we have a valid type
780 DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
782 mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
786 // we own the surface about to created
787 WindowSystem::Initialize();
790 CreateWindow(positionSize);
793 mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
795 SetTransparency(isTransparent);
797 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
798 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
799 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
800 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
801 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
803 // Register Rotate event
804 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
806 // Register Configure event
807 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
809 // Register Touch events
810 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
811 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
812 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
813 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
815 // Register Mouse wheel events
816 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
818 // Register Detent event
819 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
821 // Register Key events
822 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
823 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
825 // Register Selection event - clipboard selection
826 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
827 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
829 // Register Effect Start/End event
830 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
831 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
833 // Register Keyboard repeat event
834 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
836 // Register Window redraw request event
837 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
839 // Register Vconf notify - font name and size
840 vconf_notify_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
841 vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
843 InitializeEcoreElDBus();
845 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
846 mDisplay = ecore_wl2_display_get(display);
850 wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
853 mEventQueue = wl_display_create_queue(mDisplay);
856 wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
858 wl_registry* registry = wl_display_get_registry(displayWrapper);
859 wl_registry_add_listener(registry, ®istryListener, this);
862 wl_proxy_wrapper_destroy(displayWrapper);
866 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
870 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
872 mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
875 // get auxiliary hint
876 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
882 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))))
884 mSupportedAuxiliaryHints.push_back(hint);
886 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
891 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
893 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
894 Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
896 if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
898 if(iconifyChangedEvent->iconified == EINA_TRUE)
900 mIconifyChangedSignal.Emit(true);
904 mIconifyChangedSignal.Emit(false);
906 handled = ECORE_CALLBACK_DONE;
912 Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
914 Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
916 if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
918 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
920 mFocusChangedSignal.Emit(true);
923 return ECORE_CALLBACK_PASS_ON;
926 Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
928 Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
930 if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
932 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
934 mFocusChangedSignal.Emit(false);
937 return ECORE_CALLBACK_PASS_ON;
940 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
942 Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
944 if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
946 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
948 mScreenRotationAngle = GetScreenRotationAngle();
950 mOutputTransformedSignal.Emit();
953 return ECORE_CALLBACK_PASS_ON;
956 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
958 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
960 if(ignoreTransformEvent->win == mEcoreWindow)
962 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
964 mScreenRotationAngle = GetScreenRotationAngle();
966 mOutputTransformedSignal.Emit();
969 return ECORE_CALLBACK_PASS_ON;
972 void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
974 Ecore_Wl2_Event_Window_Rotation* ev(static_cast<Ecore_Wl2_Event_Window_Rotation*>(event));
976 if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
978 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
980 RotationEvent rotationEvent;
981 rotationEvent.angle = ev->angle;
982 rotationEvent.winResize = 0;
983 mWindowRotationAngle = ev->angle;
985 if(ev->angle == 0 || ev->angle == 180)
987 rotationEvent.width = ev->w;
988 rotationEvent.height = ev->h;
992 rotationEvent.width = ev->h;
993 rotationEvent.height = ev->w;
996 mWindowPositionSize.width = rotationEvent.width;
997 mWindowPositionSize.height = rotationEvent.height;
999 mRotationSignal.Emit(rotationEvent);
1003 void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
1005 Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
1007 if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1009 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1010 // by calling ecore_wl2_window_commit
1012 int tempWidth = static_cast<int>(ev->w);
1013 int tempHeight = static_cast<int>(ev->h);
1015 // Initialize with previous size for skip resize when new size is 0.
1016 // When window is just moved or window is resized by client application,
1017 // The configure notification event's size will be 0.
1018 // If new size is 0, the resized work should be skip.
1019 int newWidth = mWindowPositionSize.width;
1020 int newHeight = mWindowPositionSize.height;
1021 bool windowMoved = false, windowResized = false;
1023 if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
1028 if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
1030 windowResized = true;
1031 newWidth = tempWidth;
1032 newHeight = tempHeight;
1035 if(windowMoved || windowResized)
1037 Dali::PositionSize newPositionSize(ev->x, ev->y, newWidth, newHeight);
1038 mUpdatePositionSizeSignal.Emit(newPositionSize);
1041 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1045 void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
1047 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1049 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1051 Device::Class::Type deviceClass;
1052 Device::Subclass::Type deviceSubclass;
1054 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1055 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1057 PointState::Type state(PointState::DOWN);
1059 if(deviceClass != Device::Class::Type::MOUSE)
1061 // Check if the buttons field is set and ensure it's the primary touch button.
1062 // If this event was triggered by buttons other than the primary button (used for touch), then
1063 // just send an interrupted event to Core.
1064 if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
1066 state = PointState::INTERRUPTED;
1070 Integration::Point point;
1071 point.SetDeviceId(touchEvent->multi.device);
1072 point.SetState(state);
1073 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1074 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1075 point.SetPressure(touchEvent->multi.pressure);
1076 point.SetAngle(Degree(touchEvent->multi.angle));
1077 point.SetDeviceClass(deviceClass);
1078 point.SetDeviceSubclass(deviceSubclass);
1079 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1081 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1085 void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
1087 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1089 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1091 Device::Class::Type deviceClass;
1092 Device::Subclass::Type deviceSubclass;
1094 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1095 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1097 Integration::Point point;
1098 point.SetDeviceId(touchEvent->multi.device);
1099 point.SetState(PointState::UP);
1100 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1101 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1102 point.SetPressure(touchEvent->multi.pressure);
1103 point.SetAngle(Degree(touchEvent->multi.angle));
1104 point.SetDeviceClass(deviceClass);
1105 point.SetDeviceSubclass(deviceSubclass);
1106 point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
1108 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1112 void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
1114 Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
1116 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1118 Device::Class::Type deviceClass;
1119 Device::Subclass::Type deviceSubclass;
1121 GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
1122 GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
1124 Integration::Point point;
1125 point.SetDeviceId(touchEvent->multi.device);
1126 point.SetState(PointState::MOTION);
1127 point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
1128 point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
1129 point.SetPressure(touchEvent->multi.pressure);
1130 point.SetAngle(Degree(touchEvent->multi.angle));
1131 point.SetDeviceClass(deviceClass);
1132 point.SetDeviceSubclass(deviceSubclass);
1134 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1138 void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
1140 Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
1142 if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1144 Integration::Point point;
1145 point.SetDeviceId(touchEvent->multi.device);
1146 point.SetState(PointState::INTERRUPTED);
1147 point.SetScreenPosition(Vector2(0.0f, 0.0f));
1149 mTouchEventSignal.Emit(point, touchEvent->timestamp);
1151 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
1155 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
1157 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
1159 if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1161 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);
1163 Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
1165 mWheelEventSignal.Emit(wheelEvent);
1169 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
1171 Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
1173 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
1175 int direction = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1176 int timeStamp = detentEvent->timestamp;
1178 Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2(0.0f, 0.0f), 0, timeStamp);
1180 mWheelEventSignal.Emit(wheelEvent);
1183 void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
1185 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1187 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1189 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n");
1191 std::string keyName(keyEvent->keyname);
1192 std::string logicalKey("");
1193 std::string keyString("");
1194 std::string compose("");
1196 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1197 if(keyEvent->compose)
1199 compose = keyEvent->compose;
1202 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1205 logicalKey = keyEvent->key;
1209 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1213 // Get a specific key code from dali key look up table.
1214 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1217 keyCode = (keyCode == -1) ? 0 : keyCode;
1218 int modifier(keyEvent->modifiers);
1219 unsigned long time = keyEvent->timestamp;
1220 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1222 keyCode = atoi(keyEvent->keyname + 8);
1225 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1226 if(keyEvent->string)
1228 keyString = keyEvent->string;
1231 std::string deviceName;
1232 Device::Class::Type deviceClass;
1233 Device::Subclass::Type deviceSubclass;
1235 GetDeviceName(keyEvent, deviceName);
1236 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1237 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1239 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
1241 mKeyEventSignal.Emit(keyEvent);
1245 void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
1247 Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
1249 if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
1251 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n");
1253 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1254 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1255 if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
1257 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
1260 #endif // Since ecore 1.23 version
1262 std::string keyName(keyEvent->keyname);
1263 std::string logicalKey("");
1264 std::string keyString("");
1265 std::string compose("");
1267 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1268 if(keyEvent->compose)
1270 compose = keyEvent->compose;
1273 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1276 logicalKey = keyEvent->key;
1280 GetKeyCode(keyName, keyCode); // Get key code dynamically.
1284 // Get a specific key code from dali key look up table.
1285 keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
1288 keyCode = (keyCode == -1) ? 0 : keyCode;
1289 int modifier(keyEvent->modifiers);
1290 unsigned long time = keyEvent->timestamp;
1291 if(!strncmp(keyEvent->keyname, "Keycode-", 8))
1293 keyCode = atoi(keyEvent->keyname + 8);
1296 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1297 if(keyEvent->string)
1299 keyString = keyEvent->string;
1302 std::string deviceName;
1303 Device::Class::Type deviceClass;
1304 Device::Subclass::Type deviceSubclass;
1306 GetDeviceName(keyEvent, deviceName);
1307 GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
1308 GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
1310 Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
1312 mKeyEventSignal.Emit(keyEvent);
1316 void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
1318 mSelectionDataSendSignal.Emit(event);
1321 void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
1323 mSelectionDataReceivedSignal.Emit(event);
1326 void WindowBaseEcoreWl2::OnFontNameChanged()
1328 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
1331 void WindowBaseEcoreWl2::OnFontSizeChanged()
1333 mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
1336 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
1338 #ifdef DALI_ELDBUS_AVAILABLE
1339 AccessibilityInfo info;
1341 // The string defines the arg-list's respective types.
1342 if(!eldbus_message_arguments_get(message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime))
1344 DALI_LOG_ERROR("OnEcoreElDBusAccessibilityNotification: Error getting arguments\n");
1347 mAccessibilitySignal.Emit(info);
1351 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
1353 mTransitionEffectEventSignal.Emit(state, type);
1356 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1358 mKeyboardRepeatSettingsChangedSignal.Emit();
1361 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1363 mWindowRedrawRequestSignal.Emit();
1366 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
1368 Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
1369 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
1370 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
1373 mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
1377 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
1379 if(strcmp(interface, tizen_policy_interface.name) == 0)
1381 uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
1383 mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
1386 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
1390 tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
1392 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
1394 else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
1396 mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
1397 if(!mTizenDisplayPolicy)
1399 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
1403 tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
1405 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
1409 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
1411 mTizenPolicy = NULL;
1412 mTizenDisplayPolicy = NULL;
1415 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
1417 mNotificationLevel = level;
1418 mNotificationChangeState = state;
1419 mNotificationLevelChangeDone = true;
1421 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
1424 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
1426 mScreenOffMode = mode;
1427 mScreenOffModeChangeState = state;
1428 mScreenOffModeChangeDone = true;
1430 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
1433 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
1435 mBrightness = brightness;
1436 mBrightnessChangeState = state;
1437 mBrightnessChangeDone = true;
1439 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
1442 void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
1444 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1445 KeyCodeMap foundKeyCode;
1447 sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
1448 if(sym == XKB_KEY_NoSymbol)
1450 DALI_LOG_ERROR("Failed to get keysym in WindowBaseEcoreWl2\n");
1454 foundKeyCode.keySym = sym;
1455 foundKeyCode.isKeyCode = false;
1456 xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
1457 keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
1460 Any WindowBaseEcoreWl2::GetNativeWindow()
1462 return mEcoreWindow;
1465 int WindowBaseEcoreWl2::GetNativeWindowId()
1467 return ecore_wl2_window_id_get(mEcoreWindow);
1470 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
1472 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1473 if(totalAngle == 90 || totalAngle == 270)
1475 mEglWindow = wl_egl_window_create(mWlSurface, height, width);
1479 mEglWindow = wl_egl_window_create(mWlSurface, width, height);
1482 return static_cast<EGLNativeWindowType>(mEglWindow);
1485 void WindowBaseEcoreWl2::DestroyEglWindow()
1487 if(mEglWindow != NULL)
1489 wl_egl_window_destroy(mEglWindow);
1494 void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
1496 wl_egl_window_tizen_rotation rotation;
1502 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1507 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1512 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1517 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1522 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
1527 wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
1530 void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
1532 wl_output_transform bufferTransform;
1538 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1543 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1548 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1553 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1558 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1563 wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
1566 void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
1568 wl_output_transform windowTransform;
1574 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1579 windowTransform = WL_OUTPUT_TRANSFORM_90;
1584 windowTransform = WL_OUTPUT_TRANSFORM_180;
1589 windowTransform = WL_OUTPUT_TRANSFORM_270;
1594 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1599 wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
1602 void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
1604 wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
1606 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1607 if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
1609 wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
1610 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1614 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1617 wl_egl_window_tizen_capability capability = static_cast<wl_egl_window_tizen_capability>(wl_egl_window_tizen_get_capabilities(mEglWindow));
1618 if(capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED)
1620 mSupportedPreProtation = true;
1623 mSupportedPreProtation = false;
1627 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
1629 mWindowPositionSize = positionSize;
1630 ecore_wl2_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
1633 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
1635 mWindowPositionSize = positionSize;
1636 ecore_wl2_window_geometry_set(mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1639 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
1641 mWindowPositionSize = positionSize;
1642 ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
1645 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
1647 ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
1648 ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
1651 void WindowBaseEcoreWl2::Raise()
1653 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1654 ecore_wl2_window_activate(mEcoreWindow);
1657 void WindowBaseEcoreWl2::Lower()
1659 ecore_wl2_window_lower(mEcoreWindow);
1662 void WindowBaseEcoreWl2::Activate()
1664 ecore_wl2_window_activate(mEcoreWindow);
1667 void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
1669 int rotations[4] = {0};
1670 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size());
1671 for(std::size_t i = 0; i < angles.size(); ++i)
1673 rotations[i] = static_cast<int>(angles[i]);
1674 DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
1676 ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
1679 void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
1681 DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
1682 ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
1685 void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
1687 ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
1690 void WindowBaseEcoreWl2::Show()
1694 // Ecore-wl2 has the original window size
1695 // and he always sends the window rotation event with the swapped size.
1696 // So, to restore, dali should set the reswapped size(original window size) to ecore-wl2 for restoring.
1697 if(mWindowRotationAngle == 0 || mWindowRotationAngle == 180)
1699 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
1703 ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.height, mWindowPositionSize.width);
1708 ecore_wl2_window_show(mEcoreWindow);
1711 void WindowBaseEcoreWl2::Hide()
1714 ecore_wl2_window_hide(mEcoreWindow);
1717 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
1719 return mSupportedAuxiliaryHints.size();
1722 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
1724 if(index >= GetSupportedAuxiliaryHintCount())
1726 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
1729 return mSupportedAuxiliaryHints[index];
1732 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
1734 bool supported = false;
1736 // Check if the hint is suppported
1737 for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
1748 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
1752 // Check if the hint is already added
1753 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1755 if(mAuxiliaryHints[i].first == hint)
1757 // Just change the value
1758 mAuxiliaryHints[i].second = value;
1760 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
1762 return i + 1; // id is index + 1
1767 mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
1769 unsigned int id = mAuxiliaryHints.size();
1771 ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
1773 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
1778 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
1780 if(id == 0 || id > mAuxiliaryHints.size())
1782 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
1786 mAuxiliaryHints[id - 1].second = std::string();
1788 ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
1790 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
1795 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
1797 if(id == 0 || id > mAuxiliaryHints.size())
1799 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
1803 mAuxiliaryHints[id - 1].second = value;
1805 ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
1807 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());
1812 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
1814 if(id == 0 || id > mAuxiliaryHints.size())
1816 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
1817 return std::string();
1820 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());
1822 return mAuxiliaryHints[id - 1].second;
1825 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
1827 for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
1829 if(mAuxiliaryHints[i].first == hint)
1831 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
1836 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
1841 void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
1843 ecore_wl2_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
1846 void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
1848 Ecore_Wl2_Window_Type windowType;
1852 case Dali::WindowType::NORMAL:
1854 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1857 case Dali::WindowType::NOTIFICATION:
1859 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1862 case Dali::WindowType::UTILITY:
1864 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1867 case Dali::WindowType::DIALOG:
1869 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1874 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1879 ecore_wl2_window_type_set(mEcoreWindow, windowType);
1882 Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
1884 while(!mTizenPolicy)
1886 wl_display_dispatch_queue(mDisplay, mEventQueue);
1889 int notificationLevel;
1893 case Dali::WindowNotificationLevel::NONE:
1895 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1898 case Dali::WindowNotificationLevel::BASE:
1900 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1903 case Dali::WindowNotificationLevel::MEDIUM:
1905 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1908 case Dali::WindowNotificationLevel::HIGH:
1910 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1913 case Dali::WindowNotificationLevel::TOP:
1915 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1920 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
1921 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1926 mNotificationLevelChangeDone = false;
1927 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1929 tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
1933 while(!mNotificationLevelChangeDone && count < 3)
1935 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1936 wl_display_dispatch_queue(mDisplay, mEventQueue);
1940 if(!mNotificationLevelChangeDone)
1942 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
1943 Dali::WindowOperationResult::UNKNOWN_ERROR;
1945 else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1947 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
1948 return Dali::WindowOperationResult::PERMISSION_DENIED;
1951 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
1953 return Dali::WindowOperationResult::SUCCEED;
1956 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
1958 while(!mTizenPolicy)
1960 wl_display_dispatch_queue(mDisplay, mEventQueue);
1965 while(!mNotificationLevelChangeDone && count < 3)
1967 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1968 wl_display_dispatch_queue(mDisplay, mEventQueue);
1972 if(!mNotificationLevelChangeDone)
1974 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
1975 return Dali::WindowNotificationLevel::NONE;
1978 Dali::WindowNotificationLevel level;
1980 switch(mNotificationLevel)
1982 case TIZEN_POLICY_LEVEL_NONE:
1984 level = Dali::WindowNotificationLevel::NONE;
1987 case TIZEN_POLICY_LEVEL_DEFAULT:
1989 level = Dali::WindowNotificationLevel::BASE;
1992 case TIZEN_POLICY_LEVEL_MEDIUM:
1994 level = Dali::WindowNotificationLevel::MEDIUM;
1997 case TIZEN_POLICY_LEVEL_HIGH:
1999 level = Dali::WindowNotificationLevel::HIGH;
2002 case TIZEN_POLICY_LEVEL_TOP:
2004 level = Dali::WindowNotificationLevel::TOP;
2009 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
2010 level = Dali::WindowNotificationLevel::NONE;
2015 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
2020 void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
2022 while(!mTizenPolicy)
2024 wl_display_dispatch_queue(mDisplay, mEventQueue);
2027 tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
2030 Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
2032 while(!mTizenPolicy)
2034 wl_display_dispatch_queue(mDisplay, mEventQueue);
2037 mScreenOffModeChangeDone = false;
2038 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2040 unsigned int mode = 0;
2042 switch(screenOffMode)
2044 case WindowScreenOffMode::TIMEOUT:
2049 case WindowScreenOffMode::NEVER:
2056 tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
2060 while(!mScreenOffModeChangeDone && count < 3)
2062 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2063 wl_display_dispatch_queue(mDisplay, mEventQueue);
2067 if(!mScreenOffModeChangeDone)
2069 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
2070 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2072 else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2074 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
2075 return Dali::WindowOperationResult::PERMISSION_DENIED;
2078 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
2080 return Dali::WindowOperationResult::SUCCEED;
2083 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2085 while(!mTizenPolicy)
2087 wl_display_dispatch_queue(mDisplay, mEventQueue);
2092 while(!mScreenOffModeChangeDone && count < 3)
2094 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2095 wl_display_dispatch_queue(mDisplay, mEventQueue);
2099 if(!mScreenOffModeChangeDone)
2101 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
2102 return WindowScreenOffMode::TIMEOUT;
2105 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2107 switch(mScreenOffMode)
2111 screenMode = WindowScreenOffMode::TIMEOUT;
2116 screenMode = WindowScreenOffMode::NEVER;
2121 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
2126 Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
2128 while(!mTizenDisplayPolicy)
2130 wl_display_dispatch_queue(mDisplay, mEventQueue);
2133 mBrightnessChangeDone = false;
2134 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2136 tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
2140 while(!mBrightnessChangeDone && count < 3)
2142 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2143 wl_display_dispatch_queue(mDisplay, mEventQueue);
2147 if(!mBrightnessChangeDone)
2149 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
2150 return Dali::WindowOperationResult::UNKNOWN_ERROR;
2152 else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
2154 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
2155 return Dali::WindowOperationResult::PERMISSION_DENIED;
2158 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
2160 return Dali::WindowOperationResult::SUCCEED;
2163 int WindowBaseEcoreWl2::GetBrightness() const
2165 while(!mTizenDisplayPolicy)
2167 wl_display_dispatch_queue(mDisplay, mEventQueue);
2172 while(!mBrightnessChangeDone && count < 3)
2174 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
2175 wl_display_dispatch_queue(mDisplay, mEventQueue);
2179 if(!mBrightnessChangeDone)
2181 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
2185 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
2190 bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
2192 Ecore_Wl2_Window_Keygrab_Mode mode;
2196 case KeyGrab::TOPMOST:
2198 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2201 case KeyGrab::SHARED:
2203 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2206 case KeyGrab::OVERRIDE_EXCLUSIVE:
2208 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2211 case KeyGrab::EXCLUSIVE:
2213 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2222 return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
2225 bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
2227 return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
2230 bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
2232 int keyCount = key.Count();
2233 int keyGrabModeCount = grabMode.Count();
2235 if(keyCount != keyGrabModeCount || keyCount == 0)
2242 Eina_List* keyList = NULL;
2243 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2245 for(int index = 0; index < keyCount; ++index)
2247 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2249 switch(grabMode[index])
2251 case KeyGrab::TOPMOST:
2253 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2256 case KeyGrab::SHARED:
2258 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2261 case KeyGrab::OVERRIDE_EXCLUSIVE:
2263 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2266 case KeyGrab::EXCLUSIVE:
2268 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2273 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2278 keyList = eina_list_append(keyList, &info);
2281 Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
2283 result.Resize(keyCount, true);
2285 Eina_List* l = NULL;
2286 Eina_List* m = NULL;
2287 void* listData = NULL;
2289 if(grabList != NULL)
2291 EINA_LIST_FOREACH(grabList, m, data)
2294 EINA_LIST_FOREACH(keyList, l, listData)
2296 if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
2298 DALI_LOG_ERROR("input key list has null data!");
2302 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2304 result[index] = false;
2313 eina_list_free(keyList);
2314 eina_list_free(grabList);
2320 bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
2322 int keyCount = key.Count();
2330 Eina_List* keyList = NULL;
2331 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2333 for(int index = 0; index < keyCount; ++index)
2335 info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
2336 keyList = eina_list_append(keyList, &info);
2339 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
2341 result.Resize(keyCount, true);
2343 Eina_List* l = NULL;
2344 Eina_List* m = NULL;
2345 void* listData = NULL;
2348 if(ungrabList != NULL)
2350 EINA_LIST_FOREACH(ungrabList, m, data)
2353 EINA_LIST_FOREACH(keyList, l, listData)
2355 if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
2357 result[index] = false;
2366 eina_list_free(keyList);
2367 eina_list_free(ungrabList);
2373 void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
2378 Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
2380 // 1 inch = 25.4 millimeters
2381 xres = ecore_wl2_output_dpi_get(output);
2382 yres = ecore_wl2_output_dpi_get(output);
2384 dpiHorizontal = int(xres + 0.5f); // rounding
2385 dpiVertical = int(yres + 0.5f);
2388 int WindowBaseEcoreWl2::GetOrientation() const
2390 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2391 if(mSupportedPreProtation)
2398 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2402 if(ecore_wl2_window_ignore_output_transform_get(mEcoreWindow))
2408 transform = ecore_wl2_output_transform_get(ecore_wl2_window_output_find(mEcoreWindow));
2410 mScreenRotationAngle = transform * 90;
2411 return mScreenRotationAngle;
2414 void WindowBaseEcoreWl2::SetWindowRotationAngle(int degree)
2416 mWindowRotationAngle = degree;
2417 ecore_wl2_window_rotation_set(mEcoreWindow, degree);
2420 void WindowBaseEcoreWl2::WindowRotationCompleted(int degree, int width, int height)
2422 ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
2425 void WindowBaseEcoreWl2::SetTransparency(bool transparent)
2427 ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
2430 void WindowBaseEcoreWl2::InitializeEcoreElDBus()
2432 #ifdef DALI_ELDBUS_AVAILABLE
2433 Eldbus_Object* object;
2434 Eldbus_Proxy* manager;
2436 if(!(mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM)))
2438 DALI_LOG_ERROR("Unable to get system bus\n");
2441 object = eldbus_object_get(mSystemConnection, BUS, PATH);
2444 DALI_LOG_ERROR("Getting object failed\n");
2448 manager = eldbus_proxy_get(object, INTERFACE);
2451 DALI_LOG_ERROR("Getting proxy failed\n");
2455 if(!eldbus_proxy_signal_handler_add(manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this))
2457 DALI_LOG_ERROR("No signal handler returned\n");
2462 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
2464 Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
2467 DALI_ASSERT_ALWAYS(0 && "Failed to get display");
2470 ecore_wl2_display_sync(display);
2472 mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
2474 if(mEcoreWindow == 0)
2476 DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
2480 ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
2483 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase)
2485 Ecore_Wl2_Window* ecoreParent = NULL;
2488 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
2489 ecoreParent = winBaseEcore2->mEcoreWindow;
2491 ecore_wl2_window_parent_set(mEcoreWindow, ecoreParent);
2494 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2496 return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
2499 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2501 return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
2504 } // namespace Adaptor
2506 } // namespace Internal
2510 #pragma GCC diagnostic pop