#include "DSKeyboard.h"
+#include "DSSeat.h"
+#include "DSWindow.h"
+#include "DSInputEvent.h"
+#include "DSWaylandKeyboard.h"
+#include "DSWaylandSurface.h"
namespace display_server
{
-DSKeyboard::DSKeyboard()
- : __seat(nullptr)
+DSKeyboard::DSKeyboard(DSSeat *seat)
+ : __seat(seat),
+ __dswlKeyboard(nullptr),
+ __dswlCompositor(nullptr),
+ __kbdFocus(nullptr)
{
+ if (nullptr == __dswlKeyboard)
+ {
+ //TODO : register slot for monitoring the creation of DSWaylandKeyboard
+ ;
+ }
}
-DSKeyboard::DSKeyboard(DSSeat *seat)
- : __seat(seat)
+DSKeyboard::DSKeyboard(DSSeat *seat, DSWaylandKeyboard *keyboard)
+ : __seat(seat),
+ __dswlKeyboard(keyboard),
+ __dswlCompositor(nullptr),
+ __kbdFocus(nullptr)
{
}
DSKeyboard::~DSKeyboard()
{}
+void DSKeyboard::processEvent(DSInputKeyboardEvent *ev, void *data)
+{
+ //TODO : get kbdFocus and send event to it via DSWaylandKeyboard instance
+
+ if (!__kbdFocus)
+ {
+ DSLOG_ERR("DSKeyboard", "No kbdFocus available.");
+ return;
+ }
+}
+
+void DSKeyboard::setFocus(std::shared_ptr<DSWindow> window)
+{
+ if (!window)
+ {
+ DSLOG_ERR("DSKeyboard", "Given window is INVALID. (window : %p)", window);
+ return;
+ }
+
+ DSWaylandSurface * waylandSurface = window->surface();
+
+ if (!waylandSurface)
+ {
+ DSLOG_ERR("DSKeyboard", "Wayland surface of the given window is INVALID. (window : %p, surface : %p)", window, waylandSurface);
+ return;
+ }
+
+ DSLOG_INF("DSKeyboard", "focus window has been changed. (%p -> %p)", __kbdFocus, window);
+ __kbdFocus = window;
+
+ if (!__dswlKeyboard)
+ {
+ DSLOG_ERR("DSKeyboard", "waylandKeyboard is NOT available !");
+ return;
+ }
+
+ __dswlKeyboard->setFocus(waylandSurface);
+
+}
+
+std::shared_ptr<DSWindow> DSKeyboard::getFocus()
+{
+ return __kbdFocus;
+}
+
} // namespace display_server
\ No newline at end of file
-#ifndef _DSKEYBOARD_H_
-#define _DSKEYBOARD_H_
+#ifndef __DSKEYBOARD_H__
+#define __DSKEYBOARD_H__
-#include <DSSeat.h>
+#include "DSCore.h"
+#include "DSObject.h"
namespace display_server
{
-class DSKeyboard
+class DSSeat;
+class DSWindow;
+class DSInputKeyboardEvent;
+class DSWaylandKeyboard;
+class DSWaylandCompositor;
+
+class DSKeyboard : public DSObject
{
public:
- DSKeyboard();
+ DSKeyboard() = delete;
DSKeyboard(DSSeat *seat);
+ DSKeyboard(DSSeat *seat, DSWaylandKeyboard *keyboard);
virtual ~DSKeyboard();
+ void processEvent(DSInputKeyboardEvent *ev, void *data);
+ void setFocus(std::shared_ptr<DSWindow> window);
+ std::shared_ptr<DSWindow> getFocus();
+
private:
DSSeat *__seat;
+ DSWaylandKeyboard *__dswlKeyboard;
+ DSWaylandCompositor *__dswlCompositor;
+ std::shared_ptr<DSWindow> __kbdFocus;
};
}
-#endif
\ No newline at end of file
+#endif //__DSKEYBOARD_H__
\ No newline at end of file
#include "DSPointer.h"
+#include "DSSeat.h"
+#include "DSWindow.h"
+#include "DSInputEvent.h"
+#include "DSWaylandPointer.h"
+#include "DSWaylandSurface.h"
namespace display_server
{
-DSPointer::DSPointer()
- : __seat(nullptr)
+DSPointer::DSPointer(DSSeat *seat)
+ : __seat(seat),
+ __dswlPointer(nullptr),
+ __dswlCompositor(nullptr),
+ __ptrFocus(nullptr)
{
}
-DSPointer::DSPointer(DSSeat *seat)
- : __seat(seat)
+DSPointer::DSPointer(DSSeat *seat, DSWaylandPointer *pointer)
+ : __seat(seat),
+ __dswlPointer(pointer),
+ __dswlCompositor(nullptr),
+ __ptrFocus(nullptr)
{
}
DSPointer::~DSPointer()
{}
+void DSPointer::processEvent(DSInputMouseEvent *ev, void *data)
+{
+ //TODO : get ptrFocus and send event to it via DSWaylandPointer instance
+
+ if (!__ptrFocus)
+ {
+ DSLOG_ERR("DSPointer", "No ptrFocus available.");
+ return;
+ }
+}
+
+void DSPointer::setFocus(std::shared_ptr<DSWindow> window)
+{
+ if (!window)
+ {
+ DSLOG_ERR("DSPointer", "Given window is INVALID. (window : %p)", window);
+ return;
+ }
+
+ DSWaylandSurface * waylandSurface = window->surface();
+
+ if (!waylandSurface)
+ {
+ DSLOG_ERR("DSPointer", "Wayland surface of the given window is INVALID. (window : %p, surface : %p)", window, waylandSurface);
+ return;
+ }
+
+ DSLOG_INF("DSPointer", "focus window has been changed. (%p -> %p)", __ptrFocus, window);
+ __ptrFocus = window;
+
+ if (!__dswlPointer)
+ {
+ DSLOG_ERR("DSPointer", "waylandPointer is NOT available !");
+ return;
+ }
+
+ __dswlPointer->setFocus(waylandSurface);
+}
+
+std::shared_ptr<DSWindow> DSPointer::getFocus()
+{
+ return __ptrFocus;
+}
+
} // namespace display_server
\ No newline at end of file
-#ifndef _DSKEYBOARD_H_
-#define _DSPOINTER_H_
+#ifndef __DSPOINTER_H__
+#define __DSPOINTER_H__
-#include <DSSeat.h>
+#include "DSCore.h"
+#include "DSObject.h"
namespace display_server
{
-class DSPointer
+class DSSeat;
+class DSWindow;
+class DSInputMouseEvent;
+class DSWaylandPointer;
+class DSWaylandCompositor;
+
+class DSPointer : public DSObject
{
public:
- DSPointer();
+ DSPointer() = delete;
DSPointer(DSSeat *seat);
+ DSPointer(DSSeat *seat, DSWaylandPointer *pointer);
virtual ~DSPointer();
+ void processEvent(DSInputMouseEvent *ev, void *data);
+ void setFocus(std::shared_ptr<DSWindow> window);
+ std::shared_ptr<DSWindow> getFocus();
+
private:
DSSeat *__seat;
+ DSWaylandPointer *__dswlPointer;
+ DSWaylandCompositor *__dswlCompositor;
+ std::shared_ptr<DSWindow> __ptrFocus;
};
}
-#endif
\ No newline at end of file
+#endif //__DSPOINTER_H__
\ No newline at end of file
#include "DSTouch.h"
+#include "DSSeat.h"
+#include "DSWindow.h"
+#include "DSInputEvent.h"
+#include "DSWaylandTouch.h"
namespace display_server
{
-DSTouch::DSTouch()
- : __seat(nullptr)
+DSTouch::DSTouch(DSSeat *seat)
+ : __seat(seat),
+ __dswlTouch(nullptr),
+ __dswlCompositor(nullptr),
+ __touchFocus(nullptr)
{
}
-DSTouch::DSTouch(DSSeat *seat)
- : __seat(seat)
+DSTouch::DSTouch(DSSeat *seat, DSWaylandTouch *touch)
+ : __seat(seat),
+ __dswlTouch(touch),
+ __dswlCompositor(nullptr),
+ __touchFocus(nullptr)
{
}
DSTouch::~DSTouch()
{}
+void DSTouch::processEvent(DSInputTouchEvent *ev, void *data)
+{
+ //TODO : get touchFocus and send event to it via DSWaylandTouch instance
+
+ if (!__touchFocus)
+ {
+ DSLOG_ERR("DSTouch", "No touchFocus available.");
+ return;
+ }
+}
+
+void DSTouch::setFocus(std::shared_ptr<DSWindow> window)
+{
+ if (!window)
+ {
+ DSLOG_ERR("DSTouch", "Given window is INVALID. (window : %p)", window);
+ return;
+ }
+
+ DSWaylandSurface * waylandSurface = window->surface();
+
+ if (!waylandSurface)
+ {
+ DSLOG_ERR("DSTouch", "Wayland surface of the given window is INVALID. (window : %p, surface : %p)", window, waylandSurface);
+ return;
+ }
+
+ DSLOG_INF("DSTouch", "focus window has been changed. (%p -> %p)", __touchFocus, window);
+ __touchFocus = window;
+
+ if (!__dswlTouch)
+ {
+ DSLOG_ERR("DSTouch", "waylandTouch is NOT available !");
+ return;
+ }
+
+ __dswlTouch->setFocus(waylandSurface);
+}
+
+std::shared_ptr<DSWindow> DSTouch::getFocus()
+{
+ return __touchFocus;
+}
+
} // namespace display_server
\ No newline at end of file
-#ifndef _DSTOUCH_H_
-#define _DSTOUCH_H_
+#ifndef __DSTOUCH_H__
+#define __DSTOUCH_H__
-#include <DSSeat.h>
+#include "DSCore.h"
+#include "DSObject.h"
namespace display_server
{
-class DSTouch
+class DSSeat;
+class DSWindow;
+class DSWaylandTouch;
+class DSInputTouchEvent;
+class DSWaylandCompositor;
+
+class DSTouch : public DSObject
{
public:
- DSTouch();
+ DSTouch() = delete;
DSTouch(DSSeat *seat);
+ DSTouch(DSSeat *seat, DSWaylandTouch *touch);
virtual ~DSTouch();
+ void processEvent(DSInputTouchEvent *ev, void *data);
+ void setFocus(std::shared_ptr<DSWindow> window);
+ std::shared_ptr<DSWindow> getFocus();
+
private:
DSSeat *__seat;
+ DSWaylandTouch *__dswlTouch;
+ DSWaylandCompositor *__dswlCompositor;
+ std::shared_ptr<DSWindow> __touchFocus;
};
}
-#endif
\ No newline at end of file
+#endif //__DSTOUCH_H__
\ No newline at end of file
--- /dev/null
+#include "libds-tests.h"
+#include "DSKeyboard.h"
+#include "DSSeat.h"
+#include "DSWaylandKeyboard.h"
+#include "DSWaylandSeat.h"
+#include "DSWaylandCompositor.h"
+#include "DSWindow.h"
+
+using namespace display_server;
+
+class DSKeyboardTest : public ::testing::Test
+{
+public:
+ void SetUp(void) override
+ {
+ setenv("XDG_RUNTIME_DIR", "/run", 1);
+ }
+ void TearDown(void) override
+ {
+ unsetenv("XDG_RUNTIME_DIR");
+ }
+};
+
+TEST_F(DSKeyboardTest, NewDSKeyboardWithDSSeat)
+{
+ auto seat = new DSSeat();
+ EXPECT_TRUE(seat != nullptr);
+
+ if (seat)
+ {
+ auto keyboard = new DSKeyboard(seat);
+ EXPECT_TRUE(keyboard != nullptr);
+ }
+}
+
+TEST_F(DSKeyboardTest, NewDSKeyboardWithDSWaylandKeyboard)
+{
+ auto waylandCompositor = DSWaylandCompositor::getInstance();
+ EXPECT_TRUE(waylandCompositor != nullptr);
+
+ if (waylandCompositor)
+ {
+ auto seat = new DSSeat();
+ EXPECT_TRUE(seat != nullptr);
+
+ auto waylandSeat = new DSWaylandSeat(waylandCompositor, DSWaylandSeat::capAll);
+ EXPECT_TRUE(waylandSeat != nullptr);
+
+ if (seat && waylandSeat)
+ {
+ auto waylandKeyboard = new DSWaylandKeyboard(waylandSeat);
+ EXPECT_TRUE(waylandKeyboard != nullptr);
+
+ if (waylandKeyboard)
+ {
+ auto keyboard = new DSKeyboard(seat, waylandKeyboard);
+ EXPECT_TRUE(keyboard != nullptr);
+ }
+ }
+
+ DSWaylandCompositor::releaseInstance();
+ }
+
+}
+TEST_F(DSKeyboardTest, BasicMethods)
+{
+ auto seat = new DSSeat();
+ EXPECT_TRUE(seat != nullptr);
+
+ auto window = std::make_shared<DSWindow>();
+ EXPECT_TRUE(window != nullptr);
+
+ if (seat && window)
+ {
+ auto keyboard = new DSKeyboard(seat);
+ EXPECT_TRUE(keyboard != nullptr);
+
+ if (keyboard)
+ {
+ keyboard->setFocus(window);
+ EXPECT_TRUE(window == keyboard->getFocus());
+ }
+ }
+}
--- /dev/null
+#include "libds-tests.h"
+#include "DSPointer.h"
+#include "DSSeat.h"
+#include "DSWaylandPointer.h"
+#include "DSWaylandSeat.h"
+#include "DSWaylandCompositor.h"
+#include "DSWindow.h"
+
+using namespace display_server;
+
+class DSPointerTest : public ::testing::Test
+{
+public:
+ void SetUp(void) override
+ {
+ setenv("XDG_RUNTIME_DIR", "/run", 1);
+ }
+ void TearDown(void) override
+ {
+ unsetenv("XDG_RUNTIME_DIR");
+ }
+};
+
+TEST_F(DSPointerTest, NewDSPointerWithDSSeat)
+{
+ auto seat = new DSSeat();
+ EXPECT_TRUE(seat != nullptr);
+
+ if (seat)
+ {
+ auto pointer = new DSPointer(seat);
+ EXPECT_TRUE(pointer != nullptr);
+ }
+}
+
+TEST_F(DSPointerTest, NewDSPointerWithDSWaylandPointer)
+{
+ auto waylandCompositor = DSWaylandCompositor::getInstance();
+ EXPECT_TRUE(waylandCompositor != nullptr);
+
+ if (waylandCompositor)
+ {
+ auto seat = new DSSeat();
+ EXPECT_TRUE(seat != nullptr);
+
+ auto waylandSeat = new DSWaylandSeat(waylandCompositor, DSWaylandSeat::capAll);
+ EXPECT_TRUE(waylandSeat != nullptr);
+
+ if (seat && waylandSeat)
+ {
+ auto waylandPointer = new DSWaylandPointer(waylandSeat);
+ EXPECT_TRUE(waylandPointer != nullptr);
+
+ if (waylandPointer)
+ {
+ auto pointer = new DSPointer(seat, waylandPointer);
+ EXPECT_TRUE(pointer != nullptr);
+ }
+ }
+
+ DSWaylandCompositor::releaseInstance();
+ }
+
+}
+TEST_F(DSPointerTest, BasicMethods)
+{
+ auto seat = new DSSeat();
+ EXPECT_TRUE(seat != nullptr);
+
+ auto window = std::make_shared<DSWindow>();
+ EXPECT_TRUE(window != nullptr);
+
+ if (seat && window)
+ {
+ auto pointer = new DSPointer(seat);
+ EXPECT_TRUE(pointer != nullptr);
+
+ if (pointer)
+ {
+ pointer->setFocus(window);
+ EXPECT_TRUE(window == pointer->getFocus());
+ }
+ }
+}
--- /dev/null
+#include "libds-tests.h"
+#include "DSTouch.h"
+#include "DSSeat.h"
+#include "DSWaylandTouch.h"
+#include "DSWaylandSeat.h"
+#include "DSWaylandCompositor.h"
+#include "DSWindow.h"
+
+using namespace display_server;
+
+class DSTouchTest : public ::testing::Test
+{
+public:
+ void SetUp(void) override
+ {
+ setenv("XDG_RUNTIME_DIR", "/run", 1);
+ }
+ void TearDown(void) override
+ {
+ unsetenv("XDG_RUNTIME_DIR");
+ }
+};
+
+TEST_F(DSTouchTest, NewDSTouchWithDSSeat)
+{
+ auto seat = new DSSeat();
+ EXPECT_TRUE(seat != nullptr);
+
+ if (seat)
+ {
+ auto touch = new DSTouch(seat);
+ EXPECT_TRUE(touch != nullptr);
+ }
+}
+
+TEST_F(DSTouchTest, NewDSTouchWithDSWaylandTouch)
+{
+ auto waylandCompositor = DSWaylandCompositor::getInstance();
+ EXPECT_TRUE(waylandCompositor != nullptr);
+
+ if (waylandCompositor)
+ {
+ auto seat = new DSSeat();
+ EXPECT_TRUE(seat != nullptr);
+
+ auto waylandSeat = new DSWaylandSeat(waylandCompositor, DSWaylandSeat::capAll);
+ EXPECT_TRUE(waylandSeat != nullptr);
+
+ if (seat && waylandSeat)
+ {
+ auto waylandTouch = new DSWaylandTouch(waylandSeat);
+ EXPECT_TRUE(waylandTouch != nullptr);
+
+ if (waylandTouch)
+ {
+ auto touch = new DSTouch(seat, waylandTouch);
+ EXPECT_TRUE(touch != nullptr);
+ }
+ }
+
+ DSWaylandCompositor::releaseInstance();
+ }
+
+}
+TEST_F(DSTouchTest, BasicMethods)
+{
+ auto seat = new DSSeat();
+ EXPECT_TRUE(seat != nullptr);
+
+ auto window = std::make_shared<DSWindow>();
+ EXPECT_TRUE(window != nullptr);
+
+ if (seat && window)
+ {
+ auto touch = new DSTouch(seat);
+ EXPECT_TRUE(touch != nullptr);
+
+ if (touch)
+ {
+ touch->setFocus(window);
+ EXPECT_TRUE(window == touch->getFocus());
+ }
+ }
+}
'DSWaylandInputPanel-test.cpp',
'DSWaylandInputPanelSurface-test.cpp',
'DSXkb-test.cpp',
+ 'DSPointer-test.cpp',
+ 'DSKeyboard-test.cpp',
+ 'DSTouch-test.cpp',
]
gmock_dep = dependency('gmock', method : 'pkg-config')