From 26ebb924e0882f11176e9714133653630087016b Mon Sep 17 00:00:00 2001 From: jeon Date: Tue, 21 Jul 2020 19:22:00 +0900 Subject: [PATCH 01/16] DSInput: add DSInputEvent classes Change-Id: I25bb02923328ce671468712e8d88097da052a3b8 --- src/DSInput/DSInput.cpp | 138 +++++++++++++++++++++++++++++++++++++++++++++ src/DSInput/DSInputEvent.h | 103 +++++++++++++++++++++++++++++++++ src/meson.build | 1 + 3 files changed, 242 insertions(+) create mode 100644 src/DSInput/DSInputEvent.h diff --git a/src/DSInput/DSInput.cpp b/src/DSInput/DSInput.cpp index af2eebf..28bd088 100644 --- a/src/DSInput/DSInput.cpp +++ b/src/DSInput/DSInput.cpp @@ -1,6 +1,7 @@ #include "DSInput.h" #include "DSInputPrivate.h" #include "DSSeat.h" +#include "DSInputEvent.h" namespace display_server { @@ -191,4 +192,141 @@ void DSInputDevice::setSubclass(DSInput::DeviceSubclass devSubclass) __deviceSubclass = devSubclass; } +DSInputEvent::DSInputEvent(std::shared_ptr device, Type type, int timestamp) + : __device(device), + __type(type), + __timestamp(timestamp) +{ +} + +DSInputEvent::~DSInputEvent() +{ +} + +std::shared_ptr DSInputEvent::getDevice() +{ + return __device; +} + +const DSInputEvent::Type DSInputEvent::getType() +{ + return __type; +} + +const int DSInputEvent::getTimestamp() +{ + return __timestamp; +} + +void DSInputEvent::registerEventDeviceBroadcater(DSObject *slot, std::function)> func) +{ + __eventDeviceBroadCastSignal.connect(slot, func); +} + +void DSInputEvent::eventDeviceBroadcast(std::shared_ptr device) +{ + __eventDeviceBroadCastSignal.emit(device); +} + +DSInputKeyboardEvent::DSInputKeyboardEvent() + : DSInputEvent(nullptr, NoneEvent, 0), + __keycode(0), + __keyname("") +{ +} + +DSInputKeyboardEvent::DSInputKeyboardEvent(std::shared_ptr device, Type type, int timestamp, int keycode) + : DSInputEvent(device, type, timestamp), + __keycode(keycode), + __keyname("") +{ + /* FIXME: __keyname will be defined after xkb is implied */ +} + + +DSInputKeyboardEvent::~DSInputKeyboardEvent() +{ +} + +const int DSInputKeyboardEvent::getKeycode() +{ + return __keycode; +} + +const std::string DSInputKeyboardEvent::getKeyname() +{ + return __keyname; +} + + +DSInputMouseEvent::DSInputMouseEvent() + : DSInputEvent(nullptr, NoneEvent, 0), + __button(0), __x(0), __y(0), __z(0) +{ +} + +DSInputMouseEvent::DSInputMouseEvent(std::shared_ptr device, Type type, int timestamp, int button, int x, int y, int z) + : DSInputEvent(device, type, timestamp), + __button(button), __x(x), __y(y), __z(z) +{ +} + + +DSInputMouseEvent::~DSInputMouseEvent() +{ +} + +const int DSInputMouseEvent::getButton() +{ + return __button; +} + +const int DSInputMouseEvent::getX() +{ + return __x; +} + +const int DSInputMouseEvent::getY() +{ + return __y; +} + +const int DSInputMouseEvent::getZ() +{ + return __z; +} + + +DSInputTouchEvent::DSInputTouchEvent() + : DSInputEvent(nullptr, NoneEvent, 0), + __index(0), __x(0), __y(0) +{ +} + +DSInputTouchEvent::DSInputTouchEvent(std::shared_ptr device, Type type, int timestamp, int index, int x, int y) + : DSInputEvent(device, type, timestamp), + __index(index), __x(x), __y(y) +{ +} + +DSInputTouchEvent::~DSInputTouchEvent() +{ +} + +const int DSInputTouchEvent::getIndex() +{ + return __index; +} + +const int DSInputTouchEvent::getX() +{ + return __x; +} + +const int DSInputTouchEvent::getY() +{ + return __y; +} + + } // namespace display_server diff --git a/src/DSInput/DSInputEvent.h b/src/DSInput/DSInputEvent.h new file mode 100644 index 0000000..a412a83 --- /dev/null +++ b/src/DSInput/DSInputEvent.h @@ -0,0 +1,103 @@ +#ifndef _DS_INPUT_EVENT_H_ +#define _DS_INPUT_EVENT_H_ + +#include "DSInput.h" + +namespace display_server +{ + +class DSInputEvent +{ +public: + enum Type { + NoneEvent, + KeyEnterEvent, + KeyLeaveEvent, + KeyDownEvent, + KeyUpEvent, + MouseInEvent, + MouseOutEvent, + MouseDownEvent, + MouseMoveEvent, + MouseUpEvent, + MouseWheelEvent, + MouseHWheelEvent, + TouchDownEvent, + TOuchMoveEvent, + TouchUpEvent + }; + + DSInputEvent(std::shared_ptr device, Type type, int timestamp); + virtual ~DSInputEvent(); + + std::shared_ptr getDevice(); + const Type getType(); + const int getTimestamp(); + //DSWindow getTargetWindow(); + + void registerEventDeviceBroadcater(DSObject *slot, std::function)> func); + void eventDeviceBroadcast(std::shared_ptr device); + +protected: + std::shared_ptr __device; + Type __type; + int __timestamp; + DSSignal> __eventDeviceBroadCastSignal; + //DSWindow __targetWindow; +}; + +class DSInputKeyboardEvent : public DSInputEvent +{ +public: + DSInputKeyboardEvent(); + DSInputKeyboardEvent(std::shared_ptr device, Type type, int timestamp, int keycode); + ~DSInputKeyboardEvent() override; + + const int getKeycode(); + const std::string getKeyname(); + +protected: + int __keycode; + std::string __keyname; +}; + +class DSInputMouseEvent : public DSInputEvent +{ +public: + DSInputMouseEvent(); + DSInputMouseEvent(std::shared_ptr device, Type type, int timestamp, int button, int x, int y, int z); + ~DSInputMouseEvent() override; + + const int getButton(); + const int getX(); + const int getY(); + const int getZ(); + +protected: + int __button; + int __x; + int __y; + int __z; +}; + +class DSInputTouchEvent : public DSInputEvent +{ +public: + DSInputTouchEvent(); + DSInputTouchEvent(std::shared_ptr device, Type type, int timestamp, int index, int x, int y); + ~DSInputTouchEvent() override; + + const int getIndex(); + const int getX(); + const int getY(); + +protected: + int __index; + int __x; + int __y; +}; + +} + +#endif + diff --git a/src/meson.build b/src/meson.build index 855d5ef..44d76c5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -18,6 +18,7 @@ libds_srcs = [ 'DSInput/DSInput.cpp', 'DSInput/DSInput.h', 'DSInput/DSInputPrivate.h', + 'DSInput/DSInputEvent.h', 'DSInput/DSLibinput.cpp', 'DSInput/DSLibinput.h', 'DSObject/DSObject.cpp', -- 2.7.4 From 3697ac9584241d04f658a9126b18614ac24e12d9 Mon Sep 17 00:00:00 2001 From: jeon Date: Wed, 22 Jul 2020 19:53:14 +0900 Subject: [PATCH 02/16] DSInput: Get input events using DSLibinput Change-Id: I54e2548a9d676dd65ae96d524a12873168f7a14d --- src/DSInput/DSInput.cpp | 108 +++++++++++++++++++++++++++++++++++++++++++ src/DSInput/DSInput.h | 18 ++++++++ src/DSInput/DSInputEvent.h | 2 +- src/DSInput/DSInputPrivate.h | 4 ++ src/DSInput/DSLibinput.cpp | 79 ++++++++++++++++++++++++++++--- src/meson.build | 2 +- 6 files changed, 204 insertions(+), 9 deletions(-) diff --git a/src/DSInput/DSInput.cpp b/src/DSInput/DSInput.cpp index 28bd088..ba01dfe 100644 --- a/src/DSInput/DSInput.cpp +++ b/src/DSInput/DSInput.cpp @@ -39,6 +39,41 @@ void DSInputPrivate::PostDeviceRemoveEvent(std::string seat, std::string name, s pub->deviceRemove(name, identifier, devClass, DSInput::NoneSubclass); } +void DSInputPrivate::PostKeyboardEvent(int keycode, bool pressed, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + DS_GET_PUB(DSInput); + + if (pressed) + pub->keyDown(keycode, devIdentifier, devClass); + else + pub->keyUp(keycode, devIdentifier, devClass); +} + +void DSInputPrivate::PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + DS_GET_PUB(DSInput); + + if (type == DSInputEvent::MouseDownEvent) + pub->mouseDown(button, x, y, z, devIdentifier, devClass); + else if (type == DSInputEvent::MouseMoveEvent) + pub->mouseMove(button, x, y, z, devIdentifier, devClass); + else if (type == DSInputEvent::MouseUpEvent) + pub->mouseUp(button, x, y, z, devIdentifier, devClass); +} + +void DSInputPrivate::PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + DS_GET_PUB(DSInput); + + if (type == DSInputEvent::TouchDownEvent) + pub->touchDown(index, x, y, devIdentifier, devClass); + else if (type == DSInputEvent::TouchMoveEvent) + pub->touchMove(index, x, y, devIdentifier, devClass); + else if (type == DSInputEvent::TouchUpEvent) + pub->touchUp(index, x, y, devIdentifier, devClass); +} + + DSInput::DSInput() : DS_INIT_PRIVATE_PTR(DSInput), __seat(nullptr) @@ -104,6 +139,47 @@ void DSInput::deviceRemove(std::string name, std::string identifier, DSInput::De delete device; } +void DSInput::keyDown(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + std::cout << "[keyDown] keycode: " << keycode << ", identifier: " << devIdentifier << std::endl; +} + +void DSInput::keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + std::cout << "[keyUp] keycode: " << keycode << ", identifier: " << devIdentifier << std::endl; +} + +void DSInput::mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + std::cout << "[mouseDown] button: " << button << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; +} + +void DSInput::mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + std::cout << "[mouseMove] button: " << button << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; +} + +void DSInput::mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + std::cout << "[mouseUp] button: " << button << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; +} + +void DSInput::touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + std::cout << "[touchDown] index: " << index << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; +} + +void DSInput::touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + std::cout << "[touchMove] index: " << index << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; +} + +void DSInput::touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass) +{ + std::cout << "[touchUp] index: " << index << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; +} + + void DSInput::registerCallbackDeviceAdd(DSObject *slot, std::function)> func) { this->__deviceAddSignal.connect(slot, func); @@ -114,6 +190,38 @@ void DSInput::registerCallbackDeviceRemove(DSObject *slot, std::function__deviceRemoveSignal.connect(slot, func); } +void DSInput::registerCallbackKeyDown(DSObject *slot, std::function func) +{ +} + +void DSInput::registerCallbackKeyUp(DSObject *slot, std::function func) +{ +} + +void DSInput::registerCallbackMouseDown(DSObject *slot, std::function func) +{ +} + +void DSInput::registerCallbackMouseMove(DSObject *slot, std::function func) +{ +} + +void DSInput::registerCallbackMouseUp(DSObject *slot, std::function func) +{ +} + +void DSInput::registerCallbackTouchDown(DSObject *slot, std::function func) +{ +} + +void DSInput::registerCallbackTouchMove(DSObject *slot, std::function func) +{ +} + +void DSInput::registerCallbackTouchUp(DSObject *slot, std::function func) +{ +} + DSInputDevice::DSInputDevice() : __deviceName(""), diff --git a/src/DSInput/DSInput.h b/src/DSInput/DSInput.h index 26b150b..e796bdc 100644 --- a/src/DSInput/DSInput.h +++ b/src/DSInput/DSInput.h @@ -9,6 +9,8 @@ #include #include +#include + namespace display_server { @@ -38,9 +40,25 @@ public: void deviceAdd(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass); void deviceRemove(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass); + void keyDown(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass); + void keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass); + void mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass); + void mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass); + void mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass); + void touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass); + void touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass); + void touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass); void registerCallbackDeviceAdd(DSObject *slot, std::function)> func); void registerCallbackDeviceRemove(DSObject *slot, std::function)> func); + void registerCallbackKeyDown(DSObject *slot, std::function func); + void registerCallbackKeyUp(DSObject *slot, std::function func); + void registerCallbackMouseDown(DSObject *slot, std::function func); + void registerCallbackMouseMove(DSObject *slot, std::function func); + void registerCallbackMouseUp(DSObject *slot, std::function func); + void registerCallbackTouchDown(DSObject *slot, std::function func); + void registerCallbackTouchMove(DSObject *slot, std::function func); + void registerCallbackTouchUp(DSObject *slot, std::function func); private: DSSeat* __seat; diff --git a/src/DSInput/DSInputEvent.h b/src/DSInput/DSInputEvent.h index a412a83..7a8f75e 100644 --- a/src/DSInput/DSInputEvent.h +++ b/src/DSInput/DSInputEvent.h @@ -23,7 +23,7 @@ public: MouseWheelEvent, MouseHWheelEvent, TouchDownEvent, - TOuchMoveEvent, + TouchMoveEvent, TouchUpEvent }; diff --git a/src/DSInput/DSInputPrivate.h b/src/DSInput/DSInputPrivate.h index 8d566eb..8b95b81 100644 --- a/src/DSInput/DSInputPrivate.h +++ b/src/DSInput/DSInputPrivate.h @@ -3,6 +3,7 @@ #include "DSInput.h" #include "DSLibinput.h" +#include "DSInputEvent.h" namespace display_server { @@ -21,6 +22,9 @@ public: void PostDeviceAddEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass); void PostDeviceRemoveEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass); + void PostKeyboardEvent(int keycode, bool pressed, std::string devIdentifier, DSInput::DeviceClass devClass); + void PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass); + void PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass); private: DSLibinput *__dsLibinput; diff --git a/src/DSInput/DSLibinput.cpp b/src/DSInput/DSLibinput.cpp index d766da3..3c07ec6 100644 --- a/src/DSInput/DSLibinput.cpp +++ b/src/DSInput/DSLibinput.cpp @@ -178,14 +178,33 @@ void DSLibinput::__processDeviceRemoveEvent(struct ::libinput_event *event) } } -void DSLibinput::__processKeyboardKeyEvent(struct ::libinput_event *event) +void DSLibinput::__processKeyboardKeyEvent(struct:: libinput_event *event) { - ; + struct:: libinput_event_keyboard *keyboard_event = libinput_event_get_keyboard_event(event); + int keycode = libinput_event_keyboard_get_key(keyboard_event) + 8; + int state = libinput_event_keyboard_get_key_state(keyboard_event); + bool pressed; + if (state == LIBINPUT_KEY_STATE_PRESSED) pressed = true; + else pressed = false; + + struct ::libinput_device *device = libinput_event_get_device(event); + std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); + + inputPrivate->PostKeyboardEvent(keycode, pressed, identifier, DSInput::KeyboardClass); } void DSLibinput::__processPointerMotionEvent(struct ::libinput_event *event) { - ; + struct:: libinput_event_pointer *pointer_event = libinput_event_get_pointer_event(event); + int dx, dy; + + struct ::libinput_device *device = libinput_event_get_device(event); + std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); + + dx = libinput_event_pointer_get_dx(pointer_event); + dy = libinput_event_pointer_get_dy(pointer_event); + + inputPrivate->PostPointerEvent(0, dx, dy, 0, DSInputEvent::MouseMoveEvent, identifier, DSInput::PointerClass); } void DSLibinput::__processPointerMotionAbsoluteEvent(struct ::libinput_event *event) @@ -195,7 +214,23 @@ void DSLibinput::__processPointerMotionAbsoluteEvent(struct ::libinput_event *ev void DSLibinput::__processPointerButtonEvent(struct ::libinput_event *event) { - ; + struct:: libinput_event_pointer *pointer_event = libinput_event_get_pointer_event(event); + DSInputEvent::Type eventType; + int button; + int state; + + struct ::libinput_device *device = libinput_event_get_device(event); + std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); + + button = libinput_event_pointer_get_button(pointer_event); + state = libinput_event_pointer_get_button_state(pointer_event); + + if (state) + eventType = DSInputEvent::MouseDownEvent; + else + eventType = DSInputEvent::MouseUpEvent; + + inputPrivate->PostPointerEvent(button, 0, 0, 0, eventType, identifier, DSInput::PointerClass); } void DSLibinput::__processPointerAxisEvent(struct ::libinput_event *event) @@ -205,17 +240,47 @@ void DSLibinput::__processPointerAxisEvent(struct ::libinput_event *event) void DSLibinput::__processTouchDownEvent(struct ::libinput_event *event) { - ; + struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); + int index, x, y; + + struct ::libinput_device *device = libinput_event_get_device(event); + std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); + + index = libinput_event_touch_get_slot(touch_event); + x = libinput_event_touch_get_x(touch_event); + y = libinput_event_touch_get_y(touch_event); + + inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchDownEvent, identifier, DSInput::TouchClass); } void DSLibinput::__processTouchMotionEvent(struct ::libinput_event *event) { - ; + struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); + int index, x, y; + + struct ::libinput_device *device = libinput_event_get_device(event); + std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); + + index = libinput_event_touch_get_slot(touch_event); + x = libinput_event_touch_get_x(touch_event); + y = libinput_event_touch_get_y(touch_event); + + inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchMoveEvent, identifier, DSInput::TouchClass); } void DSLibinput::__processTouchUpEvent(struct ::libinput_event *event) { - ; + struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); + int index, x, y; + + struct ::libinput_device *device = libinput_event_get_device(event); + std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); + + index = libinput_event_touch_get_slot(touch_event); + x = 0; + y = 0; + + inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchUpEvent, identifier, DSInput::TouchClass); } void DSLibinput::__processTouchCancelEvent(struct ::libinput_event *event) diff --git a/src/meson.build b/src/meson.build index 44d76c5..af01979 100644 --- a/src/meson.build +++ b/src/meson.build @@ -191,7 +191,7 @@ pkgconfig.generate( libds_declared_dep = declare_dependency( link_with : libds_lib, - dependencies : libds_deps, + dependencies : [libds_deps, ecore_dep], include_directories : [libds_include_dirs] ) -- 2.7.4 From d151f4ee0c9dfc7381246af1125b52920d71cb94 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Mon, 20 Jul 2020 15:52:17 +0000 Subject: [PATCH 03/16] DSWaylandTizenPolicy: add initial code Change-Id: Ie0b559b898c380ce6f6912f6dc97845845b53391 --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 107 +++++++++++++++++++++- src/DSWaylandServer/DSWaylandTizenPolicy.h | 14 ++- src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h | 3 + tests/DSWaylandTizenPolicy-test.cpp | 45 ++++++++- 4 files changed, 163 insertions(+), 6 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index 5e52da8..bfb0790 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -1,6 +1,8 @@ #include "DSWaylandTizenPolicy.h" #include "DSWaylandTizenPolicyPrivate.h" +const int TIZEN_POLICY_VERSION = 7; + namespace display_server { ///////////////////////////////// @@ -11,189 +13,288 @@ DSWaylandTizenPolicyPrivate::DSWaylandTizenPolicyPrivate(DSWaylandTizenPolicy *p : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) { + DSLOG_DBG("TizenPolicyPriv", ""); } DSWaylandTizenPolicyPrivate::~DSWaylandTizenPolicyPrivate() { + DSLOG_DBG("TizenPolicyPriv", ""); +} + +void DSWaylandTizenPolicyPrivate::tizen_policy_initialize(DSWaylandCompositor *wlCompositor) +{ + ::wl_display *display; + display = wlCompositor->display(); + + init(display, TIZEN_POLICY_VERSION); +} + +void DSWaylandTizenPolicyPrivate::tizen_policy_finalize(void) +{ + } void DSWaylandTizenPolicyPrivate::tizen_policy_bind_resource(Resource *resource) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_destroy_resource(Resource *resource) { - + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_visibility(Resource *resource, uint32_t id, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_position(Resource *resource, uint32_t id, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_activate(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_activate_below_by_res_id(Resource *resource, uint32_t res_id, uint32_t below_res_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_raise(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_lower(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_lower_by_res_id(Resource *resource, uint32_t res_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_focus_skip(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_focus_skip(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_role(Resource *resource, struct ::wl_resource *surface, const std::string &role) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_type(Resource *resource, struct ::wl_resource *surface, uint32_t win_type) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_conformant(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_conformant(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_conformant(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_notification_level(Resource *resource, struct ::wl_resource *surface, int32_t level) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_transient_for(Resource *resource, uint32_t child_id, uint32_t parent_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_transient_for(Resource *resource, uint32_t child_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_window_screen_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_place_subsurface_below_parent(Resource *resource, struct ::wl_resource *subsurface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_subsurface_stand_alone(Resource *resource, struct ::wl_resource *subsurface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_subsurface(Resource *resource, uint32_t id, struct ::wl_resource *surface, uint32_t parent_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_opaque_state(Resource *resource, struct ::wl_resource *surface, int32_t state) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_iconify(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_uniconify(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_add_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &name, const std::string &value) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_change_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &value) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_del_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_supported_aux_hints(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_background_state(Resource *resource, uint32_t pid) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_background_state(Resource *resource, uint32_t pid) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_floating_mode(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_floating_mode(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_stack_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_activate_above_by_res_id(Resource *resource, uint32_t res_id, uint32_t above_res_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_subsurface_watcher(Resource *resource, uint32_t id, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_parent(Resource *resource, struct ::wl_resource *child, struct ::wl_resource *parent) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_ack_conformant_region(Resource *resource, struct ::wl_resource *surface, uint32_t serial) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_destroy(Resource *resource) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_has_video(Resource *resource, struct ::wl_resource *surface, uint32_t has) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid) { + DSLOG_DBG("TizenPolicyPriv", ""); } -DSWaylandTizenPolicy::DSWaylandTizenPolicy() - : DS_INIT_PRIVATE_PTR(DSWaylandTizenPolicy) +DSWaylandTizenPolicy::DSWaylandTizenPolicy(DSWaylandCompositor *wlCompositor) + : DS_INIT_PRIVATE_PTR(DSWaylandTizenPolicy), + __wlCompositor(wlCompositor) { + this->initialize(__wlCompositor); } DSWaylandTizenPolicy::~DSWaylandTizenPolicy() { + DS_ASSERT(isCreated() == false); +} + +bool DSWaylandTizenPolicy::isCreated(void) +{ + return __isCreated; +} + +bool DSWaylandTizenPolicy::initialize(DSWaylandCompositor *wlCompositor) +{ + if (!wlCompositor) return false; + if (isCreated()) + { + DSLOG_ERR("TizenPolicy", "Already initialized"); + return true; + } + + DS_GET_PRIV(DSWaylandTizenPolicy); + if (!priv) return false; + + __wlCompositor = wlCompositor; + __isCreated = true; + + priv->tizen_policy_initialize(__wlCompositor); + + DSLOG_INF("TizenPolicy", "TizenPolicy initialized"); + return true; +} + +void DSWaylandTizenPolicy::finalize(void) +{ + DS_GET_PRIV(DSWaylandTizenPolicy); + priv->tizen_policy_finalize(); + + DSLOG_INF("TizenPolicy", "TizenPolicy finalized"); + __isCreated = false; +} + +DSWaylandCompositor *DSWaylandTizenPolicy::getWlCompositor() +{ + return __wlCompositor; } } // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.h b/src/DSWaylandServer/DSWaylandTizenPolicy.h index 844bd5a..95b93d5 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.h +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.h @@ -3,6 +3,7 @@ #include "DSCore.h" #include "DSObject.h" +#include "DSWaylandCompositor.h" namespace display_server { @@ -14,8 +15,19 @@ class DSWaylandTizenPolicy : public DSObject DS_PIMPL_USE_PRIVATE(DSWaylandTizenPolicy) public: - DSWaylandTizenPolicy(); + DSWaylandTizenPolicy(DSWaylandCompositor *wlCompositor); virtual ~DSWaylandTizenPolicy(); + + bool isCreated(void); + + bool initialize(DSWaylandCompositor *wlCompositor); + void finalize(void); + + DSWaylandCompositor *getWlCompositor(); + +private: + DSWaylandCompositor *__wlCompositor; + bool __isCreated; }; } diff --git a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h index 0ff3bf5..634060b 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h +++ b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h @@ -16,6 +16,9 @@ public: DSWaylandTizenPolicyPrivate(DSWaylandTizenPolicy *p_ptr); ~DSWaylandTizenPolicyPrivate() override; + void tizen_policy_initialize(DSWaylandCompositor *wlCompositor); + void tizen_policy_finalize(void); + protected: void tizen_policy_bind_resource(Resource *resource) override; void tizen_policy_destroy_resource(Resource *resource) override; diff --git a/tests/DSWaylandTizenPolicy-test.cpp b/tests/DSWaylandTizenPolicy-test.cpp index 49b96fd..a7be1c5 100644 --- a/tests/DSWaylandTizenPolicy-test.cpp +++ b/tests/DSWaylandTizenPolicy-test.cpp @@ -1,4 +1,5 @@ #include "libds-tests.h" +#include "DSWaylandCompositor.h" #include "DSWaylandTizenPolicy.h" using namespace display_server; @@ -12,10 +13,50 @@ public: {} }; -TEST_F(DSWaylandTizenPolicyTest, NewDSWaylandTizenPolicy) +TEST_F(DSWaylandTizenPolicyTest, new_P1) { - DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy; + DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); + DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(compositor); delete tizenPolicy; EXPECT_TRUE(true); + DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandTizenPolicyTest, initialize_P1) +{ + bool ret; + + DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); + DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(compositor); + + ret = tizenPolicy->initialize(compositor); + EXPECT_TRUE(ret == true); + + delete tizenPolicy; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTizenPolicyTest, initialize_P2) +{ + bool ret; + + DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); + DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(nullptr); + + ret = tizenPolicy->initialize(compositor); + EXPECT_TRUE(ret == true); + + delete tizenPolicy; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTizenPolicyTest, initialize_N1) +{ + bool ret; + DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(nullptr); + + ret = tizenPolicy->initialize(nullptr); + EXPECT_TRUE(ret == false); + + delete tizenPolicy; +} -- 2.7.4 From fae8e8086d152d12faee96c995b3a153255ebb7c Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Thu, 23 Jul 2020 16:08:45 +0900 Subject: [PATCH 04/16] DSWaylandTizenPolicy: call finalize instead of assert in destructor Change-Id: I2aa6b4c41544dfa9ae328004ba34c6ffe63f0087 Signed-off-by: Junseok, Kim --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index bfb0790..e61a8fa 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -254,7 +254,8 @@ DSWaylandTizenPolicy::DSWaylandTizenPolicy(DSWaylandCompositor *wlCompositor) DSWaylandTizenPolicy::~DSWaylandTizenPolicy() { - DS_ASSERT(isCreated() == false); + if (isCreated()) + this->finalize(); } bool DSWaylandTizenPolicy::isCreated(void) -- 2.7.4 From 328de20b8da9daef735aab113d6cdd0070442df4 Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Thu, 23 Jul 2020 15:59:35 +0900 Subject: [PATCH 05/16] DSWaylandTizenIndicator: add skeleton codes for Tizen Indicator Change-Id: I878deb8f343b5a16ee5161f3868ccde1136c2794 Signed-off-by: Junseok, Kim --- src/DSWaylandServer/DSWaylandTizenIndicator.cpp | 49 ++++++++++++++++++++++ src/DSWaylandServer/DSWaylandTizenIndicator.h | 24 +++++++++++ .../DSWaylandTizenIndicatorPrivate.h | 34 +++++++++++++++ src/meson.build | 3 ++ tests/DSWaylandTizenIndicator-test.cpp | 22 ++++++++++ tests/meson.build | 1 + 6 files changed, 133 insertions(+) create mode 100644 src/DSWaylandServer/DSWaylandTizenIndicator.cpp create mode 100644 src/DSWaylandServer/DSWaylandTizenIndicator.h create mode 100644 src/DSWaylandServer/DSWaylandTizenIndicatorPrivate.h create mode 100644 tests/DSWaylandTizenIndicator-test.cpp diff --git a/src/DSWaylandServer/DSWaylandTizenIndicator.cpp b/src/DSWaylandServer/DSWaylandTizenIndicator.cpp new file mode 100644 index 0000000..68b0ef5 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandTizenIndicator.cpp @@ -0,0 +1,49 @@ +#include "DSWaylandTizenIndicator.h" +#include "DSWaylandTizenIndicatorPrivate.h" + +namespace display_server +{ + + +DSWaylandTizenIndicator::DSWaylandTizenIndicator() + : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandTizenIndicator) +{ +} + +DSWaylandTizenIndicator::~DSWaylandTizenIndicator() +{ +} + + +DSWaylandTizenIndicatorPrivate::DSWaylandTizenIndicatorPrivate(DSWaylandTizenIndicator *p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr) +{ +} + +DSWaylandTizenIndicatorPrivate::~DSWaylandTizenIndicatorPrivate() +{ +} + +void DSWaylandTizenIndicatorPrivate::tizen_indicator_bind_resource(Resource *resource) +{ +} +void DSWaylandTizenIndicatorPrivate::tizen_indicator_destroy_resource(Resource *resource) +{ +} +void DSWaylandTizenIndicatorPrivate::tizen_indicator_destroy(Resource *resource) +{ +} +void DSWaylandTizenIndicatorPrivate::tizen_indicator_set_state(Resource *resource, struct ::wl_resource *surface, int32_t state) +{ +} +void DSWaylandTizenIndicatorPrivate::tizen_indicator_set_opacity_mode(Resource *resource, struct ::wl_resource *surface, int32_t mode) +{ +} +void DSWaylandTizenIndicatorPrivate::tizen_indicator_set_visible_type(Resource *resource, struct ::wl_resource *surface, int32_t type) +{ +} + + +} // namespace display_server + diff --git a/src/DSWaylandServer/DSWaylandTizenIndicator.h b/src/DSWaylandServer/DSWaylandTizenIndicator.h new file mode 100644 index 0000000..7707134 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandTizenIndicator.h @@ -0,0 +1,24 @@ +#ifndef __DS_WAYLAND_TIZEN_INDICATOR_H__ +#define __DS_WAYLAND_TIZEN_INDICATOR_H__ + +#include +#include + +namespace display_server +{ + +class DSWaylandTizenIndicatorPrivate; + +class DSWaylandTizenIndicator : public DSObject +{ +DS_PIMPL_USE_PRIVATE(DSWaylandTizenIndicator); + +public: + DSWaylandTizenIndicator(); + virtual ~DSWaylandTizenIndicator(); +}; + +} + +#endif // __DS_WAYLAND_TIZEN_INDICATOR_H__ + diff --git a/src/DSWaylandServer/DSWaylandTizenIndicatorPrivate.h b/src/DSWaylandServer/DSWaylandTizenIndicatorPrivate.h new file mode 100644 index 0000000..ae1a9df --- /dev/null +++ b/src/DSWaylandServer/DSWaylandTizenIndicatorPrivate.h @@ -0,0 +1,34 @@ +#ifndef __DS_WAYLAND_TIZEN_INDICATOR_PRIVATE_H__ +#define __DS_WAYLAND_TIZEN_INDICATOR_PRIVATE_H__ + +#include "dswayland-server-tizen-extension.h" +#include "DSWaylandTizenIndicator.h" + +namespace display_server +{ + +class DS_DECL_EXPORT DSWaylandTizenIndicatorPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_indicator +{ +DS_PIMPL_USE_PUBLIC(DSWaylandTizenIndicator); + +public: + DSWaylandTizenIndicatorPrivate() = delete; + DSWaylandTizenIndicatorPrivate(DSWaylandTizenIndicator *p_ptr); + ~DSWaylandTizenIndicatorPrivate() override; + +protected: + void tizen_indicator_bind_resource(Resource *resource) override; + void tizen_indicator_destroy_resource(Resource *resource) override; + + void tizen_indicator_destroy(Resource *resource) override; + void tizen_indicator_set_state(Resource *resource, struct ::wl_resource *surface, int32_t state) override; + void tizen_indicator_set_opacity_mode(Resource *resource, struct ::wl_resource *surface, int32_t mode) override; + void tizen_indicator_set_visible_type(Resource *resource, struct ::wl_resource *surface, int32_t type) override; +private: + +}; + +} + +#endif // __DS_WAYLAND_TIZEN_INDICATOR_PRIVATE_H__ + diff --git a/src/meson.build b/src/meson.build index af01979..f330b60 100644 --- a/src/meson.build +++ b/src/meson.build @@ -109,6 +109,9 @@ libds_wayland_srcs = [ 'DSWaylandServer/DSWaylandBufferPrivate.h', 'DSWaylandServer/DSWaylandBuffer.h', 'DSWaylandServer/DSWaylandBuffer.cpp', + 'DSWaylandServer/DSWaylandTizenIndicatorPrivate.h', + 'DSWaylandServer/DSWaylandTizenIndicator.h', + 'DSWaylandServer/DSWaylandTizenIndicator.cpp', ] libds_srcs += libds_wayland_srcs diff --git a/tests/DSWaylandTizenIndicator-test.cpp b/tests/DSWaylandTizenIndicator-test.cpp new file mode 100644 index 0000000..d05c99e --- /dev/null +++ b/tests/DSWaylandTizenIndicator-test.cpp @@ -0,0 +1,22 @@ +#include "libds-tests.h" +#include "DSWaylandTizenIndicator.h" + +using namespace display_server; + +class DSWaylandTizenIndicatorTest : public ::testing::Test +{ +public: + void SetUp(void) override + {} + void TearDown(void) override + {} +}; + +TEST_F(DSWaylandTizenIndicatorTest, NewDSWaylandTizenIndicator) +{ + DSWaylandTizenIndicator *tzInd = new DSWaylandTizenIndicator; + EXPECT_TRUE(tzInd != nullptr); + + if (tzInd) + delete tzInd; +} diff --git a/tests/meson.build b/tests/meson.build index 3ddf2ba..ecb7e04 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -23,6 +23,7 @@ libds_tests_srcs = [ 'DSWaylandTizenInputDevice-test.cpp', 'DSWaylandTizenPolicy-test.cpp', 'DSWaylandTizenSurface-test.cpp', + 'DSWaylandTizenIndicator-test.cpp', 'DSWaylandZxdgShellV6-test.cpp', 'DSWaylandBuffer-test.cpp', 'DSObject-test.cpp', -- 2.7.4 From f62b83cdbcd740a9eeb788e36236df7d111480b2 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 21 Jul 2020 20:00:36 +0900 Subject: [PATCH 06/16] DSWaylandSurface: implement the requests Change-Id: I4cdfc3414bf4c4b5204d41f1eb3bf3637cacdfbb --- src/DSWaylandServer/DSWaylandSurface.cpp | 80 ++++++++++++++++++++++++++- src/DSWaylandServer/DSWaylandSurface.h | 22 +++++++- src/DSWaylandServer/DSWaylandSurfacePrivate.h | 45 +++++++++++++++ 3 files changed, 143 insertions(+), 4 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 5fc903f..1832bdc 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -4,14 +4,42 @@ namespace display_server { -DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr) +//////////////////////////////////////////////////////////////////////////////////////////////////////// +// DSWaylandSurfaceCommitInfoPrivate +//////////////////////////////////////////////////////////////////////////////////////////////////////// +DSWaylandSurfaceCommitInfoPrivate::DSWaylandSurfaceCommitInfoPrivate(DSWaylandSurfaceCommitInfo *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) {} +DSWaylandSurfaceCommitInfoPrivate::~DSWaylandSurfaceCommitInfoPrivate() +{} + +//////////////////////////////////////////////////////////////////////////////////////////////////////// +// DSWaylandSurfaceCommitInfo +//////////////////////////////////////////////////////////////////////////////////////////////////////// +DSWaylandSurfaceCommitInfo::DSWaylandSurfaceCommitInfo() + : DS_INIT_PRIVATE_PTR(DSWaylandSurfaceCommitInfo) +{} + +DSWaylandSurfaceCommitInfo::~DSWaylandSurfaceCommitInfo() +{} + +//////////////////////////////////////////////////////////////////////////////////////////////////////// +// DSWaylandSurfacePrivate +//////////////////////////////////////////////////////////////////////////////////////////////////////// +DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr), + __commitInfoPending{std::make_unique()}, + __commitInfo{std::make_shared()} +{} + DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr, DSWaylandClient *waylandClient, uint32_t id) : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) + __p_ptr(p_ptr), + __commitInfoPending{std::make_unique()}, + __commitInfo{std::make_shared()} { if (id > 0) { wl_surface::init(waylandClient->wlClient(), (int)id, 4); @@ -35,40 +63,83 @@ void DSWaylandSurfacePrivate::surface_destroy(Resource *resource) void DSWaylandSurfacePrivate::surface_attach(Resource *resource, struct ::wl_resource *buffer, int32_t x, int32_t y) { + DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); + + commitInfoPendingPriv->attach.x = x; + commitInfoPendingPriv->attach.y = y; + commitInfoPendingPriv->attach.buffer = buffer; } void DSWaylandSurfacePrivate::surface_damage(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { + DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); + + commitInfoPendingPriv->damageSurface.x = x; + commitInfoPendingPriv->damageSurface.y = y; + commitInfoPendingPriv->damageSurface.width = width; + commitInfoPendingPriv->damageSurface.height = height; } void DSWaylandSurfacePrivate::surface_frame(Resource *resource, uint32_t callback) { + //TODO: } void DSWaylandSurfacePrivate::surface_set_opaque_region(Resource *resource, struct ::wl_resource *region) { + //TODO: } void DSWaylandSurfacePrivate::surface_set_input_region(Resource *resource, struct ::wl_resource *region) { + //TODO: } void DSWaylandSurfacePrivate::surface_commit(Resource *resource) { + DS_GET_PUB(DSWaylandSurface); + + DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); + DSWaylandSurfaceCommitInfoPrivate *commitInfoPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfo.get()); + + //copy commit information from commitInfoPendingPriv to commitInfoPriv + commitInfoPriv->attach = commitInfoPendingPriv->attach; + commitInfoPriv->damageSurface = commitInfoPendingPriv->damageSurface; + commitInfoPriv->transform = commitInfoPendingPriv->transform; + commitInfoPriv->scale = commitInfoPendingPriv->scale; + commitInfoPriv->damageBuffer = commitInfoPendingPriv->damageBuffer; + + // emit a signal of the surface committed + pub->__surfaceCommittedSignal.emit(__commitInfo); } void DSWaylandSurfacePrivate::surface_set_buffer_transform(Resource *resource, int32_t transform) { + DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); + + commitInfoPendingPriv->transform = transform; } void DSWaylandSurfacePrivate::surface_set_buffer_scale(Resource *resource, int32_t scale) { + DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); + + commitInfoPendingPriv->scale = scale; } void DSWaylandSurfacePrivate::surface_damage_buffer(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { + DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); + + commitInfoPendingPriv->damageBuffer.x = x; + commitInfoPendingPriv->damageBuffer.y = y; + commitInfoPendingPriv->damageBuffer.width = width; + commitInfoPendingPriv->damageBuffer.height = height; } +//////////////////////////////////////////////////////////////////////////////////////////////////////// +// DSWaylandSurface +//////////////////////////////////////////////////////////////////////////////////////////////////////// DSWaylandSurface::DSWaylandSurface() : DS_INIT_PRIVATE_PTR(DSWaylandSurface) {} @@ -80,4 +151,9 @@ DSWaylandSurface::DSWaylandSurface(DSWaylandClient *waylandClient, uint32_t id) DSWaylandSurface::~DSWaylandSurface() {} +void DSWaylandSurface::registerCallbackSurfaceCommitted(DSObject *slot, std::function commitInfo)> func) +{ + this->__surfaceCommittedSignal.connect(slot, func); +} + } /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandSurface.h b/src/DSWaylandServer/DSWaylandSurface.h index 6773f21..e439f13 100644 --- a/src/DSWaylandServer/DSWaylandSurface.h +++ b/src/DSWaylandServer/DSWaylandSurface.h @@ -1,15 +1,26 @@ #ifndef __DS_WAYLAND_SURFACE_H__ #define __DS_WAYLAND_SURFACE_H__ -#include +#include "DSCore.h" +#include "DSObject.h" +#include "DSSignal.h" #include "DSWaylandClient.h" -#include namespace display_server { +class DSWaylandSurfaceCommitInfoPrivate; class DSWaylandSurfacePrivate; +class DSWaylandSurfaceCommitInfo : public DSObject +{ +DS_PIMPL_USE_PRIVATE(DSWaylandSurfaceCommitInfo); +public: + DSWaylandSurfaceCommitInfo(); + virtual ~DSWaylandSurfaceCommitInfo(); + + //TODO: add getter functions. +}; class DSWaylandSurface : public DSObject { @@ -18,6 +29,13 @@ public: DSWaylandSurface(); DSWaylandSurface(DSWaylandClient *waylandClient, uint32_t id); virtual ~DSWaylandSurface(); + + // Callback methods + void registerCallbackSurfaceCommitted(DSObject *slot, std::function commitInfo)> func); + +private: + // signals + DSSignal> __surfaceCommittedSignal; }; } /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandSurfacePrivate.h b/src/DSWaylandServer/DSWaylandSurfacePrivate.h index 46324fe..f5bbbd9 100644 --- a/src/DSWaylandServer/DSWaylandSurfacePrivate.h +++ b/src/DSWaylandServer/DSWaylandSurfacePrivate.h @@ -7,8 +7,51 @@ namespace display_server { +class DSWaylandSurfaceCommitInfo; class DSWaylandSurface; +class DSWaylandSurfaceCommitInfoPrivate : public DSObjectPrivate +{ +DS_PIMPL_USE_PUBLIC(DSWaylandSurfaceCommitInfo); +public: + DSWaylandSurfaceCommitInfoPrivate() = delete; + DSWaylandSurfaceCommitInfoPrivate(DSWaylandSurfaceCommitInfo *p_ptr); + ~DSWaylandSurfaceCommitInfoPrivate() override; + + static DSWaylandSurfaceCommitInfoPrivate *getPrivate(DSWaylandSurfaceCommitInfo *q) { return q->__d_func(); } + + //TODO: add getter functions. + +public: + struct attach { + int32_t x; + int32_t y; + struct ::wl_resource *buffer; + }; + struct attach attach; + + struct damageSurface { + int32_t x; + int32_t y; + int32_t width; + int32_t height; + }; + struct damageSurface damageSurface; + + //TODO: opaque_region + //TODO: input region + int32_t transform; + int32_t scale; + + struct damageBuffer { + int32_t x; + int32_t y; + int32_t width; + int32_t height; + }; + struct damageBuffer damageBuffer; +}; + class DSWaylandSurfacePrivate : public DSObjectPrivate, public DSWaylandServer::wl_surface { DS_PIMPL_USE_PUBLIC(DSWaylandSurface); @@ -34,6 +77,8 @@ protected: void surface_damage_buffer(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; private: + std::unique_ptr __commitInfoPending; + std::shared_ptr __commitInfo; }; } /*namespace display_server */ -- 2.7.4 From 38989f2656f16feda259f525a311c92ad3be8f01 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 24 Jul 2020 10:32:19 +0900 Subject: [PATCH 07/16] DSZone : register SurfaceCreated Callback Change-Id: I1ffaa2f93c1e7f0f003f255f9c1f408d8f27028f --- src/DSZone/DSZone.cpp | 28 ++++++++++++++-------------- src/DSZone/DSZone.h | 10 ++++++---- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 1d6388a..044b003 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -1,15 +1,23 @@ #include "DSZone.h" #include "DSPolicyAreaPrivate.h" +#include "DSWaylandCompositor.h" +#include "DSWaylandSurface.h" namespace display_server { DSZone::DSZone(std::shared_ptr policyArea) - : __policyArea(policyArea) -{} + : __policyArea(policyArea), + __waylandCompositor(nullptr) +{ + __waylandCompositor = DSWaylandCompositor::getInstance(); + __waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&DSZone::onSurfaceCreated, this, std::placeholders::_1)); +} DSZone::~DSZone() -{} +{ + DSWaylandCompositor::releaseInstance(); +} int DSZone::getX() { @@ -39,18 +47,10 @@ int DSZone::getHeight() return policyAreaPriv->getHeight(); } -bool DSZone::addWindow(std::shared_ptr window) +void DSZone::onSurfaceCreated(std::shared_ptr waylandSurface) { - __windowList.push_back(window); - - return true; -} - -bool DSZone::removeWindow(std::shared_ptr window) -{ - __windowList.remove(window); - - return true; + //TODO: create DSWindow + //TODO: create DSRenderView } } // namespace display_server \ No newline at end of file diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index 1babd66..8fa834f 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -7,8 +7,9 @@ namespace display_server { - -class DSZone +class DSWaylandCompositor; +class DSWaylandSurface; +class DSZone : public DSObject { public: explicit DSZone(std::shared_ptr policyArea); @@ -18,12 +19,13 @@ public: int getY(); int getWidth(); int getHeight(); - bool addWindow(std::shared_ptr window); - bool removeWindow(std::shared_ptr window); private: + void onSurfaceCreated(std::shared_ptr waylandSurface); + std::shared_ptr __policyArea; std::list> __windowList; + DSWaylandCompositor *__waylandCompositor; }; } -- 2.7.4 From 32ad5e221e95f752aca8bd651fe620a603f57f55 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 24 Jul 2020 10:45:23 +0900 Subject: [PATCH 08/16] Test: make libds-mock.h file. make libds-mock.h file and put the MockWaylandCompositor class and TestClient structure in it. Change-Id: I5df2907b84e91bb3bf63321cea609c39ba39b144 --- tests/DSWaylandCompositor-test.cpp | 56 ++--------------------- tests/libds-mock.h | 91 ++++++++++++++++++++++++++++++++++++++ tests/libds-tests.h | 13 ++++-- 3 files changed, 105 insertions(+), 55 deletions(-) create mode 100644 tests/libds-mock.h diff --git a/tests/DSWaylandCompositor-test.cpp b/tests/DSWaylandCompositor-test.cpp index 857030a..7a459e3 100644 --- a/tests/DSWaylandCompositor-test.cpp +++ b/tests/DSWaylandCompositor-test.cpp @@ -1,14 +1,6 @@ #include "libds-tests.h" -#include "DSWaylandCompositor.h" #include "DSWaylandClient.h" #include "DSWaylandSeat.h" -#include "DSEventLoop.h" -#include -#include -#include -#include -#include -#include using namespace display_server; @@ -157,46 +149,6 @@ TEST_F(DSWaylandCompositorTest, GetDefaultSeat) } } -class MockCompositor : public DSObject -{ -public: - MockCompositor() - : surfaceCreated(false) - { - __compositor = DSWaylandCompositor::getInstance(); - __compositor->create(); - __compositor->registerCallbackSurfaceCreated(this, std::bind(&MockCompositor::onSurfaceCreated, this, std::placeholders::_1)); - } - - ~MockCompositor() { DSWaylandCompositor::releaseInstance(); } - - void onSurfaceCreated(std::shared_ptr) { - surfaceCreated = true; - } - - void run() { - __eventLoop.run(); - } - - void quit() { - __eventLoop.quit(); - } - - bool surfaceCreated; // result of surfaceCreated - -private: - DSWaylandCompositor *__compositor; - DSEventLoop __eventLoop; -}; - -struct TestClient -{ - struct wl_display *display; - struct wl_compositor *compositor; - struct wl_registry *registry; - struct wl_surface *surface; -}; - static void handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) @@ -221,12 +173,12 @@ static const struct wl_registry_listener registry_listener = { TEST_F(DSWaylandCompositorTest, registerCallbackSurfaceCreated) { - auto mockCompositor = std::make_unique(); + auto mockWaylandCompositor = std::make_unique(); Ecore_Timer *serverQuitTimer = nullptr; double severQuitTime = 1.0; auto serverQuitFunc = [](void *data) -> Eina_Bool { - MockCompositor *comp = (MockCompositor *)data; + MockWaylandCompositor *comp = (MockWaylandCompositor *)data; // quit server comp->quit(); @@ -235,7 +187,7 @@ TEST_F(DSWaylandCompositorTest, registerCallbackSurfaceCreated) return EINA_FALSE; }; - serverQuitTimer = ecore_timer_loop_add(severQuitTime, serverQuitFunc, mockCompositor.get()); + serverQuitTimer = ecore_timer_loop_add(severQuitTime, serverQuitFunc, mockWaylandCompositor.get()); EXPECT_TRUE(serverQuitTimer != nullptr); // create the wayland client which creates the wl_surface. @@ -262,7 +214,7 @@ TEST_F(DSWaylandCompositorTest, registerCallbackSurfaceCreated) } ); - mockCompositor->run(); + mockWaylandCompositor->run(); EXPECT_TRUE(clientThread.get()); // join(wait) and get the return value. } diff --git a/tests/libds-mock.h b/tests/libds-mock.h new file mode 100644 index 0000000..4554dd6 --- /dev/null +++ b/tests/libds-mock.h @@ -0,0 +1,91 @@ +/************************************************************************** + * + * Copyright 2020 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: SooChan Lim + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#ifndef __LIBDS_MOCK_H__ +#define __LIBDS_MOCK_H__ + +#include "DSWaylandCompositor.h" +#include "DSWaylandSurface.h" +#include "DSEventLoop.h" +#include "DSDebugLog.h" + +using namespace display_server; + +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// wayland MockCompositor +///////////////////////////////////////////////////////////////////////////////////////////////////////// +class MockWaylandCompositor : public DSObject +{ +public: + MockWaylandCompositor() + : surfaceCreated(false) + { + __waylandCompositor = DSWaylandCompositor::getInstance(); + __waylandCompositor->create(); + __waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&MockWaylandCompositor::onSurfaceCreated, this, std::placeholders::_1)); + } + + ~MockWaylandCompositor() + { + DSWaylandCompositor::releaseInstance(); + } + + void onSurfaceCreated(std::shared_ptr) + { + surfaceCreated = true; + } + + void run() + { + __eventLoop.run(); + } + + void quit() + { + __eventLoop.quit(); + } + + bool surfaceCreated; // result of surfaceCreated + +private: + DSWaylandCompositor *__waylandCompositor; + DSEventLoop __eventLoop; +}; + +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// wayland Test Client +///////////////////////////////////////////////////////////////////////////////////////////////////////// +struct TestClient +{ + struct wl_display *display; + struct wl_compositor *compositor; + struct wl_registry *registry; + struct wl_surface *surface; +}; + +#endif // UT_H diff --git a/tests/libds-tests.h b/tests/libds-tests.h index 8965fec..0a4656b 100644 --- a/tests/libds-tests.h +++ b/tests/libds-tests.h @@ -26,13 +26,20 @@ * **************************************************************************/ -#ifndef _LIBDS_TESTS_H_ -#define _LIBDS_TESTS_H_ +#ifndef __LIBDS_TESTS_H__ +#define __LIBDS_TESTS_H__ #include #include +#include +#include +#include +#include +#include +#include #include -#include "DSDebugLog.h" + +#include "libds-mock.h" using ::testing::TestWithParam; using ::testing::Bool; -- 2.7.4 From 44aca184236466d9ceb9e67fc23f242cc036bfc3 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 24 Jul 2020 11:32:12 +0900 Subject: [PATCH 09/16] Test: add registerCallbackSurfaceCommitted test on DSWaylandSurfaceTest TEST_F(DSWaylandSurfaceTest, registerCallbackSurfaceCommitted) Change-Id: I559d46b933962ed19e7075a3613dfec943d862a9 --- packaging/libds.spec | 2 + tests/DSWaylandSurface-test.cpp | 94 ++++++++++++++++++++++++++++++++++++++++- tests/libds-mock.h | 15 ++++++- tests/libds-tests.h | 1 + tests/meson.build | 3 +- 5 files changed, 111 insertions(+), 4 deletions(-) diff --git a/packaging/libds.spec b/packaging/libds.spec index 5123402..9b432b6 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -23,9 +23,11 @@ BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(ecore-evas) BuildRequires: pkgconfig(libinput) BuildRequires: pkgconfig(libudev) + # For samples and tests BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(xkbcommon) +BuildRequires: pkgconfig(wayland-tbm-client) # for ignoring the libds.a %define _unpackaged_files_terminate_build 0 diff --git a/tests/DSWaylandSurface-test.cpp b/tests/DSWaylandSurface-test.cpp index e23a9f9..84d7f7b 100644 --- a/tests/DSWaylandSurface-test.cpp +++ b/tests/DSWaylandSurface-test.cpp @@ -8,9 +8,35 @@ class DSWaylandSurfaceTest : public ::testing::Test { public: void SetUp(void) override - {} + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } void TearDown(void) override - {} + { + unsetenv("XDG_RUNTIME_DIR"); + } +}; + +static void +handle_global(void *data, struct wl_registry *registry, uint32_t name, + const char *interface, uint32_t version) +{ + struct TestClient *testClient = (struct TestClient *)data; + + if (strcmp(interface, "wl_compositor") == 0) { + testClient->compositor = (struct wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 1); + if (!testClient->compositor) + DSLOG_ERR("TEST", "wl_registry_bind compositor fails."); + } +} + +static void +handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) +{} + +static const struct wl_registry_listener registry_listener = { + handle_global, + handle_global_remove }; TEST_F(DSWaylandSurfaceTest, NewDSWaylandSurface) @@ -40,3 +66,67 @@ TEST_F(DSWaylandSurfaceTest, NewDSWaylandSurfaceWithPrams) DSWaylandCompositor::releaseInstance(); } } + +TEST_F(DSWaylandSurfaceTest, registerCallbackSurfaceCommitted) +{ + auto mockWaylandCompositor = std::make_unique(); + + Ecore_Timer *serverQuitTimer = nullptr; + double severQuitTime = 1.0; + auto serverQuitFunc = [](void *data) -> Eina_Bool { + MockWaylandCompositor *comp = (MockWaylandCompositor *)data; + + // quit server + comp->quit(); + // check the emitting the surfaceCommitted + EXPECT_TRUE(comp->surfaceCommitted); + + return EINA_FALSE; + }; + serverQuitTimer = ecore_timer_loop_add(severQuitTime, serverQuitFunc, mockWaylandCompositor.get()); + EXPECT_TRUE(serverQuitTimer != nullptr); + + // create the wayland client which creates the wl_surface. + std::future clientThread = std::async(std::launch::async, []() -> bool { + std::this_thread::sleep_for(std::chrono::milliseconds(40)); + auto testClient = std::make_shared(); + + testClient->display = wl_display_connect(NULL); + EXPECT_TRUE(testClient->display != nullptr); + + testClient->registry = wl_display_get_registry(testClient->display); + wl_registry_add_listener(testClient->registry, ®istry_listener, testClient.get()); + wl_display_dispatch(testClient->display); + wl_display_roundtrip(testClient->display); + EXPECT_TRUE(testClient->compositor != nullptr); + + testClient->surface = wl_compositor_create_surface(testClient->compositor); + EXPECT_TRUE(testClient->surface != nullptr); + wl_display_roundtrip(testClient->display); + + testClient->tbm_client = wayland_tbm_client_init(testClient->display); + EXPECT_TRUE(testClient->tbm_client != nullptr); + testClient->tbmBuffer = tbm_surface_create(720, 1280, TBM_FORMAT_ARGB8888); + EXPECT_TRUE(testClient->tbmBuffer != nullptr); + testClient->buffer = wayland_tbm_client_create_buffer(testClient->tbm_client, testClient->tbmBuffer); + EXPECT_TRUE(testClient->buffer != nullptr); + + wl_surface_attach(testClient->surface, testClient->buffer, 0, 0); + wl_surface_damage(testClient->surface, 0, 0, 100, 100); + wl_surface_commit(testClient->surface); + + wl_display_roundtrip(testClient->display); + + wayland_tbm_client_destroy_buffer(testClient->tbm_client, testClient->buffer); + tbm_surface_destroy(testClient->tbmBuffer); + wayland_tbm_client_deinit(testClient->tbm_client); + + wl_display_disconnect(testClient->display); + + return true; + } + ); + + mockWaylandCompositor->run(); + EXPECT_TRUE(clientThread.get()); // join(wait) and get the return value. +} diff --git a/tests/libds-mock.h b/tests/libds-mock.h index 4554dd6..94a0c04 100644 --- a/tests/libds-mock.h +++ b/tests/libds-mock.h @@ -55,9 +55,15 @@ public: DSWaylandCompositor::releaseInstance(); } - void onSurfaceCreated(std::shared_ptr) + void onSurfaceCreated(std::shared_ptr waylandSurface) { surfaceCreated = true; + __waylandSurface = waylandSurface; + __waylandSurface->registerCallbackSurfaceCommitted(this, std::bind(&MockWaylandCompositor::onSurfaceCommitted, this, std::placeholders::_1)); + } + + void onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo) { + surfaceCommitted = true; } void run() @@ -71,9 +77,11 @@ public: } bool surfaceCreated; // result of surfaceCreated + bool surfaceCommitted; // result of surfaceCommitted private: DSWaylandCompositor *__waylandCompositor; + std::shared_ptr __waylandSurface; DSEventLoop __eventLoop; }; @@ -86,6 +94,11 @@ struct TestClient struct wl_compositor *compositor; struct wl_registry *registry; struct wl_surface *surface; + struct wl_buffer *buffer; + struct wayland_tbm_client *tbm_client; + tbm_surface_h tbmBuffer; + int dx, dy, dw, dh; // damage x,y,w,h + int ax, ay; // attach x,y }; #endif // UT_H diff --git a/tests/libds-tests.h b/tests/libds-tests.h index 0a4656b..488e869 100644 --- a/tests/libds-tests.h +++ b/tests/libds-tests.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/tests/meson.build b/tests/meson.build index ecb7e04..b09a5c6 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -40,11 +40,12 @@ libds_tests_srcs = [ gmock_dep = dependency('gmock', method : 'pkg-config') ecore_dep = dependency('ecore', method : 'pkg-config') wl_client_dep = dependency('wayland-client', method : 'pkg-config') +wl_tbm_dep = dependency('wayland-tbm-client', method : 'pkg-config') executable( 'libds-tests', libds_tests_srcs, - dependencies : [libds_static_declared_dep, gmock_dep, ecore_dep, ecore_evas_dep, wl_client_dep], + dependencies : [libds_static_declared_dep, gmock_dep, ecore_dep, ecore_evas_dep, wl_client_dep, wl_tbm_dep], install_dir : libds_prefix_bindir, install : true ) -- 2.7.4 From dc68c967704050f32502088f57efdc3a38d10dc2 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 24 Jul 2020 17:06:46 +0900 Subject: [PATCH 10/16] DSInput: Support input events using ecore event Change-Id: Iaf38a9a8f8b6a08953b8947c1522b1bb8d3f159c --- src/DSInput/DSInput.cpp | 112 +++++++++++++++++++++++++++++++++++++++++------- src/DSInput/DSInput.h | 31 ++++++++++---- src/meson.build | 4 +- 3 files changed, 121 insertions(+), 26 deletions(-) diff --git a/src/DSInput/DSInput.cpp b/src/DSInput/DSInput.cpp index ba01dfe..a1bf408 100644 --- a/src/DSInput/DSInput.cpp +++ b/src/DSInput/DSInput.cpp @@ -73,11 +73,40 @@ void DSInputPrivate::PostTouchEvent(int index, int x, int y, DSInputEvent::Type pub->touchUp(index, x, y, devIdentifier, devClass); } +int DSInput::DS_INPUT_EVENT_KEY_DOWN = 0; +int DSInput::DS_INPUT_EVENT_KEY_UP = 0; +int DSInput::DS_INPUT_EVENT_MOUSE_DOWN = 0; +int DSInput::DS_INPUT_EVENT_MOUSE_MOVE = 0; +int DSInput::DS_INPUT_EVENT_MOUSE_UP = 0; +int DSInput::DS_INPUT_EVENT_TOUCH_DOWN = 0; +int DSInput::DS_INPUT_EVENT_TOUCH_MOVE = 0; +int DSInput::DS_INPUT_EVENT_TOUCH_UP = 0; + +void DSInput::__initiaiize_ecore_event_types() +{ + if (!DS_INPUT_EVENT_KEY_DOWN) + DS_INPUT_EVENT_KEY_DOWN = ecore_event_type_new(); + if (!DS_INPUT_EVENT_KEY_UP) + DS_INPUT_EVENT_KEY_UP = ecore_event_type_new(); + if (!DS_INPUT_EVENT_MOUSE_DOWN) + DS_INPUT_EVENT_MOUSE_DOWN = ecore_event_type_new(); + if (!DS_INPUT_EVENT_MOUSE_MOVE) + DS_INPUT_EVENT_MOUSE_MOVE = ecore_event_type_new(); + if (!DS_INPUT_EVENT_MOUSE_UP) + DS_INPUT_EVENT_MOUSE_UP = ecore_event_type_new(); + if (!DS_INPUT_EVENT_TOUCH_DOWN) + DS_INPUT_EVENT_TOUCH_DOWN = ecore_event_type_new(); + if (!DS_INPUT_EVENT_TOUCH_MOVE) + DS_INPUT_EVENT_TOUCH_MOVE = ecore_event_type_new(); + if (!DS_INPUT_EVENT_TOUCH_UP) + DS_INPUT_EVENT_TOUCH_UP = ecore_event_type_new(); +} DSInput::DSInput() : DS_INIT_PRIVATE_PTR(DSInput), __seat(nullptr) { + __initiaiize_ecore_event_types(); } DSInput::DSInput(DSSeat *seat) @@ -89,10 +118,17 @@ DSInput::DSInput(DSSeat *seat) DSLOG_ERR("DSInput", "DSSeat ptr is required."); return; } + + __initiaiize_ecore_event_types(); } DSInput::~DSInput() { + for (auto eventHandler : __eventHandlerList) + { + ecore_event_handler_del(eventHandler); + } + __eventHandlerList.clear(); } void DSInput::init() @@ -139,44 +175,80 @@ void DSInput::deviceRemove(std::string name, std::string identifier, DSInput::De delete device; } +DSInputDevice *DSInput::findDevice(std::string devIdentifier, DSInput::DeviceClass devClass) +{ + for (auto dev : devList) + { + if ((dev->getClass() == devClass) && (dev->getIdentifier().compare(devIdentifier) == 0)) + { + return dev; + } + } + return nullptr; +} + void DSInput::keyDown(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass) { - std::cout << "[keyDown] keycode: " << keycode << ", identifier: " << devIdentifier << std::endl; + DSLOG_DBG("DSInput", "[keyDown] keycode: %d, identifier: %d\n", keycode, devIdentifier); + DSInputDevice *device = findDevice(devIdentifier, devClass); + DSInputKeyboardEvent *ev = new DSInputKeyboardEvent(std::make_shared(*device), DSInputEvent::KeyDownEvent, 0, keycode); + ecore_event_add(DS_INPUT_EVENT_KEY_DOWN, (void *)ev, nullptr, nullptr); } void DSInput::keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass) { - std::cout << "[keyUp] keycode: " << keycode << ", identifier: " << devIdentifier << std::endl; + DSLOG_DBG("DSInput", "[keyUp] keycode: %d, identifier: %d\n", keycode, devIdentifier); + DSInputDevice *device = findDevice(devIdentifier, devClass); + DSInputKeyboardEvent *ev = new DSInputKeyboardEvent(std::make_shared(*device), DSInputEvent::KeyUpEvent, 0, keycode); + ecore_event_add(DS_INPUT_EVENT_KEY_UP, (void *)ev, nullptr, nullptr); } void DSInput::mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass) { - std::cout << "[mouseDown] button: " << button << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; + DSLOG_DBG("DSInput", "[mouseDown] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier); + DSInputDevice *device = findDevice(devIdentifier, devClass); + DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseDownEvent, 0, button, x, y, z); + ecore_event_add(DS_INPUT_EVENT_MOUSE_DOWN, (void *)ev, nullptr, nullptr); } void DSInput::mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass) { - std::cout << "[mouseMove] button: " << button << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; + DSLOG_DBG("DSInput", "[mouseMove] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier); + DSInputDevice *device = findDevice(devIdentifier, devClass); + DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseMoveEvent, 0, button, x, y, z); + ecore_event_add(DS_INPUT_EVENT_MOUSE_MOVE, (void *)ev, nullptr, nullptr); } void DSInput::mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass) { - std::cout << "[mouseUp] button: " << button << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; + DSLOG_DBG("DSInput", "[mouseUp] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier); + DSInputDevice *device = findDevice(devIdentifier, devClass); + DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseUpEvent, 0, button, x, y, z); + ecore_event_add(DS_INPUT_EVENT_MOUSE_UP, (void *)ev, nullptr, nullptr); } void DSInput::touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass) { - std::cout << "[touchDown] index: " << index << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; + DSLOG_DBG("DSInput", "[touchDown] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier); + DSInputDevice *device = findDevice(devIdentifier, devClass); + DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchDownEvent, 0, index, x, y); + ecore_event_add(DS_INPUT_EVENT_TOUCH_DOWN, (void *)ev, nullptr, nullptr); } void DSInput::touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass) { - std::cout << "[touchMove] index: " << index << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; + DSLOG_DBG("DSInput", "[touchMove] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier); + DSInputDevice *device = findDevice(devIdentifier, devClass); + DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchMoveEvent, 0, index, x, y); + ecore_event_add(DS_INPUT_EVENT_TOUCH_MOVE, (void *)ev, nullptr, nullptr); } void DSInput::touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass) { - std::cout << "[touchUp] index: " << index << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl; + DSLOG_DBG("DSInput", "[touchUp] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier); + DSInputDevice *device = findDevice(devIdentifier, devClass); + DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchUpEvent, 0, index, x, y); + ecore_event_add(DS_INPUT_EVENT_TOUCH_UP, (void *)ev, nullptr, nullptr); } @@ -190,36 +262,44 @@ void DSInput::registerCallbackDeviceRemove(DSObject *slot, std::function__deviceRemoveSignal.connect(slot, func); } -void DSInput::registerCallbackKeyDown(DSObject *slot, std::function func) +void DSInput::registerCallbackKeyDown(DSObject *slot, Ecore_Event_Handler_Cb func) { + __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_KEY_DOWN, func, slot)); } -void DSInput::registerCallbackKeyUp(DSObject *slot, std::function func) +void DSInput::registerCallbackKeyUp(DSObject *slot, Ecore_Event_Handler_Cb func) { + __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_KEY_UP, func, slot)); } -void DSInput::registerCallbackMouseDown(DSObject *slot, std::function func) +void DSInput::registerCallbackMouseDown(DSObject *slot, Ecore_Event_Handler_Cb func) { + __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_MOUSE_DOWN, func, slot)); } -void DSInput::registerCallbackMouseMove(DSObject *slot, std::function func) +void DSInput::registerCallbackMouseMove(DSObject *slot, Ecore_Event_Handler_Cb func) { + __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_MOUSE_MOVE, func, slot)); } -void DSInput::registerCallbackMouseUp(DSObject *slot, std::function func) +void DSInput::registerCallbackMouseUp(DSObject *slot, Ecore_Event_Handler_Cb func) { + __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_MOUSE_UP, func, slot)); } -void DSInput::registerCallbackTouchDown(DSObject *slot, std::function func) +void DSInput::registerCallbackTouchDown(DSObject *slot, Ecore_Event_Handler_Cb func) { + __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_TOUCH_DOWN, func, slot)); } -void DSInput::registerCallbackTouchMove(DSObject *slot, std::function func) +void DSInput::registerCallbackTouchMove(DSObject *slot, Ecore_Event_Handler_Cb func) { + __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_TOUCH_MOVE, func, slot)); } -void DSInput::registerCallbackTouchUp(DSObject *slot, std::function func) +void DSInput::registerCallbackTouchUp(DSObject *slot, Ecore_Event_Handler_Cb func) { + __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_TOUCH_UP, func, slot)); } diff --git a/src/DSInput/DSInput.h b/src/DSInput/DSInput.h index e796bdc..6f53993 100644 --- a/src/DSInput/DSInput.h +++ b/src/DSInput/DSInput.h @@ -51,14 +51,16 @@ public: void registerCallbackDeviceAdd(DSObject *slot, std::function)> func); void registerCallbackDeviceRemove(DSObject *slot, std::function)> func); - void registerCallbackKeyDown(DSObject *slot, std::function func); - void registerCallbackKeyUp(DSObject *slot, std::function func); - void registerCallbackMouseDown(DSObject *slot, std::function func); - void registerCallbackMouseMove(DSObject *slot, std::function func); - void registerCallbackMouseUp(DSObject *slot, std::function func); - void registerCallbackTouchDown(DSObject *slot, std::function func); - void registerCallbackTouchMove(DSObject *slot, std::function func); - void registerCallbackTouchUp(DSObject *slot, std::function func); + void registerCallbackKeyDown(DSObject *slot, Ecore_Event_Handler_Cb func); + void registerCallbackKeyUp(DSObject *slot, Ecore_Event_Handler_Cb func); + void registerCallbackMouseDown(DSObject *slot, Ecore_Event_Handler_Cb func); + void registerCallbackMouseMove(DSObject *slot, Ecore_Event_Handler_Cb func); + void registerCallbackMouseUp(DSObject *slot, Ecore_Event_Handler_Cb func); + void registerCallbackTouchDown(DSObject *slot, Ecore_Event_Handler_Cb func); + void registerCallbackTouchMove(DSObject *slot, Ecore_Event_Handler_Cb func); + void registerCallbackTouchUp(DSObject *slot, Ecore_Event_Handler_Cb func); + + DSInputDevice *findDevice(std::string devIdentifier, DSInput::DeviceClass devClass); private: DSSeat* __seat; @@ -66,6 +68,19 @@ private: DSSignal> __deviceAddSignal; DSSignal> __deviceRemoveSignal; + + std::list __eventHandlerList; + + static int DS_INPUT_EVENT_KEY_DOWN; + static int DS_INPUT_EVENT_KEY_UP; + static int DS_INPUT_EVENT_MOUSE_DOWN; + static int DS_INPUT_EVENT_MOUSE_MOVE; + static int DS_INPUT_EVENT_MOUSE_UP; + static int DS_INPUT_EVENT_TOUCH_DOWN; + static int DS_INPUT_EVENT_TOUCH_MOVE; + static int DS_INPUT_EVENT_TOUCH_UP; + + void __initiaiize_ecore_event_types(); }; class DSInputDevice diff --git a/src/meson.build b/src/meson.build index f330b60..4c17274 100644 --- a/src/meson.build +++ b/src/meson.build @@ -140,7 +140,7 @@ tizen_launch_dep = dependency('tizen-launch-server') tizen_ext_deps = [tizen_ext_dep, text_dep, tizen_launch_dep, tizen_surface_dep] tizen_ext_deps = [tizen_ext_deps, xdg_shell_unstable_v6_dep, xdg_shell_dep] -libds_deps = [] +libds_deps = [ecore_dep] libds_include_dirs = include_directories( '.', @@ -200,6 +200,6 @@ libds_declared_dep = declare_dependency( libds_static_declared_dep = declare_dependency( link_with : libds_static_lib, - dependencies : libds_deps, + dependencies : [libds_deps, ecore_dep], include_directories : [libds_include_dirs] ) -- 2.7.4 From 91e0fe6a78ab1b06c8e13759814fb79fa386cc5c Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 24 Jul 2020 17:22:58 +0900 Subject: [PATCH 11/16] DSSeat: register input event handlers Change-Id: Ib42c9ce6e583399bc5e7c08253df5f01af589805 --- src/DSSeat/DSSeat.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/DSSeat/DSSeat.h | 5 ++++ 2 files changed, 69 insertions(+) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index de6f51e..b911c17 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -4,10 +4,12 @@ #include "DSCompositor.h" #include "DSWaylandSeat.h" #include "DSWaylandCompositor.h" +#include "DSInputEvent.h" namespace display_server { + DSSeat::DSSeat() : __input(nullptr), __keyboard(nullptr), @@ -51,6 +53,14 @@ DSSeat::DSSeat(DSCompositor *compositor, std::string name) __input->registerCallbackDeviceAdd(this, std::bind(&DSSeat::slotDeviceAdd, this, std::placeholders::_1)); __input->registerCallbackDeviceRemove(this, std::bind(&DSSeat::slotDeviceRemove, this, std::placeholders::_1)); + __input->registerCallbackKeyDown(this, inputEventHandlerKey); + __input->registerCallbackKeyUp(this, inputEventHandlerKey); + __input->registerCallbackMouseDown(this, inputEventHandlerMouse); + __input->registerCallbackMouseMove(this, inputEventHandlerMouse); + __input->registerCallbackMouseUp(this, inputEventHandlerMouse); + __input->registerCallbackTouchDown(this, inputEventHandlerTouch); + __input->registerCallbackTouchMove(this, inputEventHandlerTouch); + __input->registerCallbackTouchUp(this, inputEventHandlerTouch); __input->init(); } @@ -125,4 +135,58 @@ void DSSeat::slotDeviceRemove(std::shared_ptr device) __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); } +Eina_Bool DSSeat::inputEventHandlerKey(void *data, int type, void *event) +{ + //DSSeat *seat = static_cast< DSSeat* >(data); + DSInputKeyboardEvent *ev = static_cast< DSInputKeyboardEvent* >(event); + std::string typeString; + + if (ev->getType() == DSInputEvent::KeyDownEvent) + typeString = "down"; + else + typeString = "up"; + + DSLOG_DBG("DSSeat", "[key%s] keycode: %d, devicename: %s\n", typeString.c_str(), ev->getKeycode(), ev->getDevice()->getName().c_str()); + + return EINA_TRUE; +} + +Eina_Bool DSSeat::inputEventHandlerMouse(void *data, int type, void *event) +{ + //DSSeat *seat = static_cast< DSSeat* >(data); + DSInputMouseEvent *ev = static_cast< DSInputMouseEvent* >(event); + std::string typeString; + + if (ev->getType() == DSInputEvent::MouseDownEvent) + typeString = "down"; + else if (ev->getType() == DSInputEvent::MouseMoveEvent) + typeString = "move"; + else + typeString = "up"; + + DSLOG_DBG("DSSeat", "[mouse%s] button: %d (%d, %d, %d), devicename: %s\n", typeString.c_str(), ev->getButton(), ev->getX(), ev->getY(), ev->getZ(), ev->getDevice()->getName().c_str()); + + return EINA_TRUE; +} + +Eina_Bool DSSeat::inputEventHandlerTouch(void *data, int type, void *event) +{ + //DSSeat *seat = static_cast< DSSeat* >(data); + DSInputTouchEvent *ev = static_cast< DSInputTouchEvent* >(event); + std::string typeString; + + if (ev->getType() == DSInputEvent::TouchDownEvent) + typeString = "down"; + else if (ev->getType() == DSInputEvent::TouchMoveEvent) + typeString = "move"; + else + typeString = "up"; + + DSLOG_DBG("DSSeat", "[touch%s] index: %d (%d, %d), devicename: %s\n", typeString.c_str(), ev->getIndex(), ev->getX(), ev->getY(), ev->getDevice()->getName().c_str()); + + return EINA_TRUE; +} + + } // namespace display_server + diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h index fb1bd0e..a7347a0 100644 --- a/src/DSSeat/DSSeat.h +++ b/src/DSSeat/DSSeat.h @@ -3,6 +3,7 @@ #include #include +#include namespace display_server { @@ -37,6 +38,10 @@ private: uint32_t __numPointer; uint32_t __numKeyboard; uint32_t __numTouch; + + static Eina_Bool inputEventHandlerKey(void *data, int type, void *event); + static Eina_Bool inputEventHandlerMouse(void *data, int type, void *event); + static Eina_Bool inputEventHandlerTouch(void *data, int type, void *event); }; } -- 2.7.4 From 5346d392fc7d900f35dfa45862d102061c6a76e5 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Mon, 27 Jul 2020 13:49:41 +0900 Subject: [PATCH 12/16] add wayland client simple rendering sample Change-Id: I4f43135de7f28ef33bb8dfce9c2dac62a2730bfb Signed-off-by: Junkyeong Kim --- samples/exampleWlClientSimpleRendering.cpp | 403 +++++++++++++++++++++++++++++ samples/meson.build | 9 + 2 files changed, 412 insertions(+) create mode 100644 samples/exampleWlClientSimpleRendering.cpp diff --git a/samples/exampleWlClientSimpleRendering.cpp b/samples/exampleWlClientSimpleRendering.cpp new file mode 100644 index 0000000..6d8228c --- /dev/null +++ b/samples/exampleWlClientSimpleRendering.cpp @@ -0,0 +1,403 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define BUF_WIDTH 400 +#define BUF_HEIGHT 200 +#define TEST_COUNT 200 +#define BUF_NUM 3 + +class WlClientSimpleRendering { + int __width; + int __height; + int __stride; + int __size; + int __count; + tbm_format __format; + tbm_surface_h __tbmSurface[BUF_NUM]; + + Ecore_Wl2_Display *__ecoreWl2Dpy; + struct wl_display *__wlDisplay; + struct wl_registry *__wlRegistry; + +public: + WlClientSimpleRendering(int width, int height, tbm_format format) + :__width(width), + __height(height), + __format(format) + { + __stride = width * 4; + __size = height * __stride; + __count = 0; + + for (int i = 0; i < BUF_NUM; i++) + { + __tbmSurface[i] = nullptr; + __wlBuffer[i] = nullptr; + } + + __ecoreWl2Dpy = nullptr; + __wlDisplay = nullptr; + __wlRegistry = nullptr; + __wlCompositor = nullptr; + __wlShell = nullptr; + __wlSurface = nullptr; + __wlShellSurface = nullptr; + __wlTbmClient = nullptr; + } + + ~WlClientSimpleRendering() + { + if (__wlShellSurface != nullptr) wl_shell_surface_destroy(__wlShellSurface); + if (__wlSurface != nullptr) wl_surface_destroy(__wlSurface); + for (int i = 0; i < BUF_NUM; i++) + { + if (__wlBuffer[i] != nullptr) wl_buffer_destroy(__wlBuffer[i]); + if (__tbmSurface[i] != nullptr) tbm_surface_destroy(__tbmSurface[i]); + } + if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); + if (__wlShell != nullptr) wl_shell_destroy(__wlShell); + if (__wlCompositor != nullptr) wl_compositor_destroy(__wlCompositor); + + if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); + if (__ecoreWl2Dpy != nullptr) ecore_wl2_display_disconnect(__ecoreWl2Dpy); + } + + int ConnectDisplay(); + void DisconnectDisplay(); + int CreateBuffer(int bufferNum); + void DestroyBuffer(int bufferNum); + int RenderingBuffer(int bufferNum, unsigned char color); + void CommitBuffer(int bufferNum); + + struct wl_compositor *__wlCompositor; + struct wl_shell *__wlShell; + struct wl_surface *__wlSurface; + struct wl_shell_surface *__wlShellSurface; + struct wl_buffer *__wlBuffer[BUF_NUM]; + struct wayland_tbm_client *__wlTbmClient; +}; + +static void +handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) +{ + WlClientSimpleRendering *temp = (WlClientSimpleRendering *)data; + + if (strcmp(interface, "wl_compositor") == 0) { + temp->__wlCompositor = (struct wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 3); + if (temp->__wlCompositor == nullptr) + std::cout << __func__ << " Error. fail to bind " << interface << std::endl; + else + std::cout << __func__ << " bind " << interface << std::endl; + } else if (strcmp(interface, "wl_shell") == 0) { + temp->__wlShell = (struct wl_shell *)wl_registry_bind(registry, name, &wl_shell_interface, 1); + if (temp->__wlShell == nullptr) + std::cout << __func__ << " Error. fail to bind " << interface << std::endl; + else + std::cout << __func__ << " bind " << interface << std::endl; + } else { + std::cout << __func__ << " Not bind" << interface << std::endl; + } +} + +static void +handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) +{ +} + +static const struct wl_registry_listener registry_listener = { + handle_global, + handle_global_remove +}; + +int WlClientSimpleRendering::ConnectDisplay() +{ + __ecoreWl2Dpy = ecore_wl2_display_connect(NULL); + if (__ecoreWl2Dpy == nullptr) + { + std::cout << __func__ << " Error. fail ecore_wl2_display_connect" << std::endl; + return -1; + } + + __wlDisplay = ecore_wl2_display_get(__ecoreWl2Dpy); + if (__wlDisplay == nullptr) + { + std::cout << __func__ << " Error. fail ecore_wl2_display_get" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + __wlRegistry = wl_display_get_registry(__wlDisplay); + if (__wlRegistry == nullptr) + { + std::cout << __func__ << " Error. fail wl_display_get_registry" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + wl_registry_add_listener(__wlRegistry, ®istry_listener, this); + wl_display_dispatch(__wlDisplay); + wl_display_roundtrip(__wlDisplay); + + if (__wlCompositor == nullptr || __wlShell == nullptr) + { + std::cout << __func__ << " Error. fail binding" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + __wlTbmClient = wayland_tbm_client_init(__wlDisplay); + if (__wlTbmClient == nullptr) + { + std::cout << __func__ << " Error. fail wayland_tbm_client_init" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + __wlSurface = wl_compositor_create_surface(__wlCompositor); + if (__wlSurface == nullptr) + { + std::cout << __func__ << " Error. fail wl_compositor_create_surface" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + __wlShellSurface = wl_shell_get_shell_surface(__wlShell, __wlSurface); + if (__wlShellSurface == nullptr) + { + std::cout << __func__ << " Error. fail wl_shell_get_shell_surface" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + return 0; +} + +void WlClientSimpleRendering::DisconnectDisplay() +{ + int i; + + if (__wlShellSurface != nullptr) wl_shell_surface_destroy(__wlShellSurface); + __wlShellSurface = nullptr; + if (__wlSurface != nullptr) wl_surface_destroy(__wlSurface); + __wlSurface = nullptr; + for (i = 0; i < BUF_NUM; i++) + { + this->DestroyBuffer(i); + } + if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); + __wlTbmClient = nullptr; + + if (__wlShell != nullptr) wl_shell_destroy(__wlShell); + __wlShell = nullptr; + if (__wlCompositor) wl_compositor_destroy(__wlCompositor); + __wlCompositor = nullptr; + + if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); + __wlRegistry = nullptr; + __wlDisplay = nullptr; + if (__ecoreWl2Dpy != nullptr) ecore_wl2_display_disconnect(__ecoreWl2Dpy); + __ecoreWl2Dpy = nullptr; +} + +int WlClientSimpleRendering::CreateBuffer(int bufferNum) +{ + tbm_surface_h tbm_surface; + + if (bufferNum >= BUF_NUM) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return -1; + } + + if (__wlTbmClient == nullptr) + { + std::cout << __func__ << " Error. no __wlTbmClient. execute ConnectDisplay first" << std::endl; + return -1; + } + + tbm_surface = tbm_surface_create(__width, __height, __format); + if (tbm_surface == nullptr) + { + std::cout << __func__ << " Error. fail to create tbm_surface" << std::endl; + return -1; + } + + if (__tbmSurface[bufferNum] != nullptr) + { + std::cout << __func__ << " destroy prev tbm_surface " << bufferNum << ":" << __tbmSurface[bufferNum] << std::endl; + this->DestroyBuffer(bufferNum); + } + __tbmSurface[bufferNum] = tbm_surface; + + __wlBuffer[bufferNum] = wayland_tbm_client_create_buffer(__wlTbmClient, __tbmSurface[bufferNum]); + if (__wlBuffer[bufferNum] == nullptr) + { + std::cout << __func__ << " Error. fail to create wl_buffer" << std::endl; + tbm_surface_destroy(__tbmSurface[bufferNum]); + __tbmSurface[bufferNum] = nullptr; + return -1; + } + + std::cout << __func__ << " create " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; + + return 0; +} + +void WlClientSimpleRendering::DestroyBuffer(int bufferNum) +{ + if (bufferNum >= BUF_NUM) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return; + } + + if (__tbmSurface[bufferNum] == nullptr) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return; + } + + std::cout << __func__ << " destroy " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; + + wl_buffer_destroy(__wlBuffer[bufferNum]); + __wlBuffer[bufferNum] = nullptr; + tbm_surface_destroy(__tbmSurface[bufferNum]); + __tbmSurface[bufferNum] = nullptr; +} + +int WlClientSimpleRendering::RenderingBuffer(int bufferNum, unsigned char color) +{ + tbm_surface_h tbm_surface; + tbm_surface_info_s info; + int ret = 0; + + if (bufferNum >= BUF_NUM) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return -1; + } + + tbm_surface = __tbmSurface[bufferNum]; + if (tbm_surface == nullptr) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return -1; + } + + ret = tbm_surface_map(tbm_surface, TBM_SURF_OPTION_WRITE, &info); + if (ret != 0) + { + std::cout << __func__ << " Error. fail to tbm_surface_map " << ret << std::endl; + return ret; + } + + memset(info.planes[0].ptr, color, info.planes[0].stride * info.height); + + tbm_surface_unmap(tbm_surface); + + return ret; +} + +void WlClientSimpleRendering::CommitBuffer(int bufferNum) +{ + int ret = 0; + + if (__wlSurface == nullptr || __wlDisplay == nullptr) + { + std::cout << __func__ << " Error. execute connect first" << std::endl; + return; + } + + if (bufferNum >= BUF_NUM || __wlBuffer[bufferNum] == nullptr) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return; + } + + wl_surface_attach(__wlSurface, __wlBuffer[bufferNum], 0, 0); + wl_surface_damage(__wlSurface, 0, 0, __width, __height); + wl_surface_commit(__wlSurface); + + std::cout << __func__ << " commit " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; + + ret = wl_display_dispatch(__wlDisplay); + if (ret < 0) { + std::cout << __func__ << " Error. wl_display_dispatch error:" << ret << std::endl; + return; + } + + wl_display_roundtrip(__wlDisplay); +} + +int main (void) +{ + WlClientSimpleRendering *simpleRenderSample = nullptr; + int count = 0; + int ret = 0; + int i; + unsigned char color; + + ecore_wl2_init(); + + simpleRenderSample = new WlClientSimpleRendering(BUF_WIDTH, BUF_HEIGHT, TBM_FORMAT_XRGB8888); + if (simpleRenderSample == nullptr) + { + std::cout << __func__ << " Error. fail create WlClientSimpleRendering" << std::endl; + ecore_wl2_shutdown(); + return -1; + } + + ret = simpleRenderSample->ConnectDisplay(); + if (ret) + { + std::cout << __func__ << " Error. fail ConnectDisplay" << std::endl; + ecore_wl2_shutdown(); + return -1; + } + + for (i = 0; i < BUF_NUM; i++) + { + ret = simpleRenderSample->CreateBuffer(i); + if (ret) + { + std::cout << __func__ << " Error. fail CreateBuffer " << i << std::endl; + goto finish; + } + } + + wl_shell_surface_set_toplevel(simpleRenderSample->__wlShellSurface); + + /* main loop */ + i = 0; + color = 0x11; + std::cout << __func__ << " loop start." << std::endl; + while (count < TEST_COUNT) { + simpleRenderSample->RenderingBuffer(i, color); + simpleRenderSample->CommitBuffer(i); + count++; + i++; + if (i == BUF_NUM) i = 0; + if (color == 0xff) + color = 0x11; + else + color += 0x11; + std::cout << __func__ << " loop running " << count << std::endl; + usleep(100000); + } + std::cout << __func__ << " loop end." << std::endl; + +finish: + simpleRenderSample->DisconnectDisplay(); + + delete simpleRenderSample; + + ecore_wl2_shutdown(); + + return 0; +} diff --git a/samples/meson.build b/samples/meson.build index 1e02cc9..cbc09ce 100644 --- a/samples/meson.build +++ b/samples/meson.build @@ -35,3 +35,12 @@ executable('exampleClient', install_dir : libds_prefix_bindir, install : true ) + +ecore_wayland2_dep = dependency('ecore-wl2') +wayland_tbm_client_dep = dependency('wayland-tbm-client') +executable('exampleWlClientSimpleRendering', + 'exampleWlClientSimpleRendering.cpp', + dependencies : [libds_declared_dep, wayland_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], + install_dir : libds_prefix_bindir, + install : true + ) -- 2.7.4 From a1dfb25a59eb2eb1fc62fba3baf2059a4537fdc4 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Mon, 27 Jul 2020 18:56:00 +0900 Subject: [PATCH 13/16] DSWindowShell - add skeleton code Change-Id: I8b4550acc37addffbbfec0301ba8889c6a0bb807 --- src/DSWindowShell/DSWindowShell.cpp | 233 ++++++++++++++++++++++++ src/DSWindowShell/DSWindowShell.h | 71 ++++++++ src/DSWindowShell/DSWindowShellPrivate.cpp | 190 ++++++++++++++++++++ src/DSWindowShell/DSWindowShellPrivate.h | 66 +++++++ src/meson.build | 3 + tests/DSWindowShell-test.cpp | 276 +++++++++++++++++++++++++++++ tests/meson.build | 1 + 7 files changed, 840 insertions(+) create mode 100644 src/DSWindowShell/DSWindowShell.cpp create mode 100644 src/DSWindowShell/DSWindowShell.h create mode 100644 src/DSWindowShell/DSWindowShellPrivate.cpp create mode 100644 src/DSWindowShell/DSWindowShellPrivate.h create mode 100644 tests/DSWindowShell-test.cpp diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp new file mode 100644 index 0000000..3951c12 --- /dev/null +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -0,0 +1,233 @@ +#include "DSWindowShell.h" +#include "DSWindowShellPrivate.h" + +namespace display_server +{ + +struct DTWindowShell +{ +}; + +DSWindowShell::DSWindowShell() + : DS_INIT_PRIVATE_PTR(DSWindowShell) +{} + +DSWindowShell::~DSWindowShell() +{ + +} + +bool DSWindowShell::create(DSWindowShell *pParent) +{ + return true; +} + +bool DSWindowShell::create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pParent) +{ + return true; +} + +void DSWindowShell::destroy(void) +{ + +} + +bool DSWindowShell::setPosition(int x, int y) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->setPosition(x, y); +} + +stPosition DSWindowShell::getPosition(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->getPosition(); +} + +bool DSWindowShell::setSize(int w, int h) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->setSize(w, h); +} + + +bool DSWindowShell::show(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->show(); +} + +bool DSWindowShell::hide(bool autoFocus) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->hide(autoFocus); +} + +int DSWindowShell::showState(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->showState(); +} + + +bool DSWindowShell::setLayer(int layer) +{ + return true; +} + +int DSWindowShell::getLayer(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->getLayer(); +} + + +bool DSWindowShell::raise(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->raise(); +} + +bool DSWindowShell::lower(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->lower(); +} + + +bool DSWindowShell::setFocus(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->setFocus(); +} + +bool DSWindowShell::isFocused(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->isFocused(); +} + + +bool DSWindowShell::activate(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->activate(); +} + +bool DSWindowShell::isActivated(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->isActivated(); +} + + +bool DSWindowShell::iconify(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->iconify(); +} + +bool DSWindowShell::iconify(bool by_client) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->iconify(by_client); +} + +bool DSWindowShell::uniconify(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->uniconify(); +} + +bool DSWindowShell::uniconify(bool by_client) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->uniconify(by_client); +} + +int DSWindowShell::getIconicState(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->getIconicState(); +} + + +bool DSWindowShell::setType(int type) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->setType(type); +} + +int DSWindowShell::getType(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->getType(); +} + + +bool DSWindowShell::maximize(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->maximize(); +} + +bool DSWindowShell::isMaximized(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->isMaximized(); +} + + +bool DSWindowShell::fullscreen(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->fullscreen(); +} + +bool DSWindowShell::isFullscreen(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->isFullscreen(); +} + + +bool DSWindowShell::setRole(const char *role) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->setRole(role); +} + +const char* DSWindowShell::getRole(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->getRole(); +} + + +} // namespace display_server \ No newline at end of file diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h new file mode 100644 index 0000000..7bbfafd --- /dev/null +++ b/src/DSWindowShell/DSWindowShell.h @@ -0,0 +1,71 @@ +#ifndef _DS_WINDOW_SHELL_H_ +#define _DS_WINDOW_SHELL_H_ + +#include "DSStruct.h" +#include "DSCore.h" + +namespace display_server +{ + +class DSWindowShellPrivate; + +class DSWindowShell +{ +DS_PIMPL_USE_PRIVATE(DSWindowShell) + +public: + explicit DSWindowShell(); + virtual ~DSWindowShell(); + + bool create(DSWindowShell *pParent); + bool create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pParent); + + void destroy(void); + + bool setPosition(int x, int y); + stPosition getPosition(void); + + bool setSize(int w, int h); + + bool show(void); + bool hide(bool autoFocus = true); + int showState(void); + + bool setLayer(int layer); + int getLayer(void); + + bool raise(void); + bool lower(void); + + bool setFocus(void); + bool isFocused(void); + + bool activate(void); + bool isActivated(void); + + bool iconify(void); + bool iconify(bool by_client); + bool uniconify(void); + bool uniconify(bool by_client); + int getIconicState(void); + + bool setType(int type); + int getType(void); + + bool maximize(void); + bool isMaximized(void); + + bool fullscreen(void); + bool isFullscreen(void); + + bool setRole(const char *role); + const char* getRole(void); + +protected: + +private: +}; + +} + +#endif // _DS_WINDOW_SHELL_H_ \ No newline at end of file diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp new file mode 100644 index 0000000..9f62f6b --- /dev/null +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -0,0 +1,190 @@ +#include "DSWindowShell.h" +#include "DSWindowShellPrivate.h" + +namespace display_server +{ + +struct DTWindowShell +{ +}; + +DSWindowShellPrivate::DSWindowShellPrivate(DSWindowShell *p_ptr) + : __p_ptr(p_ptr) +{ +} + +DSWindowShellPrivate::~DSWindowShellPrivate() +{ + +} + + +bool DSWindowShellPrivate::create(DSWindowShell *pParent) +{ + return true; +} + +bool DSWindowShellPrivate::create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pParent) +{ + return true; +} + + +void DSWindowShellPrivate::destroy(void) +{ + +} + + +bool DSWindowShellPrivate::setPosition(int x, int y) +{ + return true; +} + +stPosition DSWindowShellPrivate::getPosition(void) +{ + stPosition pos; + + pos.x = 0; + pos.y = 0; + + return pos; +} + +bool DSWindowShellPrivate::setSize(int w, int h) +{ + return true; +} + + +bool DSWindowShellPrivate::show(void) +{ + return true; +} + +bool DSWindowShellPrivate::hide(bool autoFocus) +{ + return true; +} + +int DSWindowShellPrivate::showState(void) +{ + return 0; +} + + +bool DSWindowShellPrivate::setLayer(int layer) +{ + return true; +} + +int DSWindowShellPrivate::getLayer(void) +{ + return 0; +} + + +bool DSWindowShellPrivate::raise(void) +{ + return true; +} + +bool DSWindowShellPrivate::lower(void) +{ + return true; +} + + +bool DSWindowShellPrivate::setFocus(void) +{ + return true; +} + +bool DSWindowShellPrivate::isFocused(void) +{ + return true; +} + + +bool DSWindowShellPrivate::activate(void) +{ + return true; +} + +bool DSWindowShellPrivate::isActivated(void) +{ + return true; +} + + +bool DSWindowShellPrivate::iconify(void) +{ + return true; +} + +bool DSWindowShellPrivate::iconify(bool by_client) +{ + return true; +} + +bool DSWindowShellPrivate::uniconify(void) +{ + return true; +} + +bool DSWindowShellPrivate::uniconify(bool by_client) +{ + return true; +} + +int DSWindowShellPrivate::getIconicState(void) +{ + return 0; +} + + +bool DSWindowShellPrivate::setType(int type) +{ + return true; +} + +int DSWindowShellPrivate::getType(void) +{ + return 0; +} + + +bool DSWindowShellPrivate::maximize(void) +{ + return true; +} + +bool DSWindowShellPrivate::isMaximized(void) +{ + return true; +} + + +bool DSWindowShellPrivate::fullscreen(void) +{ + return true; +} + +bool DSWindowShellPrivate::isFullscreen(void) +{ + return true; +} + + +bool DSWindowShellPrivate::setRole(const char *role) +{ + return true; +} + +const char* DSWindowShellPrivate::getRole(void) +{ + return nullptr; +} + + +} // namespace display_server \ No newline at end of file diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h new file mode 100644 index 0000000..0f8c68f --- /dev/null +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -0,0 +1,66 @@ +#ifndef _DS_WINDOW_SHELL_PRIVATE_H_ +#define _DS_WINDOW_SHELL_PRIVATE_H_ + +namespace display_server +{ + +class DSWindowShellPrivate +{ +DS_PIMPL_USE_PUBLIC(DSWindowShell) + +public: + DSWindowShellPrivate() = delete; + DSWindowShellPrivate(DSWindowShell *p_ptr); + ~DSWindowShellPrivate(); + + bool create(DSWindowShell *pParent); + bool create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pParent); + + void destroy(void); + + bool setPosition(int x, int y); + stPosition getPosition(void); + + bool setSize(int w, int h); + + bool show(void); + bool hide(bool autoFocus = true); + int showState(void); + + bool setLayer(int layer); + int getLayer(void); + + bool raise(void); + bool lower(void); + + bool setFocus(void); + bool isFocused(void); + + bool activate(void); + bool isActivated(void); + + bool iconify(void); + bool iconify(bool by_client); + bool uniconify(void); + bool uniconify(bool by_client); + int getIconicState(void); + + bool setType(int type); + int getType(void); + + bool maximize(void); + bool isMaximized(void); + + bool fullscreen(void); + bool isFullscreen(void); + + bool setRole(const char *role); + const char* getRole(void); + +private: + bool __create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pWin, DSWindowShell *pParent); +}; + +} + +#endif // _DS_WINDOW_SHELL_PRIVATE_H_ \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index 4c17274..4b4b283 100644 --- a/src/meson.build +++ b/src/meson.build @@ -49,6 +49,8 @@ libds_srcs = [ 'DSCore/DSCore.h', 'DSWindow/DSWindow.cpp', 'DSWindow/DSWindowPrivate.cpp', + 'DSWindowShell/DSWindowShell.cpp', + 'DSWindowShell/DSWindowShellPrivate.cpp', 'DSZone/DSZone.cpp', ] @@ -164,6 +166,7 @@ libds_include_dirs = include_directories( './DSCore', './DSWaylandServer', './DSWindow', + './DSWindowShell', './DSZone', ) diff --git a/tests/DSWindowShell-test.cpp b/tests/DSWindowShell-test.cpp new file mode 100644 index 0000000..8a1ea55 --- /dev/null +++ b/tests/DSWindowShell-test.cpp @@ -0,0 +1,276 @@ +#include "libds-tests.h" +#include "DSObject.h" +#include "DSWindowShell.h" + +using namespace display_server; + +class DSWindowShellTest : public ::testing::Test +{ +public: + void SetUp(void) override + {} + void TearDown(void) override + {} +}; + +TEST_F(DSWindowShellTest, NewDSWindowShell) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); +} + +TEST_F(DSWindowShellTest, create_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(nullptr) == true); +} + +TEST_F(DSWindowShellTest, create_P2) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); +} + +TEST_F(DSWindowShellTest, setPosition_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->setPosition(100, 150) == true); +} + +TEST_F(DSWindowShellTest, getPosition_P1) +{ + stPosition pos; + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->setPosition(100, 150) == true); + + pos = shell->getPosition(); + + EXPECT_TRUE(pos.x == 100); + EXPECT_TRUE(pos.y == 150); +} + +TEST_F(DSWindowShellTest, setSize_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->setSize(720, 1280) == true); +} + +TEST_F(DSWindowShellTest, show_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->show() == true); +} + +TEST_F(DSWindowShellTest, hide_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->hide(true) == true); +} + +TEST_F(DSWindowShellTest, showState_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->showState() == 0); +} + +TEST_F(DSWindowShellTest, setLayer_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->setLayer(100) == true); +} + +TEST_F(DSWindowShellTest, getLayer_P1) +{ + int layer = -1; + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->setLayer(100) == true); + + layer = shell->getLayer(); + EXPECT_TRUE(layer == 100); +} + +TEST_F(DSWindowShellTest, raise_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->raise() == true); +} + +TEST_F(DSWindowShellTest, lower_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->lower() == true); +} + +TEST_F(DSWindowShellTest, setFocus_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->setFocus() == true); +} + +TEST_F(DSWindowShellTest, isFocused_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->setFocus() == true); + + EXPECT_TRUE(shell->isFocused() == true); +} + +TEST_F(DSWindowShellTest, activate_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, isActivated_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, iconify_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, iconify_P2) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, uniconify_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, uniconify_P2) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, getIconicState_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, setType_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, getType_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, maximize_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, isMaximized_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, fullscreen_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, isFullscreen_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, setRole_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} + +TEST_F(DSWindowShellTest, getRole_P1) +{ + std::unique_ptr shell = std::make_unique(); + EXPECT_TRUE(shell != nullptr); + + // do something +} diff --git a/tests/meson.build b/tests/meson.build index b09a5c6..22ac7a0 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -16,6 +16,7 @@ libds_tests_srcs = [ 'DSDisplayDeviceTDMImpl-test.cpp', 'DSSignal-test.cpp', 'DSWindow-test.cpp', + 'DSWindowShell-test.cpp', 'DSWaylandCallback-test.cpp', 'DSWaylandOutput-test.cpp', 'DSWaylandSurface-test.cpp', -- 2.7.4 From a81d42ed6b4bb8603836dfc442b6f3fb199bcb6f Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 27 Jul 2020 19:53:29 +0900 Subject: [PATCH 14/16] DSWindow: add geometric information, apis and integration DSWindow*.cpp into DSWindow.cpp Change-Id: Ic9be2b9ec07164efa5ffc7e0eb9ad8da4518e326 Signed-off-by: Sung-Jin Park --- src/DSCore/DSStruct.h | 9 +++ src/DSWindow/DSWindow.cpp | 153 +++++++++++++++++++++++++++++++++++++-- src/DSWindow/DSWindow.h | 12 +++ src/DSWindow/DSWindowPrivate.cpp | 82 --------------------- src/DSWindow/DSWindowPrivate.h | 20 ++++- src/meson.build | 3 +- tests/DSWindow-test.cpp | 60 +++++++++++---- 7 files changed, 232 insertions(+), 107 deletions(-) delete mode 100644 src/DSWindow/DSWindowPrivate.cpp diff --git a/src/DSCore/DSStruct.h b/src/DSCore/DSStruct.h index 92f8e39..fb9aa51 100644 --- a/src/DSCore/DSStruct.h +++ b/src/DSCore/DSStruct.h @@ -8,6 +8,7 @@ namespace display_server using stPosition = struct _stPosition; using stRect = struct _stRect; +using stGeometry = struct _stGeometry; struct _stPosition { @@ -23,6 +24,14 @@ struct _stRect uint32_t h; }; +struct _stGeometry +{ + int x; + int y; + unsigned int w; + unsigned int h; +}; + } // namespace display_server #endif //__DS_STRUCT_H__ diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 5c2b797..52d6eba 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -4,20 +4,129 @@ namespace display_server { +DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr), + __x(0), + __y(0), + __w(1), + __h(1), + __created(false), + __hasFocus(false) +{ +} + +DSWindowPrivate::~DSWindowPrivate() +{ +} + +bool DSWindowPrivate::create(DSWindow *pParent) +{ + // get screen position (x, y) + + // get screen width (w, h) + + __created = __create(__x, __y, __w, __h, pParent); + return __created; +} + +bool DSWindowPrivate::create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent) +{ + __created = __create(x, y, w, h, pParent); + return __created; +} + +void DSWindowPrivate::destroy(void) +{ +} + +bool DSWindowPrivate::show(void) +{ + return true; +} + +bool DSWindowPrivate::hide(bool autoFocus) +{ + return true; +} + +int DSWindowPrivate::showState(void) +{ + return 0; +} + +bool DSWindowPrivate::setLayer(int layer) +{ + return true; +} + +bool DSWindowPrivate::raise(void) +{ + return true; +} + +bool DSWindowPrivate::lower(void) +{ + return true; +} + +bool DSWindowPrivate::setFocus(void) +{ + return true; +} + +bool DSWindowPrivate::__create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent) +{ + DS_GET_PUB(DSWindow); + + __x = x; + __y = y; + __w = w; + __h = h; + pub->__parentWindow = pParent; + + // Do something + + return true; +} + +bool DSWindowPrivate::isCreated() +{ + return __created; +} + DSWindow::DSWindow() - : DS_INIT_PRIVATE_PTR(DSWindow) -{} + : DS_INIT_PRIVATE_PTR(DSWindow), + __parentWindow(nullptr) +{ +} + +DSWindow::DSWindow(DSWindow *pParent) + : DS_INIT_PRIVATE_PTR(DSWindow), + __parentWindow(pParent) +{ + create(pParent); +} + +DSWindow::DSWindow(DSWindow *pParent, int x, int y, unsigned int w, unsigned h) + : DS_INIT_PRIVATE_PTR(DSWindow), + __parentWindow(pParent) +{ + create(x, y, w, h, pParent); +} DSWindow::~DSWindow() -{} +{ + +} bool DSWindow::create(DSWindow *pParent) { DS_GET_PRIV(DSWindow); - if (priv->create(this, pParent) == false) + if (!priv->isCreated()) { - return false; + return priv->create(pParent); } return true; @@ -27,9 +136,9 @@ bool DSWindow::create(int x, int y, unsigned int w, unsigned int h, DSWindow *pP { DS_GET_PRIV(DSWindow); - if (priv->create(x, y, w, h, this, pParent) == false) + if (!priv->isCreated()) { - return false; + return priv->create(x, y, w, h, pParent); } return true; @@ -92,5 +201,35 @@ bool DSWindow::setFocus(void) return priv->setFocus(); } +bool DSWindow::hasFocus(void) +{ + DS_GET_PRIV(DSWindow); + + return priv->__hasFocus; +} + +DSWindow *DSWindow::getParent() +{ + return __parentWindow; +} + +void DSWindow::setParent(DSWindow *pParent) +{ + DSLOG_INF("DSWindow", "Parent window has been changed. (%p -> %p)", __parentWindow, pParent); + __parentWindow = pParent; +} + +stGeometry DSWindow::getGeometry() +{ + DS_GET_PRIV(DSWindow); + + stGeometry geom; + geom.x = priv->__x; + geom.y = priv->__y; + geom.w = priv->__w; + geom.h = priv->__h; + + return geom; +} } // namespace display_server \ No newline at end of file diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index cd59a0d..fca506b 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -2,6 +2,7 @@ #define _DS_WINDOW_H_ #include "DSCore.h" +#include "DSStruct.h" #include "DSObject.h" namespace display_server @@ -15,6 +16,8 @@ class DSWindow : public DSObject public: explicit DSWindow(); + DSWindow(DSWindow *pParent); + DSWindow(DSWindow *pParent, int x, int y, unsigned int w, unsigned h); virtual ~DSWindow(); bool create(DSWindow *pParent); @@ -31,10 +34,19 @@ public: bool lower(void); bool setFocus(void); + bool hasFocus(void); + + DSWindow *getParent(); + void setParent(DSWindow *pParent); + + stGeometry getGeometry(); protected: //virtual bool _onFocus(void); //virtual bool _onShowStateChange(void); + +private: + DSWindow *__parentWindow; }; } diff --git a/src/DSWindow/DSWindowPrivate.cpp b/src/DSWindow/DSWindowPrivate.cpp deleted file mode 100644 index caa062a..0000000 --- a/src/DSWindow/DSWindowPrivate.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "DSWindow.h" -#include "DSWindowPrivate.h" - -namespace display_server -{ - -DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{ -} - -DSWindowPrivate::~DSWindowPrivate() -{ -} - -bool DSWindowPrivate::create(DSWindow *pWin, DSWindow *pParent) -{ - int x = 0; - int y = 0; - unsigned int w = 1; - unsigned int h = 1; - - // get screen position (x, y) - - // get screen width (w, h) - - return __create(x, y, w, h, pWin, pParent); -} - -bool DSWindowPrivate::create(int x, int y, unsigned int w, unsigned int h, DSWindow *pWin, DSWindow *pParent) -{ - return __create(x, y, w, h, pWin, pParent); -} - -void DSWindowPrivate::destroy(void) -{ -} - -bool DSWindowPrivate::show(void) -{ - return true; -} - -bool DSWindowPrivate::hide(bool autoFocus) -{ - return true; -} - -int DSWindowPrivate::showState(void) -{ - return 0; -} - -bool DSWindowPrivate::setLayer(int layer) -{ - return true; -} - -bool DSWindowPrivate::raise(void) -{ - return true; -} - -bool DSWindowPrivate::lower(void) -{ - return true; -} - -bool DSWindowPrivate::setFocus(void) -{ - return true; -} - -bool DSWindowPrivate::__create(int x, int y, unsigned int w, unsigned int h, DSWindow *pWin, DSWindow *pParent) -{ - // Do something - - return true; -} - -} // namespace display_server \ No newline at end of file diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index 507cd56..44f284b 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -1,9 +1,14 @@ #ifndef _DS_WINDOW_PRIVATE_H_ #define _DS_WINDOW_PRIVATE_H_ +#include "DSCore.h" +#include "DSObjectPrivate.h" + namespace display_server { +class DSWindow; + class DSWindowPrivate : public DSObjectPrivate { DS_PIMPL_USE_PUBLIC(DSWindow) @@ -13,8 +18,8 @@ public: DSWindowPrivate(DSWindow *p_ptr); ~DSWindowPrivate(); - bool create(DSWindow *pWin, DSWindow *pParent); - bool create(int x, int y, unsigned int w, unsigned int h, DSWindow *pWin, DSWindow *pParent); + bool create(DSWindow *pParent); + bool create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent); void destroy(void); @@ -27,10 +32,17 @@ public: bool lower(void); bool setFocus(void); + bool isCreated(); private: - bool __create(int x, int y, unsigned int w, unsigned int h, DSWindow *pWin, DSWindow *pParent); - + bool __create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent); + + int __x; + int __y; + unsigned int __w; + unsigned int __h; + bool __created; + bool __hasFocus; }; } diff --git a/src/meson.build b/src/meson.build index 4b4b283..24bfcf4 100644 --- a/src/meson.build +++ b/src/meson.build @@ -47,8 +47,9 @@ libds_srcs = [ 'DSSignal/DSSignal.h', 'DSCore/DSStruct.h', 'DSCore/DSCore.h', + 'DSWindow/DSWindow.h', + 'DSWindow/DSWindowPrivate.h', 'DSWindow/DSWindow.cpp', - 'DSWindow/DSWindowPrivate.cpp', 'DSWindowShell/DSWindowShell.cpp', 'DSWindowShell/DSWindowShellPrivate.cpp', 'DSZone/DSZone.cpp', diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index 07b41fe..9838ca8 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -1,6 +1,7 @@ #include "libds-tests.h" #include "DSObject.h" #include "DSWindow.h" +#include "DSStruct.h" using namespace display_server; @@ -15,26 +16,59 @@ public: TEST_F(DSWindowTest, NewDSWindow) { - std::unique_ptr Window = std::make_unique(); - EXPECT_TRUE(Window != nullptr); + DSWindow *win = new DSWindow(); + EXPECT_TRUE(win != nullptr); +} + +TEST_F(DSWindowTest, NewDSWindowWithParent) +{ + DSWindow *wParent = new DSWindow(); + EXPECT_TRUE(wParent != nullptr); + + DSWindow *wChild = new DSWindow(wParent); + EXPECT_TRUE(wChild != nullptr); +} + +TEST_F(DSWindowTest, NewDSWindowWithGeometry) +{ + int x = 100; + int y = 100; + unsigned int w = 500; + unsigned int h = 500; + + DSWindow *win = new DSWindow(nullptr, x, y, w, h); + EXPECT_TRUE(win != nullptr); + + stGeometry geom = win->getGeometry(); + EXPECT_TRUE(geom.x == x); + EXPECT_TRUE(geom.y == y); + EXPECT_TRUE(geom.w == w); + EXPECT_TRUE(geom.h == h); } TEST_F(DSWindowTest, BasicMethods) { - std::unique_ptr Window = std::make_unique(); - EXPECT_TRUE(Window != nullptr); + bool hasFocus = false; + + DSWindow *win = new DSWindow(); + EXPECT_TRUE(win != nullptr); + EXPECT_TRUE(win->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(Window->create(nullptr) == true); - EXPECT_TRUE(Window->create(0, 0, 720, 1280, nullptr) == true); + stGeometry geom = win->getGeometry(); + EXPECT_TRUE(geom.x == 0); + EXPECT_TRUE(geom.y == 0); + EXPECT_TRUE(geom.w == 720); + EXPECT_TRUE(geom.h == 1280); - EXPECT_TRUE(Window->show() == true); - EXPECT_TRUE(Window->hide(true) == true); - EXPECT_TRUE(Window->showState() == 0); + EXPECT_TRUE(win->show() == true); + EXPECT_TRUE(win->hide(true) == true); + EXPECT_TRUE(win->showState() == 0); - EXPECT_TRUE(Window->setLayer(100) == true); + EXPECT_TRUE(win->setLayer(100) == true); - EXPECT_TRUE(Window->raise() == true); - EXPECT_TRUE(Window->lower() == true); + EXPECT_TRUE(win->raise() == true); + EXPECT_TRUE(win->lower() == true); - EXPECT_TRUE(Window->setFocus() == true); + hasFocus = win->setFocus(); + EXPECT_TRUE(hasFocus == win->hasFocus()); } \ No newline at end of file -- 2.7.4 From 7aa7513660b79c8d2893e63715412d104d390340 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 27 Jul 2020 20:57:58 +0900 Subject: [PATCH 15/16] DSClient: add basic implementation and tests Change-Id: I27fca5fcd93959353304506c68daee9810beb864 Signed-off-by: Sung-Jin Park --- src/DSClient/DSClient.cpp | 99 +++++++++++++++++++++++ src/DSClient/DSClient.h | 36 +++++++++ src/DSClient/DSClientPrivate.h | 30 +++++++ src/meson.build | 4 + tests/DSClient-test.cpp | 176 +++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 3 +- 6 files changed, 347 insertions(+), 1 deletion(-) create mode 100644 src/DSClient/DSClient.cpp create mode 100644 src/DSClient/DSClient.h create mode 100644 src/DSClient/DSClientPrivate.h create mode 100644 tests/DSClient-test.cpp diff --git a/src/DSClient/DSClient.cpp b/src/DSClient/DSClient.cpp new file mode 100644 index 0000000..45b72ac --- /dev/null +++ b/src/DSClient/DSClient.cpp @@ -0,0 +1,99 @@ +#include "DSClient.h" +#include "DSClientPrivate.h" +#include "DSWaylandCompositor.h" +#include "DSWaylandClient.h" +#include "DSWindow.h" + +namespace display_server +{ + +/* Begin Private Class Implementation */ +DSClientPrivate::DSClientPrivate(DSClient *client, DSWaylandClient *dswlClient) + : DSObjectPrivate(client), + __p_ptr(client), + __dswlComp(nullptr), + __dswlClient(dswlClient), + __numWindows(0) +{ + __windows.clear(); +} + +DSClientPrivate::~DSClientPrivate() +{ + __windows.clear(); +} + +/* Begin Public Class Implementation */ +DSClient::DSClient(DSCompositor *compositor) + : _d_ptr(std::make_unique(this, nullptr)), + __compositor(compositor) +{ + +} +DSClient::DSClient(DSCompositor *compositor, DSWaylandClient *dswlClient) + : _d_ptr(std::make_unique(this, dswlClient)), + __compositor(compositor) +{ + +} + +DSClient::~DSClient() +{ +} + +void DSClient::addWindow(DSWindow *window) +{ + DS_GET_PRIV(DSClient); + + for (auto win : priv->__windows) + { + if (window == win) + { + DSLOG_ERR("DSClient", "Window(%p) exists already.", window); + return; + } + } + + priv->__windows.push_back(window); + return; +} + +bool DSClient::removeWindow(DSWindow *window) +{ + DS_GET_PRIV(DSClient); + + for (auto win : priv->__windows) + { + if (window == win) + { + priv->__windows.remove(window); + DSLOG_ERR("DSClient", "Window(%p) has been removed.", window); + return true; + } + } + + return false; +} + +std::list DSClient::getWindows() +{ + DS_GET_PRIV(DSClient); + + return priv->__windows; +} + +uint32_t DSClient::numWindows() +{ + DS_GET_PRIV(DSClient); + + return priv->__numWindows; +} + +bool DSClient::hasWindow() +{ + DS_GET_PRIV(DSClient); + + return priv->__numWindows ? true : false; +} + +} // namespace display_server diff --git a/src/DSClient/DSClient.h b/src/DSClient/DSClient.h new file mode 100644 index 0000000..9f851ce --- /dev/null +++ b/src/DSClient/DSClient.h @@ -0,0 +1,36 @@ +#ifndef __DS_SEAT_H__ +#define __DS_SEAT_H__ + +#include "DSCore.h" +#include "DSObject.h" + +namespace display_server +{ + +class DSClientPrivate; +class DSWaylandClient; +class DSCompositor; +class DSWindow; + +class DSClient : public DSObject +{ + DS_PIMPL_USE_PRIVATE(DSClient) +public: + DSClient() = delete; + DSClient(DSCompositor *compositor); + DSClient(DSCompositor *compositor, DSWaylandClient *dswlClient); + ~DSClient() override; + + void addWindow(DSWindow *window); + bool removeWindow(DSWindow *window); + std::list getWindows(); + uint32_t numWindows(); + bool hasWindow(); + +private: + DSCompositor *__compositor; +}; + +} + +#endif //__DS_SEAT_H__ \ No newline at end of file diff --git a/src/DSClient/DSClientPrivate.h b/src/DSClient/DSClientPrivate.h new file mode 100644 index 0000000..62ef3b8 --- /dev/null +++ b/src/DSClient/DSClientPrivate.h @@ -0,0 +1,30 @@ +#ifndef __DS_SEAT_PRIVATE_H__ +#define __DS_SEAT_PRIVATE_H__ + +#include "DSCore.h" +#include "DSObjectPrivate.h" + +namespace display_server +{ + +class DSClient; +class DSWaylandCompositor; + +class DSClientPrivate : public DSObjectPrivate +{ + DS_PIMPL_USE_PUBLIC(DSClient); +public: + DSClientPrivate() = delete; + DSClientPrivate(DSClient *client, DSWaylandClient *dswlClient); + ~DSClientPrivate() override; + +private: + DSWaylandCompositor *__dswlComp; + DSWaylandClient *__dswlClient; + std::list __windows;//use if one or more windows in a client + int __numWindows; +}; + +} + +#endif //__DS_SEAT_PRIVATE_H__ \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index 24bfcf4..4a06e85 100644 --- a/src/meson.build +++ b/src/meson.build @@ -53,6 +53,9 @@ libds_srcs = [ 'DSWindowShell/DSWindowShell.cpp', 'DSWindowShell/DSWindowShellPrivate.cpp', 'DSZone/DSZone.cpp', + 'DSClient/DSClientPrivate.h', + 'DSClient/DSClient.h', + 'DSClient/DSClient.cpp', ] libds_wayland_srcs = [ @@ -169,6 +172,7 @@ libds_include_dirs = include_directories( './DSWindow', './DSWindowShell', './DSZone', + './DSClient', ) libds_lib = shared_library( diff --git a/tests/DSClient-test.cpp b/tests/DSClient-test.cpp new file mode 100644 index 0000000..ba5db7d --- /dev/null +++ b/tests/DSClient-test.cpp @@ -0,0 +1,176 @@ +#include "libds-tests.h" +#include "DSObject.h" +#include "DSClient.h" +#include "DSCompositor.h" +#include "DSWaylandCompositor.h" +#include "DSWindow.h" +#include "DSWaylandClient.h" +#include + +using namespace display_server; + +class DSClientTest : public ::testing::Test +{ +public: + void SetUp(void) override + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + } +}; + +class MockCompositor : public DSCompositor +{ +public: + MockCompositor() {} + ~MockCompositor() {} + + std::shared_ptr _onInitialized() override + { + auto canvas = std::make_shared(); + return canvas; + } + + void _onOutputAdded(std::shared_ptr output) override + {} + + void _onOutputRemoved(std::shared_ptr output) override + {} + + void _onInputAdded(std::shared_ptr input) override + {} + + void _onInputRemoved(std::shared_ptr input) override + {} +}; + +TEST_F(DSClientTest, NewDSClientWithDSWaylandClient) +{ + DSCompositor *comp = new MockCompositor(); + EXPECT_TRUE(comp != nullptr); + + if (comp) + { + DSWaylandCompositor *dswlComp = DSWaylandCompositor::getInstance(); + EXPECT_TRUE(dswlComp != nullptr); + + if (dswlComp) + { + /* client must be created with a valid wl_client ptr later. */ + DSWaylandClient *dswlClient = new DSWaylandClient(dswlComp, (wl_client *)nullptr); + EXPECT_TRUE(dswlClient != nullptr); + + if (dswlClient) + { + DSClient *client = new DSClient(comp, dswlClient); + EXPECT_TRUE(client != nullptr); + + if (client) + delete client; + + delete dswlClient; + } + + DSWaylandCompositor::releaseInstance(); + } + + delete comp; + } +} + +TEST_F(DSClientTest, AddRemoveHasWindow) +{ + DSCompositor *comp = new MockCompositor(); + EXPECT_TRUE(comp != nullptr); + + if (comp) + { + DSWindow *win = new DSWindow(); + EXPECT_TRUE(win != nullptr); + + if (win) + { + DSClient *client = new DSClient(comp); + EXPECT_TRUE(client != nullptr); + + if (client) + { + client->addWindow(win); + EXPECT_TRUE(client->hasWindow() == true); + + client->removeWindow(win); + EXPECT_TRUE(client->hasWindow() != true); + + delete client; + } + + delete win; + } + + delete comp; + } +} + +TEST_F(DSClientTest, GetWindowsNumWindows) +{ + DSCompositor *comp = new MockCompositor(); + EXPECT_TRUE(comp != nullptr); + + if (comp) + { + DSWindow *win1 = new DSWindow(); + EXPECT_TRUE(win1 != nullptr); + + DSWindow *win2 = new DSWindow(); + EXPECT_TRUE(win2 != nullptr); + + DSWindow *win3 = new DSWindow(); + EXPECT_TRUE(win3 != nullptr); + + if (win1 && win2 && win3) + { + DSClient *client = new DSClient(comp); + EXPECT_TRUE(client != nullptr); + + if (client) + { + client->addWindow(win1); + EXPECT_TRUE(client->numWindows() == 1); + client->addWindow(win2); + EXPECT_TRUE(client->numWindows() == 2); + client->addWindow(win3); + EXPECT_TRUE(client->numWindows() == 3); + + int cnt = 3; + std::list winList = client->getWindows(); + for (auto win : winList) + { + if (win == win1 || + win == win2 || + win == win3) + cnt--; + } + + EXPECT_TRUE(cnt == 0); + + client->removeWindow(win1); + EXPECT_TRUE(client->numWindows() == 2); + client->removeWindow(win2); + EXPECT_TRUE(client->numWindows() == 1); + client->removeWindow(win3); + EXPECT_TRUE(client->numWindows() == 0); + + delete client; + } + + delete win1; + delete win2; + delete win3; + } + + delete comp; + } +} diff --git a/tests/meson.build b/tests/meson.build index 22ac7a0..4a741c1 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -35,7 +35,8 @@ libds_tests_srcs = [ 'DSWaylandPointer-test.cpp', 'DSWaylandKeyboard-test.cpp', 'DSWaylandTouch-test.cpp', - 'DSZone-test.cpp' + 'DSZone-test.cpp', + 'DSClient-test.cpp' ] gmock_dep = dependency('gmock', method : 'pkg-config') -- 2.7.4 From dfa7453d7b9b30341d7079df7d7bb7efd2018cfb Mon Sep 17 00:00:00 2001 From: jeon Date: Tue, 28 Jul 2020 08:18:21 +0900 Subject: [PATCH 16/16] DSWaylandInputMethod: add skeleton codes for wl_input_method and wl_input_method_context Change-Id: Ib432d18df446f8f19a4338ba584a443e03b53ac2 --- packaging/libds.spec | 1 + src/DSWaylandServer/DSWaylandInputMethod.cpp | 157 +++++++++++++++++++++ src/DSWaylandServer/DSWaylandInputMethod.h | 27 ++++ src/DSWaylandServer/DSWaylandInputMethodContext.h | 27 ++++ .../DSWaylandInputMethodContextPrivate.h | 54 +++++++ src/DSWaylandServer/DSWaylandInputMethodPrivate.h | 24 ++++ src/meson.build | 10 +- 7 files changed, 299 insertions(+), 1 deletion(-) create mode 100644 src/DSWaylandServer/DSWaylandInputMethod.cpp create mode 100644 src/DSWaylandServer/DSWaylandInputMethod.h create mode 100644 src/DSWaylandServer/DSWaylandInputMethodContext.h create mode 100644 src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h create mode 100644 src/DSWaylandServer/DSWaylandInputMethodPrivate.h diff --git a/packaging/libds.spec b/packaging/libds.spec index 9b432b6..c47a179 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -14,6 +14,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(libtdm) BuildRequires: pkgconfig(wayland-server) BuildRequires: pkgconfig(tizen-extension-server) +BuildRequires: pkgconfig(input-method-server) BuildRequires: pkgconfig(text-server) BuildRequires: pkgconfig(tizen-launch-server) BuildRequires: pkgconfig(tizen-surface-server) diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp new file mode 100644 index 0000000..e361ae4 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandInputMethod.cpp @@ -0,0 +1,157 @@ +#include "DSWaylandInputMethodContext.h" +#include "DSWaylandInputMethodContextPrivate.h" +#include "DSWaylandInputMethod.h" +#include "DSWaylandInputMethodPrivate.h" + +namespace display_server { + +DSWaylandInputMethodContextPrivate::DSWaylandInputMethodContextPrivate(DSWaylandInputMethodContext *p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr) +{ +} + +DSWaylandInputMethodContextPrivate::~DSWaylandInputMethodContextPrivate() +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_destroy(Resource *resource) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_commit_string(Resource *resource, uint32_t serial, const std::string &text) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_preedit_string(Resource *resource, uint32_t serial, const std::string &text, const std::string &commit) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_preedit_cursor(Resource *resource, int32_t index) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_cursor_position(Resource *resource, int32_t index, int32_t anchor) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_modifiers_map(Resource *resource, wl_array *map) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_grab_keyboard(Resource *resource, uint32_t keyboard) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_language(Resource *resource, uint32_t serial, const std::string &language) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_text_direction(Resource *resource, uint32_t serial, uint32_t direction) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_selection_region(Resource *resource, uint32_t serial, int32_t start, int32_t end) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_private_command(Resource *resource, uint32_t serial, const std::string &command) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_update_input_panel_data(Resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_hide_input_panel(Resource *resource, uint32_t serial) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_get_selection_text(Resource *resource, int32_t fd) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_get_surrounding_text(Resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_filter_key_event_done(Resource *resource, uint32_t serial, uint32_t state) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_update_ise_geometry(Resource *resource, uint32_t serial, uint32_t x, uint32_t y, uint32_t width, uint32_t height) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_recapture_string(Resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_input_panel_event(Resource *resource, uint32_t serial, uint32_t event_type, uint32_t value) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_commit_content(Resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_update_candidate_state(Resource *resource, uint32_t state) +{ +} + +void DSWaylandInputMethodContextPrivate::input_method_context_reshow_input_panel(Resource *resource) +{ +} + + +DSWaylandInputMethodContext::DSWaylandInputMethodContext() + : DSObject(), _d_ptr(std::make_unique(this)) +{ +} + +DSWaylandInputMethodContext::~DSWaylandInputMethodContext() +{ +} + + +DSWaylandInputMethodPrivate::DSWaylandInputMethodPrivate(DSWaylandInputMethod *p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr) +{ +} + +DSWaylandInputMethodPrivate::~DSWaylandInputMethodPrivate() +{ +} + + +DSWaylandInputMethod::DSWaylandInputMethod() + : DSObject(), _d_ptr(std::make_unique(this)) +{ +} + +DSWaylandInputMethod::~DSWaylandInputMethod() +{ +} + +} \ No newline at end of file diff --git a/src/DSWaylandServer/DSWaylandInputMethod.h b/src/DSWaylandServer/DSWaylandInputMethod.h new file mode 100644 index 0000000..caf0317 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandInputMethod.h @@ -0,0 +1,27 @@ +#ifndef __DS_WAYLAND_INPUT_METHOD_H__ +#define __DS_WAYLAND_INPUT_METHOD_H__ + +#include "DSCore.h" +#include "DSObject.h" + +namespace display_server +{ + +class DSWaylandInputMethodPrivate; + +class DS_DECL_EXPORT DSWaylandInputMethod : public DSObject +{ +DS_PIMPL_USE_PRIVATE(DSWaylandInputMethod); +public: + DSWaylandInputMethod(); + ~DSWaylandInputMethod() override; + +protected: + +private: + +}; + +} + +#endif //__DS_WAYLAND_INPUT_METHOD_H__ diff --git a/src/DSWaylandServer/DSWaylandInputMethodContext.h b/src/DSWaylandServer/DSWaylandInputMethodContext.h new file mode 100644 index 0000000..b4fb94a --- /dev/null +++ b/src/DSWaylandServer/DSWaylandInputMethodContext.h @@ -0,0 +1,27 @@ +#ifndef __DS_WAYLAND_INPUT_METHOD_CONTEXT_H__ +#define __DS_WAYLAND_INPUT_METHOD_CONTEXT_H__ + +#include "DSCore.h" +#include "DSObject.h" + +namespace display_server +{ + +class DSWaylandInputMethodContextPrivate; + +class DS_DECL_EXPORT DSWaylandInputMethodContext : public DSObject +{ +DS_PIMPL_USE_PRIVATE(DSWaylandInputMethodContext); +public: + DSWaylandInputMethodContext(); + ~DSWaylandInputMethodContext() override; + +protected: + +private: + +}; + +} + +#endif //__DS_WAYLAND_INPUT_METHOD_CONTEXT_H__ diff --git a/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h new file mode 100644 index 0000000..0b362b3 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h @@ -0,0 +1,54 @@ +#ifndef __DS_WAYLAND_INPUT_METHOD_CONTEXT_PRIVATE_H__ +#define __DS_WAYLAND_INPUT_METHOD_CONTEXT_PRIVATE_H__ + +#include "dswayland-server-input-method.h" + +#include "DSCore.h" +#include "DSObjectPrivate.h" +#include "DSWaylandInputMethodContext.h" + +namespace display_server +{ + +class DS_DECL_EXPORT DSWaylandInputMethodContextPrivate : public DSObjectPrivate, public DSWaylandServer::wl_input_method_context +{ +DS_PIMPL_USE_PUBLIC(DSWaylandInputMethodContext); +public: + DSWaylandInputMethodContextPrivate(DSWaylandInputMethodContext *p_ptr); + ~DSWaylandInputMethodContextPrivate() override; + +protected: + void input_method_context_destroy(Resource *resource); + void input_method_context_commit_string(Resource *resource, uint32_t serial, const std::string &text); + void input_method_context_preedit_string(Resource *resource, uint32_t serial, const std::string &text, const std::string &commit); + void input_method_context_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style); + void input_method_context_preedit_cursor(Resource *resource, int32_t index); + void input_method_context_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length); + void input_method_context_cursor_position(Resource *resource, int32_t index, int32_t anchor); + void input_method_context_modifiers_map(Resource *resource, wl_array *map); + void input_method_context_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers); + void input_method_context_grab_keyboard(Resource *resource, uint32_t keyboard); + void input_method_context_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); + void input_method_context_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); + void input_method_context_language(Resource *resource, uint32_t serial, const std::string &language); + void input_method_context_text_direction(Resource *resource, uint32_t serial, uint32_t direction); + void input_method_context_selection_region(Resource *resource, uint32_t serial, int32_t start, int32_t end); + void input_method_context_private_command(Resource *resource, uint32_t serial, const std::string &command); + void input_method_context_update_input_panel_data(Resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length); + void input_method_context_hide_input_panel(Resource *resource, uint32_t serial); + void input_method_context_get_selection_text(Resource *resource, int32_t fd); + void input_method_context_get_surrounding_text(Resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd); + void input_method_context_filter_key_event_done(Resource *resource, uint32_t serial, uint32_t state); + void input_method_context_update_ise_geometry(Resource *resource, uint32_t serial, uint32_t x, uint32_t y, uint32_t width, uint32_t height); + void input_method_context_recapture_string(Resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit); + void input_method_context_input_panel_event(Resource *resource, uint32_t serial, uint32_t event_type, uint32_t value); + void input_method_context_commit_content(Resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types); + void input_method_context_update_candidate_state(Resource *resource, uint32_t state); + void input_method_context_reshow_input_panel(Resource *resource); + +}; + +} + +#endif //__DS_WAYLAND_INPUT_METHOD_CONTEXT_PRIVATE_H__ + diff --git a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h new file mode 100644 index 0000000..dfc4e48 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h @@ -0,0 +1,24 @@ +#ifndef __DS_WAYLAND_INPUT_METHOD_PRIVATE_H__ +#define __DS_WAYLAND_INPUT_METHOD_PRIVATE_H__ + +#include "dswayland-server-input-method.h" + +#include "DSCore.h" +#include "DSObjectPrivate.h" +#include "DSWaylandInputMethod.h" + +namespace display_server +{ + +class DS_DECL_EXPORT DSWaylandInputMethodPrivate : public DSObjectPrivate, public DSWaylandServer::wl_input_method +{ +DS_PIMPL_USE_PUBLIC(DSWaylandInputMethod); +public: + DSWaylandInputMethodPrivate(DSWaylandInputMethod *p_ptr); + ~DSWaylandInputMethodPrivate() override; +}; + +} + +#endif //__DS_WAYLAND_INPUT_METHOD_PRIVATE_H__ + diff --git a/src/meson.build b/src/meson.build index 4a06e85..7e5401b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -73,6 +73,8 @@ libds_wayland_srcs = [ 'DSWaylandServer/dswayland-server-text.h', 'DSWaylandServer/dswayland-server-tizen-launch.cpp', 'DSWaylandServer/dswayland-server-tizen-launch.h', + 'DSWaylandServer/dswayland-server-input-method.cpp', + 'DSWaylandServer/dswayland-server-input-method.h', 'DSWaylandServer/DSWaylandCallback.cpp', 'DSWaylandServer/DSWaylandCallback.h', 'DSWaylandServer/DSWaylandCallbackPrivate.h', @@ -118,6 +120,11 @@ libds_wayland_srcs = [ 'DSWaylandServer/DSWaylandTizenIndicatorPrivate.h', 'DSWaylandServer/DSWaylandTizenIndicator.h', 'DSWaylandServer/DSWaylandTizenIndicator.cpp', + 'DSWaylandServer/DSWaylandInputMethodContextPrivate.h', + 'DSWaylandServer/DSWaylandInputMethodContext.h', + 'DSWaylandServer/DSWaylandInputMethodPrivate.h', + 'DSWaylandServer/DSWaylandInputMethod.h', + 'DSWaylandServer/DSWaylandInputMethod.cpp', ] libds_srcs += libds_wayland_srcs @@ -141,10 +148,11 @@ tizen_ext_dep = dependency('tizen-extension-server') xdg_shell_unstable_v6_dep = dependency('xdg-shell-unstable-v6-server') xdg_shell_dep = dependency('xdg-shell-server') tizen_surface_dep = dependency('tizen-surface-server') +input_method_dep = dependency('input-method-server') text_dep = dependency('text-server') tizen_launch_dep = dependency('tizen-launch-server') -tizen_ext_deps = [tizen_ext_dep, text_dep, tizen_launch_dep, tizen_surface_dep] +tizen_ext_deps = [tizen_ext_dep, input_method_dep, text_dep, tizen_launch_dep, tizen_surface_dep] tizen_ext_deps = [tizen_ext_deps, xdg_shell_unstable_v6_dep, xdg_shell_dep] libds_deps = [ecore_dep] -- 2.7.4