/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
-const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
-const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
+/**
+ * @brief Enumeration of location for window resized by display server.
+ */
+enum class ResizeLocation
+{
+ INVALID = 0, ///< Invalid value
+ TOP_LEFT = 5, ///< Start resizing window to the top-left edge.
+ LEFT = 4, ///< Start resizing window to the left side.
+ BOTTOM_LEFT = 6, ///< Start resizing window to the bottom-left edge.
+ BOTTOM = 2, ///< Start resizing window to the bottom side.
+ BOTTOM_RIGHT = 10, ///< Start resizing window to the bottom-right edge.
+ RIGHT = 8, ///< Start resizing window to the right side.
+ TOP_RIGHT = 9, ///< Start resizing window to the top-right edge.
+ TOP = 1 ///< Start resizing window to the top side.
+};
+
+const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
+const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
+const ResizeLocation RESIZE_LOCATIONS[] = {ResizeLocation::TOP_LEFT, ResizeLocation::LEFT, ResizeLocation::BOTTOM_LEFT, ResizeLocation::BOTTOM, ResizeLocation::BOTTOM_RIGHT, ResizeLocation::RIGHT, ResizeLocation::TOP_RIGHT, ResizeLocation::TOP, ResizeLocation::INVALID};
#if defined(VCONF_ENABLED)
const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
}
}
+/**
+ * Return the recalculated window resizing location according to the current orientation.
+ */
+ResizeLocation RecalculateLocationToCurrentOrientation(WindowResizeDirection direction, int windowRotationAngle)
+{
+ int index = 8;
+ switch(direction)
+ {
+ case WindowResizeDirection::TOP_LEFT:
+ {
+ index = 0;
+ break;
+ }
+ case WindowResizeDirection::LEFT:
+ {
+ index = 1;
+ break;
+ }
+ case WindowResizeDirection::BOTTOM_LEFT:
+ {
+ index = 2;
+ break;
+ }
+ case WindowResizeDirection::BOTTOM:
+ {
+ index = 3;
+ break;
+ }
+ case WindowResizeDirection::BOTTOM_RIGHT:
+ {
+ index = 4;
+ break;
+ }
+ case WindowResizeDirection::RIGHT:
+ {
+ index = 5;
+ break;
+ }
+ case WindowResizeDirection::TOP_RIGHT:
+ {
+ index = 6;
+ break;
+ }
+ case WindowResizeDirection::TOP:
+ {
+ index = 7;
+ break;
+ }
+ default:
+ {
+ index = 8;
+ break;
+ }
+ }
+
+ if(index != 8 && windowRotationAngle != 0)
+ {
+ index = (index + (windowRotationAngle / 90) * 2) % 8;
+ }
+
+ return RESIZE_LOCATIONS[index];
+}
+
/////////////////////////////////////////////////////////////////////////////////////////////////
// Window Callbacks
/////////////////////////////////////////////////////////////////////////////////////////////////
}
/**
+ * Called when a mouse in is received.
+ */
+static Eina_Bool EcoreEventMouseIn(void* data, int type, void* event)
+{
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
+ {
+ windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::IN);
+ }
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+/**
+ * Called when a mouse out is received.
+ */
+static Eina_Bool EcoreEventMouseOut(void* data, int type, void* event)
+{
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
+ {
+ // When the mouse is out, the previous mouse must be canceled.
+ windowBase->OnMouseButtonCancel(data, type, event);
+ windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::OUT);
+ }
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+/**
* Called when a detent rotation event is recevied.
*/
static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
mWindowRotationAngle(0),
mScreenRotationAngle(0),
mSupportedPreProtation(0),
- mScreenWidth(0),
- mScreenHeight(0),
mNotificationChangeState(0),
mScreenOffModeChangeState(0),
mBrightnessChangeState(0),
// Register Mouse wheel events
mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
+ // Register Mouse IO events
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
+
// Register Detent event
mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_DOWN");
+
Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_UP");
+
Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_MOVE");
+
Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_CANCEL");
+
Integration::Point point;
point.SetDeviceId(touchEvent->multi.device);
point.SetState(PointState::INTERRUPTED);
if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_WHEEL");
+
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);
Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
}
}
+void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
+{
+ Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
+
+ if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
+ {
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
+
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseInOut: timestamp: %d, modifiers: %d, x: %d, y: %d\n", mouseInOutEvent->timestamp, mouseInOutEvent->modifiers, mouseInOutEvent->x, mouseInOutEvent->y);
+
+ Device::Class::Type deviceClass;
+ Device::Subclass::Type deviceSubclass;
+
+ GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
+
+ Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
+
+ mMouseInOutEventSignal.Emit(inOutEvent);
+ }
+}
+
void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
{
Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
std::string keyString("");
std::string compose("");
-#ifdef TRACE_ENABLED
- std::ostringstream stream;
- if(gTraceFilter->IsTraceEnabled())
- {
- stream << "DALI_ON_KEY_DOWN [" << keyName << "]\n";
- DALI_TRACE_BEGIN(gTraceFilter, stream.str().c_str());
- }
-#endif
+ DALI_TRACE_BEGIN(gTraceFilter, "DALI_ON_KEY_DOWN");
// Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
if(keyEvent->compose)
mKeyEventSignal.Emit(keyEvent);
-#ifdef TRACE_ENABLED
- if(gTraceFilter->IsTraceEnabled())
- {
- DALI_TRACE_END(gTraceFilter, stream.str().c_str());
- }
-#endif
+ DALI_TRACE_END(gTraceFilter, "DALI_ON_KEY_DOWN");
}
}
std::string keyString("");
std::string compose("");
-#ifdef TRACE_ENABLED
- std::ostringstream stream;
- if(gTraceFilter->IsTraceEnabled())
- {
- stream << "DALI_ON_KEY_UP [" << keyName << "]" << std::endl;
- DALI_TRACE_BEGIN(gTraceFilter, stream.str().c_str());
- }
-#endif
+ DALI_TRACE_BEGIN(gTraceFilter, "DALI_ON_KEY_UP");
// Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
if(keyEvent->compose)
mKeyEventSignal.Emit(keyEvent);
-#ifdef TRACE_ENABLED
- if(gTraceFilter->IsTraceEnabled())
- {
- DALI_TRACE_END(gTraceFilter, stream.str().c_str());
- }
-#endif
+ DALI_TRACE_END(gTraceFilter, "DALI_ON_KEY_UP");
}
}
PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
{
PositionSize newPositionSize;
+ int32_t screenWidth, screenHeight;
+ WindowSystem::GetScreenSize(screenWidth, screenHeight);
if(mWindowRotationAngle == 90)
{
newPositionSize.x = positionSize.y;
- newPositionSize.y = mScreenHeight - (positionSize.x + positionSize.width);
+ newPositionSize.y = screenHeight - (positionSize.x + positionSize.width);
newPositionSize.width = positionSize.height;
newPositionSize.height = positionSize.width;
}
else if(mWindowRotationAngle == 180)
{
- newPositionSize.x = mScreenWidth - (positionSize.x + positionSize.width);
- newPositionSize.y = mScreenHeight - (positionSize.y + positionSize.height);
+ newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
+ newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
newPositionSize.width = positionSize.width;
newPositionSize.height = positionSize.height;
}
else if(mWindowRotationAngle == 270)
{
- newPositionSize.x = mScreenWidth - (positionSize.y + positionSize.height);
+ newPositionSize.x = screenWidth - (positionSize.y + positionSize.height);
newPositionSize.y = positionSize.x;
newPositionSize.width = positionSize.height;
newPositionSize.height = positionSize.width;
PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
{
PositionSize newPositionSize;
+ int32_t screenWidth, screenHeight;
+ WindowSystem::GetScreenSize(screenWidth, screenHeight);
if(mWindowRotationAngle == 90)
{
- newPositionSize.x = mScreenHeight - (positionSize.y + positionSize.height);
+ newPositionSize.x = screenHeight - (positionSize.y + positionSize.height);
newPositionSize.y = positionSize.x;
newPositionSize.width = positionSize.height;
newPositionSize.height = positionSize.width;
}
else if(mWindowRotationAngle == 180)
{
- newPositionSize.x = mScreenWidth - (positionSize.x + positionSize.width);
- newPositionSize.y = mScreenHeight - (positionSize.y + positionSize.height);
+ newPositionSize.x = screenWidth - (positionSize.x + positionSize.width);
+ newPositionSize.y = screenHeight - (positionSize.y + positionSize.height);
newPositionSize.width = positionSize.width;
newPositionSize.height = positionSize.height;
}
else if(mWindowRotationAngle == 270)
{
newPositionSize.x = positionSize.y;
- newPositionSize.y = mScreenWidth - (positionSize.x + positionSize.width);
+ newPositionSize.y = screenWidth - (positionSize.x + positionSize.width);
newPositionSize.width = positionSize.height;
newPositionSize.height = positionSize.width;
}
ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
}
+void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
+{
+ DALI_LOG_RELEASE_INFO("ecore_wl2_window_layout_set, numCols[%d], numRows[%d], column[%d], row[%d], colSpan[%d], rowSpan[%d]\n", numCols, numRows, column, row, colSpan, rowSpan);
+ ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
+}
+
void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
{
ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
{
DALI_LOG_RELEASE_INFO("ecore_wl2_window_maximum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
ecore_wl2_window_maximum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
+ ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
}
void WindowBaseEcoreWl2::Minimize(bool minimize)
{
DALI_LOG_RELEASE_INFO("ecore_wl2_window_minimum_size_set, width: %d, height: %d\n", size.GetWidth(), size.GetHeight());
ecore_wl2_window_minimum_size_set(mEcoreWindow, size.GetWidth(), size.GetHeight());
+ ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
}
void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
return 0;
}
+Rect<int> WindowBaseEcoreWl2::RecalculateInputRect(const Rect<int>& rect)
+{
+ Rect<int> newRect;
+
+ if(mWindowRotationAngle == 90)
+ {
+ newRect.x = rect.y;
+ newRect.y = mWindowPositionSize.height - (rect.x + rect.width);
+ newRect.width = rect.height;
+ newRect.height = rect.width;
+ }
+ else if(mWindowRotationAngle == 180)
+ {
+ newRect.x = mWindowPositionSize.width - (rect.x + rect.width);
+ newRect.y = mWindowPositionSize.height - (rect.y + rect.height);
+ newRect.width = rect.width;
+ newRect.height = rect.height;
+ }
+ else if(mWindowRotationAngle == 270)
+ {
+ newRect.x = mWindowPositionSize.width - (rect.y + rect.height);
+ newRect.y = rect.x;
+ newRect.width = rect.height;
+ newRect.height = rect.width;
+ }
+ else
+ {
+ newRect.x = rect.x;
+ newRect.y = rect.y;
+ newRect.width = rect.width;
+ newRect.height = rect.height;
+ }
+ return newRect;
+}
+
void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
{
- ecore_wl2_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
+ Rect<int> convertRegion = RecalculateInputRect(inputRegion);
+
+ Eina_Rectangle rect;
+ rect.x = convertRegion.x;
+ rect.y = convertRegion.y;
+ rect.w = convertRegion.width;
+ rect.h = convertRegion.height;
+
+ DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
+ ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
+ ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
}
void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
windowType = ECORE_WL2_WINDOW_TYPE_NONE;
break;
}
+ case Dali::WindowType::DESKTOP:
+ {
+ windowType = ECORE_WL2_WINDOW_TYPE_DESKTOP;
+ break;
+ }
default:
{
windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
// Set default type
ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
-
- // Get Screen width, height
- ecore_wl2_display_screen_size_get(display, &mScreenWidth, &mScreenHeight);
}
void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
return;
}
- int location = 0;
- switch(direction)
- {
- case WindowResizeDirection::TOP_LEFT:
- {
- location = 5;
- break;
- }
- case WindowResizeDirection::TOP:
- {
- location = 1;
- break;
- }
- case WindowResizeDirection::TOP_RIGHT:
- {
- location = 9;
- break;
- }
- case WindowResizeDirection::LEFT:
- {
- location = 4;
- break;
- }
- case WindowResizeDirection::RIGHT:
- {
- location = 8;
- break;
- }
- case WindowResizeDirection::BOTTOM_LEFT:
- {
- location = 6;
- break;
- }
- case WindowResizeDirection::BOTTOM:
- {
- location = 2;
- break;
- }
- case WindowResizeDirection::BOTTOM_RIGHT:
- {
- location = 10;
- break;
- }
- default:
- {
- location = 0;
- break;
- }
- }
+ ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
- ecore_wl2_window_resize(mEcoreWindow, input, location);
- DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestResizeToServer, starts the window[%p] is resized by server, mode:%d\n", mEcoreWindow, location);
+ ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
+ DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestResizeToServer, starts the window[%p] is resized by server, direction:%d oriention:%d mode:%d\n", mEcoreWindow, direction, mWindowRotationAngle, location);
}
void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
{
+ Rect<int> convertRegion = RecalculateInputRect(inputRegion);
Eina_Rectangle rect;
- rect.x = inputRegion.x;
- rect.y = inputRegion.y;
- rect.w = inputRegion.width;
- rect.h = inputRegion.height;
+ rect.x = convertRegion.x;
+ rect.y = convertRegion.y;
+ rect.w = convertRegion.width;
+ rect.h = convertRegion.height;
+
+ DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
}
void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
{
+ Rect<int> convertRegion = RecalculateInputRect(inputRegion);
Eina_Rectangle rect;
- rect.x = inputRegion.x;
- rect.y = inputRegion.y;
- rect.w = inputRegion.width;
- rect.h = inputRegion.height;
+ rect.x = convertRegion.x;
+ rect.y = convertRegion.y;
+ rect.w = convertRegion.width;
+ rect.h = convertRegion.height;
+
+ DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
}