this event called when a device such as a mouse or keyboard is connected or disconnected
Change-Id: Ia8d70e87000514b691436732b148666d8a5c1b51
}
END_TEST;
}
+
+int UtcDaliWindowDeviceInfoSignalNegative(void)
+{
+ Dali::Window instance;
+ try
+ {
+ DevelWindow::DeviceInfoEventSignal(instance);
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(true); // We expect an assert
+ }
+ END_TEST;
+}
--- /dev/null
+#ifndef DALI_WINDOW_DEVEL_DEVICE_INFO_EVENT_H
+#define DALI_WINDOW_DEVEL_DEVICE_INFO_EVENT_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/events/device.h>
+#include <dali/public-api/math/vector2.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+namespace DevelWindow
+{
+/**
+ * @brief DeviceInfoEvent occurs when a device such as a mouse or keyboard is connected or disconnected.
+ *
+ * A signal is emitted whenever when a device such as a mouse or keyboard is connected or disconnected.
+ */
+struct DALI_ADAPTOR_API DeviceInfoEvent
+{
+ enum class Type
+ {
+ NONE = 0,
+ CONNECTED,
+ DISCONNECTED
+ };
+
+ /**
+ * @brief Constructor which creates a DeviceInfoEvent instance
+ * @param[in] type The type of the event.
+ * @param[in] name The device name.
+ * @param[in] identifier The identifier.
+ * @param[in] seatname The seat name.
+ * @param[in] deviceClass The device class the event originated from.
+ * @param[in] deviceSubclass The device subclass the event originated from.
+ */
+ DeviceInfoEvent(Type type, const std::string& name, const std::string& identifier, const std::string& seatname, const Device::Class::Type deviceClass, const Device::Subclass::Type deviceSubclass)
+ : type(type),
+ name(name),
+ identifier(identifier),
+ seatname(seatname),
+ deviceClass(deviceClass),
+ deviceSubclass(deviceSubclass)
+ {
+ }
+
+ Type type;
+ const std::string name;
+ const std::string identifier;
+ const std::string seatname;
+ const Device::Class::Type deviceClass;
+ const Device::Subclass::Type deviceSubclass;
+};
+
+} // namespace DevelWindow
+
+} // namespace Dali
+
+#endif // DALI_WINDOW_DEVEL_DEVICE_INFO_EVENT_H
return GetImplementation(window).MouseInOutEventSignal();
}
+DeviceInfoEventSignalType& DeviceInfoEventSignal(Window window)
+{
+ return GetImplementation(window).DeviceInfoEventSignal();
+}
+
} // namespace DevelWindow
} // namespace Dali
#include <memory>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/device-info-event.h>
#include <dali/devel-api/adaptor-framework/mouse-in-out-event.h>
#include <dali/public-api/adaptor-framework/window-enumerations.h>
#include <dali/public-api/adaptor-framework/window.h>
typedef Signal<void(Window, const Dali::DevelWindow::MouseInOutEvent&)> MouseInOutEventSignalType; ///< MouseInOutEvent signal type
typedef Signal<void(Window, Dali::Window::WindowPosition)> MoveCompletedSignalType; ///< Window Moved by Server signal type
typedef Signal<void(Window, Dali::Window::WindowSize)> ResizeCompletedSignalType; ///< Window Resized by Server signal type
+typedef Signal<void(Window, const Dali::DevelWindow::DeviceInfoEvent&)> DeviceInfoEventSignalType; ///< DeviceInfoEvent signal type
/**
* @brief Creates an initialized handle to a new Window.
*/
DALI_ADAPTOR_API ResizeCompletedSignalType& ResizeCompletedSignal(Window window);
+/**
+ * @brief This signal is emitted when the device info event is received.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName( Window window, Dali::DeviceInfoEvent event );
+ * @endcode
+ *
+ * @param[in] window The window instance.
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API DeviceInfoEventSignalType& DeviceInfoEventSignal(Window window);
+
} // namespace DevelWindow
} // namespace Dali
${adaptor_devel_api_dir}/adaptor-framework/capture-devel.h
${adaptor_devel_api_dir}/adaptor-framework/clipboard-event-notifier.h
${adaptor_devel_api_dir}/adaptor-framework/clipboard.h
+ ${adaptor_devel_api_dir}/adaptor-framework/device-info-event.h
${adaptor_devel_api_dir}/adaptor-framework/drag-and-drop.h
${adaptor_devel_api_dir}/adaptor-framework/color-controller-plugin.h
${adaptor_devel_api_dir}/adaptor-framework/color-controller.h
mAuxiliaryMessageSignal(),
mMouseInOutEventSignal(),
mMoveCompletedSignal(),
- mResizeCompletedSignal()
+ mResizeCompletedSignal(),
+ mDeviceInfoEventSignal()
{
}
return mResizeCompletedSignal;
}
+WindowBase::DeviceInfoEventSignalType& WindowBase::DeviceInfoEventSignal()
+{
+ return mDeviceInfoEventSignal;
+}
+
} // namespace Adaptor
} // namespace Internal
#include <vector>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/device-info-event.h>
#include <dali/devel-api/adaptor-framework/mouse-in-out-event.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/internal/graphics/gles/egl-implementation.h>
typedef Signal<void(const Dali::DevelWindow::MouseInOutEvent&)> MouseInOutEventSignalType;
typedef Signal<void(Dali::Int32Pair&)> MoveCompletedSignalType;
typedef Signal<void(Dali::Uint16Pair&)> ResizeCompletedSignalType;
+ typedef Signal<void(const Dali::DevelWindow::DeviceInfoEvent&)> DeviceInfoEventSignalType;
// Input events
typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
*/
ResizeCompletedSignalType& ResizeCompletedSignal();
+ /**
+ * @brief This signal is emitted when a device info event is recevied.
+ */
+ DeviceInfoEventSignalType& DeviceInfoEventSignal();
+
protected:
// Undefined
WindowBase(const WindowBase&) = delete;
MouseInOutEventSignalType mMouseInOutEventSignal;
MoveCompletedSignalType mMoveCompletedSignal;
ResizeCompletedSignalType mResizeCompletedSignal;
+ DeviceInfoEventSignalType mDeviceInfoEventSignal;
};
} // namespace Adaptor
mMouseInOutEventSignal(),
mMoveCompletedSignal(),
mResizeCompletedSignal(),
+ mDeviceInfoEventSignal(),
mLastKeyEvent(),
mLastTouchEvent(),
mIsTransparent(false),
mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
+ mWindowBase->DeviceInfoEventSignal().Connect(this, &Window::OnDeviceInfoEvent);
mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
bool isSetWithScreenSize = false;
if(mWindowWidth <= 0 || mWindowHeight <= 0)
{
- mWindowWidth = screenWidth;
- mWindowHeight = screenHeight;
+ mWindowWidth = screenWidth;
+ mWindowHeight = screenHeight;
isSetWithScreenSize = true;
DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
}
mMoveCompletedSignal.Emit(handle, position);
}
+void Window::OnDeviceInfoEvent(const Dali::DevelWindow::DeviceInfoEvent& deviceInfoEvent)
+{
+ Dali::Window handle(this);
+
+ mDeviceInfoEventSignal.Emit(handle, deviceInfoEvent);
+}
+
void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
{
Dali::Window handle(this);
using WindowPtr = IntrusivePtr<Window>;
using OrientationPtr = IntrusivePtr<Orientation>;
using MouseInOutEventPtr = IntrusivePtr<Dali::DevelWindow::MouseInOutEvent>;
+using DeviceInfoEventPtr = IntrusivePtr<Dali::DevelWindow::DeviceInfoEvent>;
using EventHandlerPtr = IntrusivePtr<EventHandler>;
/**
typedef Dali::DevelWindow::MouseInOutEventSignalType MouseInOutEventSignalType;
typedef Dali::DevelWindow::MoveCompletedSignalType MoveCompletedSignalType;
typedef Dali::DevelWindow::ResizeCompletedSignalType ResizeCompletedSignalType;
+ typedef Dali::DevelWindow::DeviceInfoEventSignalType DeviceInfoEventSignalType;
typedef Signal<void()> SignalType;
/**
void OnResizeCompleted(Dali::Window::WindowSize& size);
/**
+ * @brief Called when a device such as a mouse or keyboard is connected or disconnected.
+ * @param[in] deviceInfoEvent the device info event
+ */
+ void OnDeviceInfoEvent(const Dali::DevelWindow::DeviceInfoEvent& deviceInfoEvent);
+
+ /**
* @brief Set available orientation to window base.
*/
void SetAvailableAnlges(const std::vector<int>& angles);
return mResizeCompletedSignal;
}
+ /**
+ * @copydoc Dali::DevelWindow::DeviceInfoEventSignal()
+ */
+ DeviceInfoEventSignalType& DeviceInfoEventSignal()
+ {
+ return mDeviceInfoEventSignal;
+ }
+
private:
WindowRenderSurface* mWindowSurface; ///< The window rendering surface
WindowBase* mWindowBase;
std::vector<int> mAvailableAngles;
int mPreferredAngle;
- int mRotationAngle; ///< The angle of the rotation
- int mWindowWidth; ///< The width of the window
- int mWindowHeight; ///< The height of the window
- int mNativeWindowId; ///< The Native Window Id
+ int mRotationAngle; ///< The angle of the rotation
+ int mWindowWidth; ///< The width of the window
+ int mWindowHeight; ///< The height of the window
+ int mNativeWindowId; ///< The Native Window Id
EventHandlerPtr mEventHandler; ///< The window events handler
OrientationMode mOrientationMode; ///< The physical screen mode is portrait or landscape
MouseInOutEventSignalType mMouseInOutEventSignal;
MoveCompletedSignalType mMoveCompletedSignal;
ResizeCompletedSignalType mResizeCompletedSignal;
+ DeviceInfoEventSignalType mDeviceInfoEventSignal;
Dali::KeyEvent mLastKeyEvent;
Dali::TouchEvent mLastTouchEvent;
bool mOpaqueState : 1;
bool mWindowRotationAcknowledgement : 1;
bool mFocused : 1;
- bool mIsWindowRotating : 1; ///< The window rotating flag.
+ bool mIsWindowRotating : 1; ///< The window rotating flag.
bool mIsEnabledUserGeometry : 1; ///< The user geometry enable flag.
};
return ECORE_CALLBACK_RENEW;
}
+/////////////////////////////////////////////////////////////////////////////////////////////////
+// Window Device Info Callbacks
+/////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Called when a device is added.
+ */
+static Eina_Bool EcoreEventDeviceAdd(void* data, int type, void* event)
+{
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
+ {
+ windowBase->OnDeviceInfo(data, type, event, Dali::DevelWindow::DeviceInfoEvent::Type::CONNECTED);
+ }
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+/**
+ * Called when a device is removed
+ */
+static Eina_Bool EcoreEventDeviceDel(void* data, int type, void* event)
+{
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
+ {
+ windowBase->OnDeviceInfo(data, type, event, Dali::DevelWindow::DeviceInfoEvent::Type::DISCONNECTED);
+ }
+ return ECORE_CALLBACK_PASS_ON;
+}
+
static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
{
WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE, EcoreEventWindowMoveCompleted, this));
mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE, EcoreEventWindowResizeCompleted, this));
+ // Register Device Info
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DEVICE_ADD, EcoreEventDeviceAdd, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DEVICE_DEL, EcoreEventDeviceDel, this));
+
Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
mDisplay = ecore_wl2_display_get(display);
}
}
+void WindowBaseEcoreWl2::OnDeviceInfo(void* data, int type, void* event, Dali::DevelWindow::DeviceInfoEvent::Type action)
+{
+ Ecore_Event_Device_Info* deviceInfo = static_cast<Ecore_Event_Device_Info*>(event);
+
+ if(deviceInfo->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
+ {
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_DEVICE_INFO");
+
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnDeviceInfo: name: %s, identifier: %s, seatname: %s\n", deviceInfo->name, deviceInfo->identifier, deviceInfo->seatname);
+
+ std::string name(deviceInfo->name);
+ std::string identifier(deviceInfo->identifier);
+ std::string seatname(deviceInfo->seatname);
+
+ Device::Class::Type deviceClass;
+ Device::Subclass::Type deviceSubclass;
+
+ GetDeviceClass(deviceInfo->clas, deviceClass);
+ GetDeviceSubclass(deviceInfo->subclas, deviceSubclass);
+
+ Dali::DevelWindow::DeviceInfoEvent deviceInfoEvent(action, name, identifier, seatname, deviceClass, deviceSubclass);
+
+ mDeviceInfoEventSignal.Emit(deviceInfoEvent);
+ }
+}
+
void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
{
if(strcmp(interface, tizen_policy_interface.name) == 0)
void KeymapChanged(void* data, int type, void* event);
/**
+ * @brief Called when a device info changed.
+ */
+ void OnDeviceInfo(void* data, int type, void* event, Dali::DevelWindow::DeviceInfoEvent::Type action);
+
+ /**
* @brief RegistryGlobalCallback
*/
void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);