From a2b65a9bcc9eafd8299f485f4d92ce65c825f92f Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 16 Jun 2020 13:41:18 +0900 Subject: [PATCH 01/16] use the namespace display_server at samples and tests Change-Id: I1f2278d6a6fea0ce683db41829ec0e3b3ad16869 --- samples/exampleObjectPimpl.cpp | 128 +++++++++++++++++----------------- samples/exampleProperty.cpp | 153 ++++++++++++++++++++--------------------- samples/exampleSignalSlot.cpp | 147 +++++++++++++++++++-------------------- tests/DSProperty-test.cpp | 20 +++--- tests/DSRefBase-test.cpp | 4 +- 5 files changed, 223 insertions(+), 229 deletions(-) diff --git a/samples/exampleObjectPimpl.cpp b/samples/exampleObjectPimpl.cpp index d098b6b..c06242f 100644 --- a/samples/exampleObjectPimpl.cpp +++ b/samples/exampleObjectPimpl.cpp @@ -5,91 +5,91 @@ /* RESULT === ObjectPimpl *myobj = new ObjectPimpl() === -Constructor 'ObjectPimplPrivate' : example::ObjectPimplPrivate::ObjectPimplPrivate(example::ObjectPimpl*) -Constructor 'ObjectPimpl' : example::ObjectPimpl::ObjectPimpl() +Constructor 'ObjectPimplPrivate' : ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl*) +Constructor 'ObjectPimpl' : ObjectPimpl::ObjectPimpl() === ObjectPimpl *myobj2 = new ObjectPimpl() === -Constructor 'ObjectPimplPrivate' : example::ObjectPimplPrivate::ObjectPimplPrivate(example::ObjectPimpl*) -Constructor 'ObjectPimpl' : example::ObjectPimpl::ObjectPimpl() +Constructor 'ObjectPimplPrivate' : ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl*) +Constructor 'ObjectPimpl' : ObjectPimpl::ObjectPimpl() === delete myobj === -Destructor 'ObjectPimpl' : virtual example::ObjectPimpl::~ObjectPimpl() -Destructor 'ObjectPimplPrivate' : virtual example::ObjectPimplPrivate::~ObjectPimplPrivate() +Destructor 'ObjectPimpl' : virtual ObjectPimpl::~ObjectPimpl() +Destructor 'ObjectPimplPrivate' : virtual ObjectPimplPrivate::~ObjectPimplPrivate() === delete myobj2 === -Destructor 'ObjectPimpl' : virtual example::ObjectPimpl::~ObjectPimpl() -Destructor 'ObjectPimplPrivate' : virtual example::ObjectPimplPrivate::~ObjectPimplPrivate() +Destructor 'ObjectPimpl' : virtual ObjectPimpl::~ObjectPimpl() +Destructor 'ObjectPimplPrivate' : virtual ObjectPimplPrivate::~ObjectPimplPrivate() */ -namespace example { - class ObjectPimpl; - - class ObjectPimplPrivate : public display_server::DSObjectPrivate { - public: - ObjectPimplPrivate() = delete; - ObjectPimplPrivate(ObjectPimpl *p_ptr); - ~ObjectPimplPrivate(); - }; - - class ObjectPimpl : public display_server::DSObject { - public: - explicit ObjectPimpl(); - virtual ~ObjectPimpl(); - - private: - inline ObjectPimplPrivate *d_func() - { - return reinterpret_cast(__d_ptr.get()); - } - inline const ObjectPimplPrivate *d_func() const - { - return reinterpret_cast(__d_ptr.get()); - } - friend class ObjectPimplPrivate; - }; - - ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl *p_ptr) : - display_server::DSObjectPrivate(p_ptr) - { - std::cout << "Constructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; - } +using namespace display_server; - ObjectPimplPrivate::~ObjectPimplPrivate() - { - std::cout << "Destructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; - } +class ObjectPimpl; + +class ObjectPimplPrivate : public DSObjectPrivate { +public: + ObjectPimplPrivate() = delete; + ObjectPimplPrivate(ObjectPimpl *p_ptr); + ~ObjectPimplPrivate(); +}; + +class ObjectPimpl : public DSObject { +public: + explicit ObjectPimpl(); + virtual ~ObjectPimpl(); - ObjectPimpl::ObjectPimpl() : - display_server::DSObject(std::make_unique(this)) +private: + inline ObjectPimplPrivate *d_func() { - std::cout << "Constructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; + return reinterpret_cast(__d_ptr.get()); } - - ObjectPimpl::~ObjectPimpl() + inline const ObjectPimplPrivate *d_func() const { - std::cout << "Destructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; + return reinterpret_cast(__d_ptr.get()); } + friend class ObjectPimplPrivate; +}; - int exampleObjectPimpl(void) - { - std::cout << "\n=== ObjectPimpl *myobj = new ObjectPimpl() ===" << std::endl; - ObjectPimpl *myobj = new ObjectPimpl(); +ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl *p_ptr) : + DSObjectPrivate(p_ptr) +{ + std::cout << "Constructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; +} - std::cout << "\n=== ObjectPimpl *myobj2 = new ObjectPimpl() ===" << std::endl; - ObjectPimpl *myobj2 = new ObjectPimpl(); +ObjectPimplPrivate::~ObjectPimplPrivate() +{ + std::cout << "Destructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; +} - std::cout << "\n=== delete myobj ===" << std::endl; - delete myobj; +ObjectPimpl::ObjectPimpl() : + DSObject(std::make_unique(this)) +{ + std::cout << "Constructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; +} - std::cout << "\n=== delete myobj2 ===" << std::endl; - delete myobj2; +ObjectPimpl::~ObjectPimpl() +{ + std::cout << "Destructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; +} - return 0; - } -} // namespace example +int exampleObjectPimpl(void) +{ + std::cout << "\n=== ObjectPimpl *myobj = new ObjectPimpl() ===" << std::endl; + ObjectPimpl *myobj = new ObjectPimpl(); + + std::cout << "\n=== ObjectPimpl *myobj2 = new ObjectPimpl() ===" << std::endl; + ObjectPimpl *myobj2 = new ObjectPimpl(); + + std::cout << "\n=== delete myobj ===" << std::endl; + delete myobj; + + std::cout << "\n=== delete myobj2 ===" << std::endl; + delete myobj2; + + return 0; +} int main() { - return example::exampleObjectPimpl(); + return exampleObjectPimpl(); } diff --git a/samples/exampleProperty.cpp b/samples/exampleProperty.cpp index e3520d0..a67d542 100644 --- a/samples/exampleProperty.cpp +++ b/samples/exampleProperty.cpp @@ -4,10 +4,10 @@ /* RESULT === Property *myproperty = new Property() === -Constructor 'Property' : example::Property::Property() +Constructor 'Property' : Property::Property() === Property *myproperty2 = new Property() === -Constructor 'Property' : example::Property::Property() +Constructor 'Property' : Property::Property() === Add Property [myProperty:1234(int)] to myproperty Try get Property (key:"myProperty", type:int) of myproperty @@ -24,92 +24,87 @@ Try get Property (key:"yourProperty", type:DSPropertyVariant&) of myproperty SUCCESS: NOT_EXIST === delete myproperty === -Destructor 'Property' : virtual example::Property::~Property() +Destructor 'Property' : virtual Property::~Property() === delete myproperty2 === -Destructor 'Property' : virtual example::Property::~Property() +Destructor 'Property' : virtual Property::~Property() */ -namespace example { - class Property : public display_server::DSObject { - public: - explicit Property(); - virtual ~Property(); - }; +using namespace display_server; - Property::Property() - { - std::cout << "Constructor 'Property' : " << __PRETTY_FUNCTION__ << std::endl; +class Property : public DSObject { +public: + explicit Property(); + virtual ~Property(); +}; + +Property::Property() +{ + std::cout << "Constructor 'Property' : " << __PRETTY_FUNCTION__ << std::endl; +} + +Property::~Property() +{ + std::cout << "Destructor 'Property' : " << __PRETTY_FUNCTION__ << std::endl; +} + +int main() +{ + std::cout << "\n=== Property *myproperty = new Property() ===" << std::endl; + Property *myproperty = new Property(); + + std::cout << "\n=== Property *myproperty2 = new Property() ===" << std::endl; + Property *myproperty2 = new Property(); + + std::cout << "\n=== Add Property [myProperty:1234(int)] to myproperty ===" << std::endl; + myproperty->setProperty("myProperty", 1234, DSPropertyType::INTEGER); + try { + std::cout << "Try get Property (key:\"myProperty\", type:int) of myproperty" << std::endl; + std::cout << "myProperty: " << std::get(myproperty->getProperty("myProperty")) << std::endl; + } + catch (std::exception &e) { + std::cout << "ERR: " << e.what() << std::endl; + } + try { + std::cout << "Try get Property (key:\"myProperty\", type:float) of myproperty" << std::endl; + std::cout << std::get(myproperty->getProperty("myProperty")) << std::endl; + } + catch (std::exception &e) { + std::cout << "ERR: " << e.what() << std::endl; } - Property::~Property() - { - std::cout << "Destructor 'Property' : " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "\n=== Add Property [myProperty:" << myproperty2 << "(ptr)] to myproperty ===" << std::endl; + myproperty->setProperty("myProperty", static_cast(myproperty2), DSPropertyType::POINTER); + try { + std::cout << "Try get Property (key:\"myProperty\", type:int) of myproperty" << std::endl; + std::cout << std::get(myproperty->getProperty("myProperty")) << std::endl; + } + catch (std::exception &e) { + std::cout << "ERR: " << e.what() << std::endl; + } + try { + std::cout << "Try get Property (key:\"myProperty\", type:void *) of myproperty" << std::endl; + Property *mypropertyptr = static_cast(std::get(myproperty->getProperty("myProperty"))); + std::cout << "myProperty: " << mypropertyptr << std::endl; + } + catch (std::exception &e) { + std::cout << "ERR: " << e.what() << std::endl; } - int exampleProperty(void) - { - std::cout << "\n=== Property *myproperty = new Property() ===" << std::endl; - Property *myproperty = new Property(); - - std::cout << "\n=== Property *myproperty2 = new Property() ===" << std::endl; - Property *myproperty2 = new Property(); - - std::cout << "\n=== Add Property [myProperty:1234(int)] to myproperty ===" << std::endl; - myproperty->setProperty("myProperty", 1234, display_server::DSPropertyType::INTEGER); - try { - std::cout << "Try get Property (key:\"myProperty\", type:int) of myproperty" << std::endl; - std::cout << "myProperty: " << std::get(myproperty->getProperty("myProperty")) << std::endl; - } - catch (std::exception &e) { - std::cout << "ERR: " << e.what() << std::endl; - } - try { - std::cout << "Try get Property (key:\"myProperty\", type:float) of myproperty" << std::endl; - std::cout << std::get(myproperty->getProperty("myProperty")) << std::endl; - } - catch (std::exception &e) { - std::cout << "ERR: " << e.what() << std::endl; - } - - std::cout << "\n=== Add Property [myProperty:" << myproperty2 << "(ptr)] to myproperty ===" << std::endl; - myproperty->setProperty("myProperty", static_cast(myproperty2), display_server::DSPropertyType::POINTER); - try { - std::cout << "Try get Property (key:\"myProperty\", type:int) of myproperty" << std::endl; - std::cout << std::get(myproperty->getProperty("myProperty")) << std::endl; - } - catch (std::exception &e) { - std::cout << "ERR: " << e.what() << std::endl; - } - try { - std::cout << "Try get Property (key:\"myProperty\", type:void *) of myproperty" << std::endl; - Property *mypropertyptr = static_cast(std::get(myproperty->getProperty("myProperty"))); - std::cout << "myProperty: " << mypropertyptr << std::endl; - } - catch (std::exception &e) { - std::cout << "ERR: " << e.what() << std::endl; - } - - try { - std::cout << "Try get Property (key:\"yourProperty\", type:DSPropertyVariant&) of myproperty" << std::endl; - const display_server::DSPropertyVariant &ptr = myproperty->getProperty("yourProperty"); - std::cout << " THIS LINE SHOULD BE NOT PRINTED! yourProperty: " << &ptr << std::endl; - } - catch (std::exception &e) { - std::cout << "SUCCESS: " << e.what() << std::endl; - } - - std::cout << "\n=== delete myproperty ===" << std::endl; - delete myproperty; - - std::cout << "\n=== delete myproperty2 ===" << std::endl; - delete myproperty2; - - return 0; + try { + std::cout << "Try get Property (key:\"yourProperty\", type:DSPropertyVariant&) of myproperty" << std::endl; + const DSPropertyVariant &ptr = myproperty->getProperty("yourProperty"); + std::cout << " THIS LINE SHOULD BE NOT PRINTED! yourProperty: " << &ptr << std::endl; + } + catch (std::exception &e) { + std::cout << "SUCCESS: " << e.what() << std::endl; } -} // namespace example -int main() -{ - return example::exampleProperty(); + std::cout << "\n=== delete myproperty ===" << std::endl; + delete myproperty; + + std::cout << "\n=== delete myproperty2 ===" << std::endl; + delete myproperty2; + + return 0; } diff --git a/samples/exampleSignalSlot.cpp b/samples/exampleSignalSlot.cpp index 42e35f3..7b91bd5 100644 --- a/samples/exampleSignalSlot.cpp +++ b/samples/exampleSignalSlot.cpp @@ -19,98 +19,93 @@ destruct Sender destruct Sender destruct Receiver(ref: 1) */ -namespace example { - using SignalAType = display_server::DSSignal; - using SignalBType = display_server::DSSignal; +using namespace display_server; - class Sender : public display_server::DSObject { - public: - Sender() : - display_server::DSObject() - { - std::cout << "construct Sender" << std::endl; - } - ~Sender() - { - std::cout << "destruct Sender " << getName() << std::endl; - } +using SignalAType = DSSignal; +using SignalBType = DSSignal; - struct SignalA : public SignalAType { - void emit(int val) - { - SignalAType::emit(val); - } - } signalA; - - struct SignalB : public SignalBType { - void emit(double val) - { - SignalBType::emit(val); - } - } signalB; - }; +class Sender : public DSObject { +public: + Sender() : + DSObject() + { + std::cout << "construct Sender" << std::endl; + } + ~Sender() + { + std::cout << "destruct Sender " << getName() << std::endl; + } - class Receiver : public display_server::DSObject, public display_server::DSRefBase { - public: - Receiver() : - display_server::DSObject(), display_server::DSRefBase() - { - std::cout << "construct Receiver" << std::endl; - } - ~Receiver() + struct SignalA : public SignalAType { + void emit(int val) { - std::cout << "destruct Receiver(ref: " << getref() << ") " << getName() << std::endl; + SignalAType::emit(val); } + } signalA; - static void slotA(int a) + struct SignalB : public SignalBType { + void emit(double val) { - std::cout << "slotA invoked! a:" << a << std::endl; - }; - static void slotA2(int a) - { - std::cout << "slotA2 invoked! a:" << a << std::endl; + SignalBType::emit(val); } - static void slotB(double a) - { - std::cout << "slotB invoked! a:" << a << std::endl; - }; - }; + } signalB; +}; - int main(void) +class Receiver : public DSObject, public DSRefBase { +public: + Receiver() : + DSObject(), DSRefBase() { - Sender *sender = new Sender(); - Sender *sender2 = new Sender(); - Receiver *receiver = new Receiver(); - Receiver *receiver2 = new Receiver(); - - sender->signalA.connect(receiver, Receiver::slotA); - sender->signalA.connect(receiver2, Receiver::slotA2); - sender->signalB.connect(receiver, Receiver::slotB); - sender->signalB.connect(receiver2, [](double val) { - std::cout << "Lambda slot invoked! val: " << val << std::endl; - }); + std::cout << "construct Receiver" << std::endl; + } + ~Receiver() + { + std::cout << "destruct Receiver(ref: " << getref() << ") " << getName() << std::endl; + } - sender->signalA.emit(1234); - sender->signalB.emit(45.67); + static void slotA(int a) + { + std::cout << "slotA invoked! a:" << a << std::endl; + }; + static void slotA2(int a) + { + std::cout << "slotA2 invoked! a:" << a << std::endl; + } + static void slotB(double a) + { + std::cout << "slotB invoked! a:" << a << std::endl; + }; +}; - if (receiver2->getref() == 1) { - receiver2->unref(); - receiver2 = nullptr; - } +int main(void) +{ + Sender *sender = new Sender(); + Sender *sender2 = new Sender(); + Receiver *receiver = new Receiver(); + Receiver *receiver2 = new Receiver(); - sender->signalB.emit(5678); - sender->signalA.emit(90.1); + sender->signalA.connect(receiver, Receiver::slotA); + sender->signalA.connect(receiver2, Receiver::slotA2); + sender->signalB.connect(receiver, Receiver::slotB); + sender->signalB.connect(receiver2, [](double val) { + std::cout << "Lambda slot invoked! val: " << val << std::endl; + }); - delete sender; - delete sender2; - delete receiver; + sender->signalA.emit(1234); + sender->signalB.emit(45.67); - return 0; + if (receiver2->getref() == 1) { + receiver2->unref(); + receiver2 = nullptr; } -} // namespace example -int main() -{ - return example::main(); + sender->signalB.emit(5678); + sender->signalA.emit(90.1); + + delete sender; + delete sender2; + delete receiver; + + return 0; } diff --git a/tests/DSProperty-test.cpp b/tests/DSProperty-test.cpp index 9c27f31..700c8a6 100644 --- a/tests/DSProperty-test.cpp +++ b/tests/DSProperty-test.cpp @@ -1,6 +1,8 @@ #include "libds-tests.h" #include "DSProperty.h" +using namespace display_server; + class DSPropertyTest : public ::testing::Test { public: @@ -16,16 +18,16 @@ public: TEST_F(DSPropertyTest, CreateProperty) { - /* display_server::DSProperty::DSProperty()*/ - display_server::DSProperty* pro = new display_server::DSProperty(); + /* DSProperty::DSProperty()*/ + DSProperty* pro = new DSProperty(); ASSERT_NE(pro, nullptr) << "Failed to DSProperty()"; delete pro; - /* display_server::DSProperty::DSProperty(std::__cxx11::string, const DSPropertyVariant&, display_server::DSPropertyType) */ - pro = new display_server::DSProperty("testProperty", 2020, display_server::DSPropertyType::INTEGER); + /* DSProperty::DSProperty(std::__cxx11::string, const DSPropertyVariant&, DSPropertyType) */ + pro = new DSProperty("testProperty", 2020, DSPropertyType::INTEGER); ASSERT_NE(pro, nullptr) << "Failed to DSProperty(key, data, type)"; ASSERT_EQ(pro->getKey(), "testProperty") << "Key value mismatch!"; - ASSERT_EQ(pro->getType(), display_server::DSPropertyType::INTEGER) << "Type mistmatch!!"; + ASSERT_EQ(pro->getType(), DSPropertyType::INTEGER) << "Type mistmatch!!"; try { int data = std::get(pro->getData()); ASSERT_TRUE(data == 2020) << "data value mismatch!!"; @@ -34,12 +36,12 @@ TEST_F(DSPropertyTest, CreateProperty) } delete pro; - /* display_server::DSProperty::DSProperty(display_server::DSProperty&) */ - display_server::DSProperty pro_s("testProperty2", 20.20, display_server::DSPropertyType::DOUBLE); - pro = new display_server::DSProperty(pro_s); + /* DSProperty::DSProperty(DSProperty&) */ + DSProperty pro_s("testProperty2", 20.20, DSPropertyType::DOUBLE); + pro = new DSProperty(pro_s); ASSERT_NE(pro, nullptr) << "Failed to DSProperty(const DSProperty&)"; ASSERT_EQ(pro->getKey(), "testProperty2") << "Key value mismatch!"; - ASSERT_EQ(pro->getType(), display_server::DSPropertyType::DOUBLE) << "Type mistmatch!!"; + ASSERT_EQ(pro->getType(), DSPropertyType::DOUBLE) << "Type mistmatch!!"; try { double data = std::get(pro->getData()); ASSERT_TRUE(data == 20.20) << "data value mismatch!!"; diff --git a/tests/DSRefBase-test.cpp b/tests/DSRefBase-test.cpp index 56853f8..086ea6b 100644 --- a/tests/DSRefBase-test.cpp +++ b/tests/DSRefBase-test.cpp @@ -1,6 +1,8 @@ #include "libds-tests.h" #include "DSRefBase.h" +using namespace display_server; + class DSRefBaseTest : public ::testing::Test { public: @@ -16,7 +18,7 @@ public: TEST_F(DSRefBaseTest, CreateRefBase) { - display_server::DSRefBase *refBase = new display_server::DSRefBase(); + DSRefBase *refBase = new DSRefBase(); int count1; int count2; -- 2.7.4 From eb732ae33ed50a36c6b5bbf8a2f35d716c37d7c7 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 16 Jun 2020 14:33:52 +0900 Subject: [PATCH 02/16] change the test package and test binary name from xxx-unitests to xxx-tests Change-Id: I63a7b24fee07e968930ad7a3c6ee39d657505e52 --- packaging/libds.spec | 8 ++++---- tests/meson.build | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packaging/libds.spec b/packaging/libds.spec index 7f26b50..299b6a8 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -27,11 +27,11 @@ Requires: %{name} = %{version}-%{release} Test DS c++ server and lib -%package unittests +%package tests Summary: libds unit tests Group: System/Libraries -%description unittests +%description tests Test module for testing libtbm APIs %prep @@ -67,6 +67,6 @@ ninja -C builddir install %{_libdir}/*.so %{_libdir}/pkgconfig/* -%files unittests +%files tests %defattr(-,root,root,-) -%{_bindir}/libds-unittests +%{_bindir}/libds-tests diff --git a/tests/meson.build b/tests/meson.build index 7ae68c0..03e11ea 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,4 +1,4 @@ -libds_unittests_srcs = [ +libds_tests_srcs = [ 'libds-tests.cpp', 'DSRefBase-test.cpp', 'DSProperty-test.cpp', @@ -19,8 +19,8 @@ libds_unittests_srcs = [ gmock_dep = dependency('gmock', method : 'pkg-config') executable( - 'libds-unittests', - libds_unittests_srcs, + 'libds-tests', + libds_tests_srcs, dependencies : [libds_declared_dep, gmock_dep], install_dir : libds_prefix_bindir, install : true -- 2.7.4 From cb7db9104aa4b42bf65000ed1a08b529b31bf337 Mon Sep 17 00:00:00 2001 From: review-bot Date: Tue, 16 Jun 2020 15:35:29 +0900 Subject: [PATCH 03/16] Apply Coding Style Change-Id: I2973ae7fc08cd40d367512e97828080a6899020c --- samples/exampleObjectPimpl.cpp | 32 ++++++++++++-------- samples/exampleProperty.cpp | 69 ++++++++++++++++++++++++++---------------- samples/exampleSignalSlot.cpp | 21 +++++++------ tests/DSProperty-test.cpp | 6 ++-- 4 files changed, 78 insertions(+), 50 deletions(-) diff --git a/samples/exampleObjectPimpl.cpp b/samples/exampleObjectPimpl.cpp index c06242f..b8dc4aa 100644 --- a/samples/exampleObjectPimpl.cpp +++ b/samples/exampleObjectPimpl.cpp @@ -26,14 +26,16 @@ using namespace display_server; class ObjectPimpl; -class ObjectPimplPrivate : public DSObjectPrivate { +class ObjectPimplPrivate : public DSObjectPrivate +{ public: ObjectPimplPrivate() = delete; ObjectPimplPrivate(ObjectPimpl *p_ptr); ~ObjectPimplPrivate(); }; -class ObjectPimpl : public DSObject { +class ObjectPimpl : public DSObject +{ public: explicit ObjectPimpl(); virtual ~ObjectPimpl(); @@ -50,34 +52,40 @@ private: friend class ObjectPimplPrivate; }; -ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl *p_ptr) : - DSObjectPrivate(p_ptr) +ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl *p_ptr) + : DSObjectPrivate(p_ptr) { - std::cout << "Constructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "Constructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ + << std::endl; } ObjectPimplPrivate::~ObjectPimplPrivate() { - std::cout << "Destructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "Destructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ + << std::endl; } -ObjectPimpl::ObjectPimpl() : - DSObject(std::make_unique(this)) +ObjectPimpl::ObjectPimpl() + : DSObject(std::make_unique(this)) { - std::cout << "Constructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "Constructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ + << std::endl; } ObjectPimpl::~ObjectPimpl() { - std::cout << "Destructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "Destructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ + << std::endl; } int exampleObjectPimpl(void) { - std::cout << "\n=== ObjectPimpl *myobj = new ObjectPimpl() ===" << std::endl; + std::cout << "\n=== ObjectPimpl *myobj = new ObjectPimpl() ===" + << std::endl; ObjectPimpl *myobj = new ObjectPimpl(); - std::cout << "\n=== ObjectPimpl *myobj2 = new ObjectPimpl() ===" << std::endl; + std::cout << "\n=== ObjectPimpl *myobj2 = new ObjectPimpl() ===" + << std::endl; ObjectPimpl *myobj2 = new ObjectPimpl(); std::cout << "\n=== delete myobj ===" << std::endl; diff --git a/samples/exampleProperty.cpp b/samples/exampleProperty.cpp index a67d542..fa21113 100644 --- a/samples/exampleProperty.cpp +++ b/samples/exampleProperty.cpp @@ -32,7 +32,8 @@ Destructor 'Property' : virtual Property::~Property() using namespace display_server; -class Property : public DSObject { +class Property : public DSObject +{ public: explicit Property(); virtual ~Property(); @@ -40,7 +41,8 @@ public: Property::Property() { - std::cout << "Constructor 'Property' : " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "Constructor 'Property' : " << __PRETTY_FUNCTION__ + << std::endl; } Property::~Property() @@ -53,50 +55,65 @@ int main() std::cout << "\n=== Property *myproperty = new Property() ===" << std::endl; Property *myproperty = new Property(); - std::cout << "\n=== Property *myproperty2 = new Property() ===" << std::endl; + std::cout << "\n=== Property *myproperty2 = new Property() ===" + << std::endl; Property *myproperty2 = new Property(); - std::cout << "\n=== Add Property [myProperty:1234(int)] to myproperty ===" << std::endl; + std::cout << "\n=== Add Property [myProperty:1234(int)] to myproperty ===" + << std::endl; myproperty->setProperty("myProperty", 1234, DSPropertyType::INTEGER); try { - std::cout << "Try get Property (key:\"myProperty\", type:int) of myproperty" << std::endl; - std::cout << "myProperty: " << std::get(myproperty->getProperty("myProperty")) << std::endl; - } - catch (std::exception &e) { + std::cout + << "Try get Property (key:\"myProperty\", type:int) of myproperty" + << std::endl; + std::cout << "myProperty: " + << std::get(myproperty->getProperty("myProperty")) + << std::endl; + } catch (std::exception &e) { std::cout << "ERR: " << e.what() << std::endl; } try { - std::cout << "Try get Property (key:\"myProperty\", type:float) of myproperty" << std::endl; - std::cout << std::get(myproperty->getProperty("myProperty")) << std::endl; - } - catch (std::exception &e) { + std::cout + << "Try get Property (key:\"myProperty\", type:float) of myproperty" + << std::endl; + std::cout << std::get(myproperty->getProperty("myProperty")) + << std::endl; + } catch (std::exception &e) { std::cout << "ERR: " << e.what() << std::endl; } - std::cout << "\n=== Add Property [myProperty:" << myproperty2 << "(ptr)] to myproperty ===" << std::endl; - myproperty->setProperty("myProperty", static_cast(myproperty2), DSPropertyType::POINTER); + std::cout << "\n=== Add Property [myProperty:" << myproperty2 + << "(ptr)] to myproperty ===" << std::endl; + myproperty->setProperty("myProperty", static_cast(myproperty2), + DSPropertyType::POINTER); try { - std::cout << "Try get Property (key:\"myProperty\", type:int) of myproperty" << std::endl; - std::cout << std::get(myproperty->getProperty("myProperty")) << std::endl; - } - catch (std::exception &e) { + std::cout + << "Try get Property (key:\"myProperty\", type:int) of myproperty" + << std::endl; + std::cout << std::get(myproperty->getProperty("myProperty")) + << std::endl; + } catch (std::exception &e) { std::cout << "ERR: " << e.what() << std::endl; } try { - std::cout << "Try get Property (key:\"myProperty\", type:void *) of myproperty" << std::endl; - Property *mypropertyptr = static_cast(std::get(myproperty->getProperty("myProperty"))); + std::cout + << "Try get Property (key:\"myProperty\", type:void *) of myproperty" + << std::endl; + Property *mypropertyptr = static_cast( + std::get(myproperty->getProperty("myProperty"))); std::cout << "myProperty: " << mypropertyptr << std::endl; - } - catch (std::exception &e) { + } catch (std::exception &e) { std::cout << "ERR: " << e.what() << std::endl; } try { - std::cout << "Try get Property (key:\"yourProperty\", type:DSPropertyVariant&) of myproperty" << std::endl; + std::cout + << "Try get Property (key:\"yourProperty\", type:DSPropertyVariant&) of myproperty" + << std::endl; const DSPropertyVariant &ptr = myproperty->getProperty("yourProperty"); - std::cout << " THIS LINE SHOULD BE NOT PRINTED! yourProperty: " << &ptr << std::endl; - } - catch (std::exception &e) { + std::cout << " THIS LINE SHOULD BE NOT PRINTED! yourProperty: " << &ptr + << std::endl; + } catch (std::exception &e) { std::cout << "SUCCESS: " << e.what() << std::endl; } diff --git a/samples/exampleSignalSlot.cpp b/samples/exampleSignalSlot.cpp index 7b91bd5..9cbb9b2 100644 --- a/samples/exampleSignalSlot.cpp +++ b/samples/exampleSignalSlot.cpp @@ -25,10 +25,10 @@ using namespace display_server; using SignalAType = DSSignal; using SignalBType = DSSignal; -class Sender : public DSObject { +class Sender : public DSObject +{ public: - Sender() : - DSObject() + Sender() : DSObject() { std::cout << "construct Sender" << std::endl; } @@ -37,14 +37,16 @@ public: std::cout << "destruct Sender " << getName() << std::endl; } - struct SignalA : public SignalAType { + struct SignalA : public SignalAType + { void emit(int val) { SignalAType::emit(val); } } signalA; - struct SignalB : public SignalBType { + struct SignalB : public SignalBType + { void emit(double val) { SignalBType::emit(val); @@ -52,16 +54,17 @@ public: } signalB; }; -class Receiver : public DSObject, public DSRefBase { +class Receiver : public DSObject, public DSRefBase +{ public: - Receiver() : - DSObject(), DSRefBase() + Receiver() : DSObject(), DSRefBase() { std::cout << "construct Receiver" << std::endl; } ~Receiver() { - std::cout << "destruct Receiver(ref: " << getref() << ") " << getName() << std::endl; + std::cout << "destruct Receiver(ref: " << getref() << ") " << getName() + << std::endl; } static void slotA(int a) diff --git a/tests/DSProperty-test.cpp b/tests/DSProperty-test.cpp index 700c8a6..794ef07 100644 --- a/tests/DSProperty-test.cpp +++ b/tests/DSProperty-test.cpp @@ -19,7 +19,7 @@ public: TEST_F(DSPropertyTest, CreateProperty) { /* DSProperty::DSProperty()*/ - DSProperty* pro = new DSProperty(); + DSProperty *pro = new DSProperty(); ASSERT_NE(pro, nullptr) << "Failed to DSProperty()"; delete pro; @@ -31,7 +31,7 @@ TEST_F(DSPropertyTest, CreateProperty) try { int data = std::get(pro->getData()); ASSERT_TRUE(data == 2020) << "data value mismatch!!"; - } catch (std::bad_variant_access& e) { + } catch (std::bad_variant_access &e) { ASSERT_TRUE(false) << e.what(); } delete pro; @@ -45,7 +45,7 @@ TEST_F(DSPropertyTest, CreateProperty) try { double data = std::get(pro->getData()); ASSERT_TRUE(data == 20.20) << "data value mismatch!!"; - } catch (std::bad_variant_access& e) { + } catch (std::bad_variant_access &e) { ASSERT_TRUE(false) << e.what(); } delete pro; -- 2.7.4 From a1eed7b113e03b9551c4e38957aa0746599bb176 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 16 Jun 2020 16:33:21 +0900 Subject: [PATCH 04/16] beutify the code. make the code align and obey the coding style. Change-Id: Ic73fdf61ae3a59b152f83cb64b7b7fc95758b185 --- samples/exampleCompositor.cpp | 74 +++++++++++--------- samples/exampleObjectPimpl.cpp | 26 +++---- samples/exampleProperty.cpp | 7 +- src/DSBase/DSRefBase.h | 43 ++++++++---- src/DSCallback/DSCallback.h | 33 ++++++--- src/DSObject/DSObject.cpp | 82 +++++++++++----------- src/DSObject/DSObject.h | 92 +++++++++++------------- src/DSObject/DSObjectPrivate.cpp | 15 ++-- src/DSObject/DSObjectPrivate.h | 95 +++++++++++++------------ src/DSObject/IDSObjectObserver.h | 18 +++++ src/DSProperty/DSProperty.cpp | 109 ++++++++++++++--------------- src/DSProperty/DSProperty.h | 78 +++++++++++---------- src/DSProperty/DSPropertyPrivate.cpp | 117 ++++++++++++++++--------------- src/DSProperty/DSPropertyPrivate.h | 131 +++++++++++++++++++---------------- src/DSSignal/DSSignal.cpp | 6 +- src/DSSignal/DSSignal.h | 98 +++++++++++++++----------- 16 files changed, 556 insertions(+), 468 deletions(-) create mode 100644 src/DSObject/IDSObjectObserver.h diff --git a/samples/exampleCompositor.cpp b/samples/exampleCompositor.cpp index 6d938f9..cae7261 100644 --- a/samples/exampleCompositor.cpp +++ b/samples/exampleCompositor.cpp @@ -40,62 +40,70 @@ using namespace display_server; // compositor->connectSignal(DSInput::ADD_SIGNAL, DSCompositor::InputAdd); // compositor->connectSignal(DSInput::REMOVE_SIGNAL, DSCompositor::InputRemove); -class MyCompositor : public DSCompositor { +class MyCompositor : public DSCompositor +{ public: - MyCompositor() { + MyCompositor() + { int width, height; - width = displayArea->getWidth(); - height = displayArea->getHeight(); + width = __displayArea->getWidth(); + height = __displayArea->getHeight(); - canvas = new DSCanvas(); + __canvas = new DSCanvas(); - policyArea = new DSPolicyArea(); - //policyArea->selectWmPolicy(PolicyAreaWmPolicy::MOBILE); - //policyArea->selectEffectPolicy(PolicyAreaEffectPolicy::MOBILE); - policyArea->setPosition(0, 0); - policyArea->setSize(width, height); - policyArea->attachSeat(seat); + __policyArea = new DSPolicyArea(); + //__policyArea->selectWmPolicy(PolicyAreaWmPolicy::MOBILE); + //__policyArea->selectEffectPolicy(PolicyAreaEffectPolicy::MOBILE); + __policyArea->setPosition(0, 0); + __policyArea->setSize(width, height); + __policyArea->attachSeat(__seat); - canvas->attachPolicyArea(policyArea); - canvas->attachDisplayArea(displayArea); + __canvas->attachPolicyArea(__policyArea); + __canvas->attachDisplayArea(__displayArea); } - virtual ~MyCompositor() { - delete policyArea; - delete canvas; + virtual ~MyCompositor() + { + delete __policyArea; + delete __canvas; } - void OutputAdd(DSOutput *output) { + void OutputAdd(DSOutput *output) + { // set the resolution. output->applyResolutionAuto(); } - void OutputResolutionSet(DSOutput *output, int width, int height) { - displayArea = new DSDisplayArea(output); - displayArea->setPosition(0, 0); - displayArea->setSize(width, height); + void OutputResolutionSet(DSOutput *output, int width, int height) + { + __displayArea = new DSDisplayArea(output); + __displayArea->setPosition(0, 0); + __displayArea->setSize(width, height); } - void OutputRemove(DSOutput *output) { - delete displayArea; + void OutputRemove(DSOutput *output) + { + delete __displayArea; } - void InputAdd(DSInput *input) { - seat = new DSSeat(); - seat->addInput(input); // add an input device to a seat + void InputAdd(DSInput *input) + { + __seat = new DSSeat(); + __seat->addInput(input); // add an input device to a seat } - void InputRemove(DSInput *input) { - seat->removeInput(input); // remove an input device from a seat - delete(seat); + void InputRemove(DSInput *input) + { + __seat->removeInput(input); // remove an input device from a seat + delete(__seat); } private: - DSCanvas *canvas; - DSSeat *seat; - DSPolicyArea *policyArea; - DSDisplayArea *displayArea; + DSCanvas *__canvas; + DSSeat *__seat; + DSPolicyArea *__policyArea; + DSDisplayArea *__displayArea; }; int main() { diff --git a/samples/exampleObjectPimpl.cpp b/samples/exampleObjectPimpl.cpp index b8dc4aa..369c35e 100644 --- a/samples/exampleObjectPimpl.cpp +++ b/samples/exampleObjectPimpl.cpp @@ -41,13 +41,13 @@ public: virtual ~ObjectPimpl(); private: - inline ObjectPimplPrivate *d_func() + inline ObjectPimplPrivate *__d_func() { - return reinterpret_cast(__d_ptr.get()); + return reinterpret_cast(_d_ptr.get()); } - inline const ObjectPimplPrivate *d_func() const + inline const ObjectPimplPrivate *__d_func() const { - return reinterpret_cast(__d_ptr.get()); + return reinterpret_cast(_d_ptr.get()); } friend class ObjectPimplPrivate; }; @@ -55,37 +55,31 @@ private: ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl *p_ptr) : DSObjectPrivate(p_ptr) { - std::cout << "Constructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ - << std::endl; + std::cout << "Constructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; } ObjectPimplPrivate::~ObjectPimplPrivate() { - std::cout << "Destructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ - << std::endl; + std::cout << "Destructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; } ObjectPimpl::ObjectPimpl() : DSObject(std::make_unique(this)) { - std::cout << "Constructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ - << std::endl; + std::cout << "Constructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; } ObjectPimpl::~ObjectPimpl() { - std::cout << "Destructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ - << std::endl; + std::cout << "Destructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; } int exampleObjectPimpl(void) { - std::cout << "\n=== ObjectPimpl *myobj = new ObjectPimpl() ===" - << std::endl; + std::cout << "\n=== ObjectPimpl *myobj = new ObjectPimpl() ===" << std::endl; ObjectPimpl *myobj = new ObjectPimpl(); - std::cout << "\n=== ObjectPimpl *myobj2 = new ObjectPimpl() ===" - << std::endl; + std::cout << "\n=== ObjectPimpl *myobj2 = new ObjectPimpl() ===" << std::endl; ObjectPimpl *myobj2 = new ObjectPimpl(); std::cout << "\n=== delete myobj ===" << std::endl; diff --git a/samples/exampleProperty.cpp b/samples/exampleProperty.cpp index fa21113..70f62c8 100644 --- a/samples/exampleProperty.cpp +++ b/samples/exampleProperty.cpp @@ -41,8 +41,7 @@ public: Property::Property() { - std::cout << "Constructor 'Property' : " << __PRETTY_FUNCTION__ - << std::endl; + std::cout << "Constructor 'Property' : " << __PRETTY_FUNCTION__ << std::endl; } Property::~Property() @@ -62,6 +61,7 @@ int main() std::cout << "\n=== Add Property [myProperty:1234(int)] to myproperty ===" << std::endl; myproperty->setProperty("myProperty", 1234, DSPropertyType::INTEGER); + try { std::cout << "Try get Property (key:\"myProperty\", type:int) of myproperty" @@ -72,6 +72,7 @@ int main() } catch (std::exception &e) { std::cout << "ERR: " << e.what() << std::endl; } + try { std::cout << "Try get Property (key:\"myProperty\", type:float) of myproperty" @@ -86,6 +87,7 @@ int main() << "(ptr)] to myproperty ===" << std::endl; myproperty->setProperty("myProperty", static_cast(myproperty2), DSPropertyType::POINTER); + try { std::cout << "Try get Property (key:\"myProperty\", type:int) of myproperty" @@ -95,6 +97,7 @@ int main() } catch (std::exception &e) { std::cout << "ERR: " << e.what() << std::endl; } + try { std::cout << "Try get Property (key:\"myProperty\", type:void *) of myproperty" diff --git a/src/DSBase/DSRefBase.h b/src/DSBase/DSRefBase.h index bd37b1c..f8e6a48 100644 --- a/src/DSBase/DSRefBase.h +++ b/src/DSBase/DSRefBase.h @@ -1,21 +1,38 @@ -#ifndef __DSREFBASE_H -#define __DSREFBASE_H -namespace display_server { -class DSRefBase { +#ifndef __DS_REF_BASE_H_ +#define __DS_REF_BASE_H_ + +namespace display_server +{ + +class DSRefBase +{ public: - DSRefBase() : mCount(1) {} - virtual ~DSRefBase() {} + DSRefBase() + : __count(1) + {} + virtual ~DSRefBase() + {} + + void ref() + { + ++__count; + } - void ref() { ++mCount; } inline void unref() { - if (--mCount == 0) + if (--__count == 0) delete this; } - const int getref() const { return mCount; } + + const int getref() const + { + return __count; + } + private: - int mCount; + int __count; }; -} // namespace display_server -#else -#endif /* __DSREFBASE_H */ + +} + +#endif diff --git a/src/DSCallback/DSCallback.h b/src/DSCallback/DSCallback.h index 9fba026..9746f2e 100644 --- a/src/DSCallback/DSCallback.h +++ b/src/DSCallback/DSCallback.h @@ -1,32 +1,43 @@ -#ifndef __DSCALLBACK_H -#define __DSCALLBACK_H +#ifndef __DS_CALLBACK_H_ +#define __DS_CALLBACK_H_ + #include namespace display_server { template -class DSCallback { +class DSCallback +{ protected: - virtual ~DSCallback() {} - DSCallback(const DSCallback &cb) {} + DSCallback(const DSCallback &cb) + {} + virtual ~DSCallback() + {} + bool operator==(const DSCallback &cb); + private: std::function __function; }; template -class DSCallbackUnique : public DSCallback { +class DSCallbackUnique : public DSCallback +{ public: DSCallbackUnique((void)(*function)(Args...)); }; template -class DSCallbackMember : public DSCallback { +class DSCallbackMember : public DSCallback +{ + }; template -class DSCallbackSignal : public DSCallback { +class DSCallbackSignal : public DSCallback +{ }; -} // namespace display_server -#else -#endif /* __DSCALLBACK_H */ + +} + +#endif diff --git a/src/DSObject/DSObject.cpp b/src/DSObject/DSObject.cpp index 666ef6f..d90bc75 100644 --- a/src/DSObject/DSObject.cpp +++ b/src/DSObject/DSObject.cpp @@ -1,43 +1,45 @@ #include "DSObject.h" -namespace display_server { - DSObject::DSObject() - { - __d_ptr = std::make_unique(this); - } - - DSObject::~DSObject() - { - d_func()->notifyDestroy(); - } - - void DSObject::attachDestroyObserver(DSObjectObserverIface *ob) - { - d_func()->attachDestroyObserver(ob); - } - - void DSObject::detachDestroyObserver(DSObjectObserverIface *ob) - { - d_func()->detachDestroyObserver(ob); - } - - void DSObject::setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type) - { - d_func()->setProperty(key, data, type); - } - - const DSPropertyVariant &DSObject::getProperty(std::string key) - { - return d_func()->getProperty(key); - } - - std::string DSObject::getName(void) - { - return d_func()->getName(); - } - - DSObject::DSObject(std::unique_ptr ptr) - { - __d_ptr = std::move(ptr); - } +namespace display_server +{ + +DSObject::DSObject() + : _d_ptr(std::make_unique(this)) +{} + +DSObject::~DSObject() +{ + __d_func()->notifyDestroy(); +} + +void DSObject::attachDestroyObserver(IDSObjectObserver *ob) +{ + __d_func()->attachDestroyObserver(ob); +} + +void DSObject::detachDestroyObserver(IDSObjectObserver *ob) +{ + __d_func()->detachDestroyObserver(ob); +} + +void DSObject::setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type) +{ + __d_func()->setProperty(key, data, type); +} + +const DSPropertyVariant &DSObject::getProperty(std::string key) +{ + return __d_func()->getProperty(key); +} + +std::string DSObject::getName(void) +{ + return __d_func()->getName(); +} + +DSObject::DSObject(std::unique_ptr ptr) +{ + _d_ptr = std::move(ptr); +} + } // namespace display_server diff --git a/src/DSObject/DSObject.h b/src/DSObject/DSObject.h index ba84625..1ae29d3 100644 --- a/src/DSObject/DSObject.h +++ b/src/DSObject/DSObject.h @@ -1,52 +1,44 @@ -#ifndef __DSOBJECT_H -# define __DSOBJECT_H - -# include "DSObjectPrivate.h" -# include "DSProperty.h" -# include -# include -# include - -namespace display_server { - class DSObjectPrivate; - class DSObjectObserverIface; - class DSProperty; - - class DSObject { - public: - explicit DSObject(); - virtual ~DSObject(); - - void attachDestroyObserver(DSObjectObserverIface *ob); - void detachDestroyObserver(DSObjectObserverIface *ob); - - void setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type); - const DSPropertyVariant &getProperty(std::string key); - - std::string getName(void); - protected: - DSObject(std::unique_ptr ptr); - std::unique_ptr __d_ptr; - private: - inline DSObjectPrivate *d_func() - { - return __d_ptr.get(); - } - inline const DSObjectPrivate *d_func() const - { - return __d_ptr.get(); - } - }; - - class DSObjectObserverIface { - protected: - DSObjectObserverIface() {} - virtual ~DSObjectObserverIface() {} - - public: - virtual void destroyed(DSObject *obj) = 0; - }; +#ifndef __DS_OBJECT_H_ +#define __DS_OBJECT_H_ + +#include "IDSObjectObserver.h" +#include "DSObjectPrivate.h" +#include "DSProperty.h" +#include +#include +#include + +namespace display_server +{ + +class DSObject +{ +public: + explicit DSObject(); + virtual ~DSObject(); + + void attachDestroyObserver(IDSObjectObserver *ob); + void detachDestroyObserver(IDSObjectObserver *ob); + void setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type); + const DSPropertyVariant &getProperty(std::string key); + std::string getName(void); + +protected: + DSObject(std::unique_ptr ptr); + std::unique_ptr _d_ptr; + +private: + inline DSObjectPrivate *__d_func() + { + return _d_ptr.get(); + } + inline const DSObjectPrivate *__d_func() const + { + return _d_ptr.get(); + } +}; } // namespace display_server -#else -#endif /* __DSOBJECT_H */ + +#endif + diff --git a/src/DSObject/DSObjectPrivate.cpp b/src/DSObject/DSObjectPrivate.cpp index 589c12e..f33eac5 100644 --- a/src/DSObject/DSObjectPrivate.cpp +++ b/src/DSObject/DSObjectPrivate.cpp @@ -1,10 +1,10 @@ #include "DSObject.h" -namespace display_server { +namespace display_server +{ DSObjectPrivate::DSObjectPrivate(DSObject *p_ptr) : __p_ptr(p_ptr) - { - } + {} DSObjectPrivate::~DSObjectPrivate() { @@ -13,12 +13,12 @@ namespace display_server { __properties.clear(); } - void DSObjectPrivate::attachDestroyObserver(DSObjectObserverIface *ob) + void DSObjectPrivate::attachDestroyObserver(IDSObjectObserver *ob) { __observers.push_back(ob); } - void DSObjectPrivate::detachDestroyObserver(DSObjectObserverIface *ob) + void DSObjectPrivate::detachDestroyObserver(IDSObjectObserver *ob) { __observers.remove(ob); } @@ -26,6 +26,7 @@ namespace display_server { void DSObjectPrivate::setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type) { std::unordered_map::const_iterator ci = __properties.find(key); + if (ci == __properties.end()) { __properties.emplace(key, DSProperty(key, data, type)); } else { @@ -36,6 +37,7 @@ namespace display_server { const DSPropertyVariant &DSObjectPrivate::getProperty(std::string key) { std::unordered_map::const_iterator ci = __properties.find(key); + if (ci == __properties.end()) { throw DSPropertyException("NOT_EXIST"); } @@ -44,7 +46,7 @@ namespace display_server { void DSObjectPrivate::notifyDestroy(void) { - for (DSObjectObserverIface *ob : __observers) + for (IDSObjectObserver *ob : __observers) ob->destroyed(__p_ptr); __observers.clear(); } @@ -71,4 +73,5 @@ namespace display_server { return *this; } + } // namespace display_server diff --git a/src/DSObject/DSObjectPrivate.h b/src/DSObject/DSObjectPrivate.h index 4fdf068..eddbfca 100644 --- a/src/DSObject/DSObjectPrivate.h +++ b/src/DSObject/DSObjectPrivate.h @@ -1,50 +1,49 @@ -#ifndef __DSOBJECTPRIVATE_H -# define __DSOBJECTPRIVATE_H +#ifndef __DS_OBJECT_PRIVATE_H_ +#define __DS_OBJECT_PRIVATE_H_ + +#include "DSObject.h" +#include "DSProperty.h" +#include +#include +#include +#include + +namespace display_server +{ + +class DSObject; + +class DSObjectPrivate { +public: + DSObjectPrivate() = delete; + DSObjectPrivate(DSObject *p_ptr); + virtual ~DSObjectPrivate(); + + void attachDestroyObserver(IDSObjectObserver *ob); + void detachDestroyObserver(IDSObjectObserver *ob); + void notifyDestroy(); + void setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type); + const DSPropertyVariant &getProperty(std::string key); + std::string getName(void); + + DSObjectPrivate &operator=(DSObjectPrivate &&p); //move assignment + + inline const DSObject *p_func() const + { + return __p_ptr; + } +private: + struct + { + std::string name; + } __type_info; + + DSObject *__p_ptr; + + std::list __observers; + std::unordered_map __properties; +}; -# include "DSObject.h" -# include "DSProperty.h" -# include -# include -# include -# include - -namespace display_server { - class DSObject; - class DSObjectObserverIface; - - class DSObjectPrivate { - public: - DSObjectPrivate() = delete; - DSObjectPrivate(DSObject *p_ptr); - virtual ~DSObjectPrivate(); - - inline const DSObject *p_func() const - { - return __p_ptr; - } - - void attachDestroyObserver(DSObjectObserverIface *ob); - void detachDestroyObserver(DSObjectObserverIface *ob); - void notifyDestroy(); - - void setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type); - const DSPropertyVariant &getProperty(std::string key); - - std::string getName(void); - - DSObjectPrivate &operator=(DSObjectPrivate &&p); //move assignment - - private: - struct - { - std::string name; - } __type_info; - - DSObject *__p_ptr; - - std::list __observers; - std::unordered_map __properties; - }; } // namespace display_server -#else -#endif /* __DSOBJECTPRIVATE_H */ + +#endif diff --git a/src/DSObject/IDSObjectObserver.h b/src/DSObject/IDSObjectObserver.h new file mode 100644 index 0000000..494633a --- /dev/null +++ b/src/DSObject/IDSObjectObserver.h @@ -0,0 +1,18 @@ +#ifndef __I_DS_OBJECT_OBSERVER_H_ +#define __I_DS_OBJECT_OBSERVER_H_ + +namespace display_server +{ + +class DSObject; + +class IDSObjectObserver +{ +public: + virtual ~IDSObjectObserver() = default; + virtual void destroyed(DSObject *obj) = 0; +}; + +} + +#endif diff --git a/src/DSProperty/DSProperty.cpp b/src/DSProperty/DSProperty.cpp index 30309da..76ef81c 100644 --- a/src/DSProperty/DSProperty.cpp +++ b/src/DSProperty/DSProperty.cpp @@ -1,57 +1,58 @@ #include "DSProperty.h" -namespace display_server { - DSProperty::DSProperty() : - __d_ptr(new DSPropertyPrivate(this)) - { - } - - DSProperty::DSProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type) : - __d_ptr(new DSPropertyPrivate(this)) - { - d_func()->setKey(key); - d_func()->setData(data, type); - } - - DSProperty::DSProperty(const DSProperty &property) : - __d_ptr(new DSPropertyPrivate(this)) - { - d_func()->setKey(property.getKey()); - d_func()->setData(property.getData(), property.getType()); - } - - DSProperty::~DSProperty() - { - } - - DSProperty &DSProperty::operator=(DSProperty &property) // Copy Assign - { - d_func()->setKey(property.getKey()); - d_func()->setData(property.getData(), property.getType()); - - return *this; - } - - DSProperty &DSProperty::operator=(const DSProperty &property) // Copy Assign - { - d_func()->setKey(property.getKey()); - d_func()->setData(property.getData(), property.getType()); - - return *this; - } - - const DSPropertyVariant &DSProperty::getData(void) const - { - return d_func()->getData(); - } - - const std::string DSProperty::getKey(void) const - { - return d_func()->getKey(); - } - - const DSPropertyType DSProperty::getType(void) const - { - return d_func()->getType(); - } +namespace display_server +{ + +DSProperty::DSProperty() + : __d_ptr(new DSPropertyPrivate(this)) +{} + +DSProperty::DSProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type) + : __d_ptr(new DSPropertyPrivate(this)) +{ + __d_func()->__setKey(key); + __d_func()->__setData(data, type); +} + +DSProperty::DSProperty(const DSProperty &property) + : __d_ptr(new DSPropertyPrivate(this)) +{ + __d_func()->__setKey(property.getKey()); + __d_func()->__setData(property.getData(), property.getType()); +} + +DSProperty::~DSProperty() +{} + +DSProperty &DSProperty::operator=(DSProperty &property) // Copy Assign +{ + __d_func()->__setKey(property.getKey()); + __d_func()->__setData(property.getData(), property.getType()); + + return *this; +} + +DSProperty &DSProperty::operator=(const DSProperty &property) // Copy Assign +{ + __d_func()->__setKey(property.getKey()); + __d_func()->__setData(property.getData(), property.getType()); + + return *this; +} + +const DSPropertyVariant &DSProperty::getData(void) const +{ + return __d_func()->__getData(); +} + +const std::string DSProperty::getKey(void) const +{ + return __d_func()->__getKey(); +} + +const DSPropertyType DSProperty::getType(void) const +{ + return __d_func()->__getType(); +} + } // namespace display_server diff --git a/src/DSProperty/DSProperty.h b/src/DSProperty/DSProperty.h index 4d1662c..bba4454 100644 --- a/src/DSProperty/DSProperty.h +++ b/src/DSProperty/DSProperty.h @@ -1,44 +1,48 @@ -#ifndef __DSPROPERTY_H -#define __DSPROPERTY_H +#ifndef __DS_PROPERTY_H_ +#define __DS_PROPERTY_H_ +#include "DSPropertyPrivate.h" #include #include #include #include -#include "DSPropertyPrivate.h" -namespace display_server { - class DSPropertyPrivate; - - class DSProperty { - public: - DSProperty(); - DSProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type); - DSProperty(const DSProperty &property); - virtual ~DSProperty(); - - const DSPropertyVariant &getData(void) const; - const std::string getKey(void) const; - const DSPropertyType getType(void) const; - - DSProperty &operator=(DSProperty &property); - DSProperty &operator=(const DSProperty &property); - - private: - inline DSPropertyPrivate *d_func() - { - return __d_ptr.get(); - } - inline const DSPropertyPrivate *d_func() const - { - return __d_ptr.get(); - } - - std::unique_ptr __d_ptr; - - friend class DSPropertyPrivate; - friend class DSObject; - }; +namespace display_server +{ + +class DSPropertyPrivate; + +class DSProperty +{ +public: + DSProperty(); + DSProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type); + DSProperty(const DSProperty &property); + virtual ~DSProperty(); + + const DSPropertyVariant &getData(void) const; + const std::string getKey(void) const; + const DSPropertyType getType(void) const; + + DSProperty &operator=(DSProperty &property); + DSProperty &operator=(const DSProperty &property); + +private: + std::unique_ptr __d_ptr; + + inline DSPropertyPrivate *__d_func() + { + return __d_ptr.get(); + } + inline const DSPropertyPrivate *__d_func() const + { + return __d_ptr.get(); + } + + friend class DSPropertyPrivate; + friend class DSObject; +}; + } // namespace display_server -#else -#endif /* __DSPROPERTY_H */ + +#endif diff --git a/src/DSProperty/DSPropertyPrivate.cpp b/src/DSProperty/DSPropertyPrivate.cpp index 1c0ada3..00dd756 100644 --- a/src/DSProperty/DSPropertyPrivate.cpp +++ b/src/DSProperty/DSPropertyPrivate.cpp @@ -1,70 +1,73 @@ #include "DSProperty.h" namespace display_server { - DSPropertyPrivate::DSPropertyPrivate(DSProperty *p_ptr) : - __p_ptr(p_ptr) - { - __type = DSPropertyType::NONE; - } - DSPropertyPrivate::DSPropertyPrivate(DSProperty *p_ptr, std::string key, const DSPropertyVariant &data, DSPropertyType type) : - __p_ptr(p_ptr), __key(key), __type(type) - { - switch (__type) { // copy case - case DSPropertyType::INTEGER: - case DSPropertyType::DOUBLE: - case DSPropertyType::FLOAT: - case DSPropertyType::STRING: - __data = data; // value copy - break; - case DSPropertyType::POINTER: - __data = data; // address copy - break; - default: - break; - } - } - DSPropertyPrivate::~DSPropertyPrivate() - { - __key.clear(); - } +DSPropertyPrivate::DSPropertyPrivate(DSProperty *p_ptr) + : __p_ptr(p_ptr) +{ + __type = DSPropertyType::NONE; +} - const std::string DSPropertyPrivate::getKey() const - { - return __key; +DSPropertyPrivate::DSPropertyPrivate(DSProperty *p_ptr, std::string key, const DSPropertyVariant &data, DSPropertyType type) + : __p_ptr(p_ptr), __key(key), __type(type) +{ + switch (__type) { // copy case + case DSPropertyType::INTEGER: + case DSPropertyType::DOUBLE: + case DSPropertyType::FLOAT: + case DSPropertyType::STRING: + __data = data; // value copy + break; + case DSPropertyType::POINTER: + __data = data; // address copy + break; + default: + break; } +} - const DSPropertyVariant &DSPropertyPrivate::getData() const - { - return __data; - } +DSPropertyPrivate::~DSPropertyPrivate() +{ + __key.clear(); +} - const DSPropertyType DSPropertyPrivate::getType() const - { - return __type; - } +const std::string DSPropertyPrivate::__getKey() const +{ + return __key; +} - void DSPropertyPrivate::setKey(std::string key) - { - __key = key; - } +const DSPropertyVariant &DSPropertyPrivate::__getData() const +{ + return __data; +} + +const DSPropertyType DSPropertyPrivate::__getType() const +{ + return __type; +} - void DSPropertyPrivate::setData(DSPropertyVariant data, DSPropertyType type) - { - __type = type; +void DSPropertyPrivate::__setKey(std::string key) +{ + __key = key; +} - switch (__type) { // copy case - case DSPropertyType::INTEGER: - case DSPropertyType::DOUBLE: - case DSPropertyType::FLOAT: - case DSPropertyType::STRING: - __data = data; // value copy - break; - case DSPropertyType::POINTER: - __data = data; // address copy - break; - default: - break; - } +void DSPropertyPrivate::__setData(DSPropertyVariant data, DSPropertyType type) +{ + __type = type; + + switch (__type) { // copy case + case DSPropertyType::INTEGER: + case DSPropertyType::DOUBLE: + case DSPropertyType::FLOAT: + case DSPropertyType::STRING: + __data = data; // value copy + break; + case DSPropertyType::POINTER: + __data = data; // address copy + break; + default: + break; } +} + } // namespace display_server diff --git a/src/DSProperty/DSPropertyPrivate.h b/src/DSProperty/DSPropertyPrivate.h index 2cdd937..b7de8b7 100644 --- a/src/DSProperty/DSPropertyPrivate.h +++ b/src/DSProperty/DSPropertyPrivate.h @@ -1,60 +1,73 @@ -#ifndef __DSPROPERTYPRIVATE_H -# define __DSPROPERTYPRIVATE_H -# include "DSProperty.h" - -namespace display_server { - class DSProperty; - using DSPropertyType = enum type { - NONE, - INTEGER, //int - FLOAT, //float - DOUBLE, //double - STRING, //std::string - POINTER, //void* - }; - - using DSPropertyVariant = std::variant; - - struct DSPropertyException : public std::exception { - public: - DSPropertyException(std::string str) : msg(str) {} - virtual const char *what() const noexcept override - { - return msg.c_str(); - } - - private: - std::string msg; - }; - - class DSPropertyPrivate { - public: - DSPropertyPrivate() = delete; - DSPropertyPrivate(DSProperty *p_ptr); - DSPropertyPrivate(DSProperty *p_ptr, std::string key, const DSPropertyVariant &data, DSPropertyType type); - virtual ~DSPropertyPrivate(); - - inline const DSProperty *p_func() const - { - return __p_ptr; - } - - private: - DSProperty *__p_ptr; - - std::string __key; - DSPropertyVariant __data; - DSPropertyType __type; - - const std::string getKey(void) const; - const DSPropertyVariant &getData(void) const; - const DSPropertyType getType(void) const; - - void setKey(std::string key); - void setData(DSPropertyVariant data, DSPropertyType type); - - friend class DSProperty; - }; +#ifndef __DS_PROPERTY_PRIVATE_H_ +#define __DS_PROPERTY_PRIVATE_H_ + +#include "DSProperty.h" +#include +#include +#include +#include + +namespace display_server +{ + +class DSProperty; + +using DSPropertyType = enum type { + NONE, + INTEGER, //int + FLOAT, //float + DOUBLE, //double + STRING, //std::string + POINTER, //void* +}; + +using DSPropertyVariant = std::variant; + +struct DSPropertyException : public std::exception +{ +public: + DSPropertyException(std::string str) + : __msg(str) + {} + + virtual const char *what() const noexcept override + { + return __msg.c_str(); + } + +private: + std::string __msg; +}; + +class DSPropertyPrivate +{ +public: + DSPropertyPrivate() = delete; + DSPropertyPrivate(DSProperty *p_ptr); + DSPropertyPrivate(DSProperty *p_ptr, std::string key, const DSPropertyVariant &data, DSPropertyType type); + virtual ~DSPropertyPrivate(); + + inline const DSProperty *p_func() const + { + return __p_ptr; + } + +private: + DSProperty *__p_ptr; + std::string __key; + DSPropertyVariant __data; + DSPropertyType __type; + + const std::string __getKey(void) const; + const DSPropertyVariant &__getData(void) const; + const DSPropertyType __getType(void) const; + + void __setKey(std::string key); + void __setData(DSPropertyVariant data, DSPropertyType type); + + friend class DSProperty; +}; + } // namespace display_server -#else -#endif /* __DSPROPERTYPRIVATE_H */ + +#endif diff --git a/src/DSSignal/DSSignal.cpp b/src/DSSignal/DSSignal.cpp index 1b24993..8f79de2 100644 --- a/src/DSSignal/DSSignal.cpp +++ b/src/DSSignal/DSSignal.cpp @@ -3,13 +3,13 @@ namespace display_server { void DSSlotsObserver::addSlot(DSObject *slot) { - slots.push_back(slot); + _slotList.push_back(slot); } void DSSlotsObserver::destroyed(DSObject *slot) { - slots.remove(slot); - if (slots.empty()) + _slotList.remove(slot); + if (_slotList.empty()) delete this; } } // namespace display_server diff --git a/src/DSSignal/DSSignal.h b/src/DSSignal/DSSignal.h index 824cc4d..fd40342 100644 --- a/src/DSSignal/DSSignal.h +++ b/src/DSSignal/DSSignal.h @@ -1,5 +1,5 @@ -#ifndef __DSSIGNAL_H -#define __DSSIGNAL_H +#ifndef __DS_SIGNAL_H_ +#define __DS_SIGNAL_H_ #include "DSObject.h" #include @@ -7,100 +7,120 @@ #include #include -namespace display_server { -class DSSlotsObserver : public DSObjectObserverIface { +namespace display_server +{ + +class DSSlotsObserver : public IDSObjectObserver +{ public: DSSlotsObserver() {} ~DSSlotsObserver() {} virtual void destroyed(DSObject *obj); virtual void addSlot(DSObject *slot); + protected: - std::list slots; + std::list _slotList; }; template -class DSSlotConnection : public DSSlotsObserver { - public: - DSSlotConnection() {} - DSSlotConnection(DSObject *slot, void (*func)(Args...)) : callback(func) +class DSSlotConnection : public DSSlotsObserver +{ +public: + DSSlotConnection() + {} + + DSSlotConnection(DSObject *slot, void (*func)(Args...)) + : __callback(func) { //TODO: make callback as callback iface //std::unique_ptr ptr(new DSCallbackIface(func)); - //callback = std::move(ptr); + //__callback = std::move(ptr); addSlot(slot); } + virtual ~DSSlotConnection() { - for (auto &&slot : slots) + for (auto &&slot : _slotList) slot->detachDestroyObserver(this); - slots.clear(); + + _slotList.clear(); } void addSlot(DSObject *slot) override { - slots.push_back(slot); + _slotList.push_back(slot); slot->attachDestroyObserver(this); } + void destroyed(DSObject *slot) override { - slots.remove(slot); - if (slots.empty()) + _slotList.remove(slot); + + if (_slotList.empty()) ;//TODO: delete from DSSignal connections list with [guard pointer] } void invoke(Args... args) { - if (!slots.empty()) - callback(args...); + if (!_slotList.empty()) + __callback(args...); } private: //TODO: make callback as callback iface - //std::unique_ptr callback; - void (*callback)(Args...); + //std::unique_ptr __callback; + void (*__callback)(Args...); template friend class DSSignal; }; template -class DSSignal { +class DSSignal +{ public: - DSSignal() {} - virtual ~DSSignal() {} + DSSignal() + {} + virtual ~DSSignal() + {} - DSSignal &operator()(void) { return *this; } // functor + // functor + DSSignal &operator()(void) + { + return *this; + } void connect(DSObject *slot, void (*func)(Args...)) { if ((!slot) || (!func)) return; - if (auto con = findcon(func)) { - con->addSlot(slot); - } else { - connections.emplace_back(new DSSlotConnection(slot, func)); - } + + if (auto connection = __findConnection(func)) + connection->addSlot(slot); + else + __connectionList.emplace_back(new DSSlotConnection(slot, func)); } void emit(Args... args) { - for (auto &&con : connections) - con->invoke(args...); + for (auto &&connection : __connectionList) + connection->invoke(args...); } private: - DSSlotConnection *findcon(void (*func)(Args...)) + DSSlotConnection *__findConnection(void (*func)(Args...)) { - for (auto &&con : connections) - { - if (con->callback == func) - return con.get(); + for (auto &&connection : __connectionList) { + if (connection->__callback == func) + return connection.get(); } + return nullptr; } - std::list>> connections; + std::list>> __connectionList; }; -} // namespace display_server -#else -#endif /* __DSSIGNAL_H */ + +} + +#endif -- 2.7.4 From 4ea0c207ddf7791b4180976ff25e885cce4722aa Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 16 Jun 2020 18:02:15 +0900 Subject: [PATCH 05/16] include DSPropertyPrivate.h file Change-Id: Ib2c3d9a9af5612fd64400b9baf8fa5826e9278f3 --- src/DSProperty/DSPropertyPrivate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSProperty/DSPropertyPrivate.cpp b/src/DSProperty/DSPropertyPrivate.cpp index 00dd756..d07123d 100644 --- a/src/DSProperty/DSPropertyPrivate.cpp +++ b/src/DSProperty/DSPropertyPrivate.cpp @@ -1,4 +1,4 @@ -#include "DSProperty.h" +#include "DSPropertyPrivate.h" namespace display_server { -- 2.7.4 From 376e6657d3342cab45a63dc2e89ce92a1255c663 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 17 Jun 2020 08:14:07 +0900 Subject: [PATCH 06/16] add some members to CODEOWNERS Change-Id: Ib2c784b1d8561bfad9c585c399bd533b0e9b9fc1 --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 7d1ca41..09062c1 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -5,5 +5,5 @@ # the repo. Unless a later match takes precedence, # @global-owner1 and @global-owner2 will be requested for # review when someone opens a pull request. -* @cyeon-lee @doyoun-kang @gl77-lee @jhyuni-kang @jk0430-kim @joonbum-ko @juns-kim @juyeonne-lee @lsj119 @minjjj-kim @sc1-lim @shiin-lee @sj76-park +* @cyeon-lee @doyoun-kang @gl77-lee @jhyuni-kang @jk0430-kim @joonbum-ko @juns-kim @dyamy-lee @lsj119 @sc1-lim @shiin-lee @sj76-park @duna-oh -- 2.7.4 From 01255a07e991dcff4c1ce6971c4daa5ed6e3968a Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 17 Jun 2020 10:18:38 +0900 Subject: [PATCH 07/16] DSWaylandServer: add code for tizen-ws-shell, xdg-shell* interfaces and so on Change-Id: I5f5d0e7530498cad9e9e6dd14530e7a4c0e4d7bf Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/dswayland-server-eom.cpp | 429 +++ src/DSWaylandServer/dswayland-server-eom.h | 187 + .../dswayland-server-presentation-time.cpp | 447 +++ .../dswayland-server-presentation-time.h | 204 + .../dswayland-server-tizen_policy_ext.cpp | 562 +++ .../dswayland-server-tizen_policy_ext.h | 235 ++ src/DSWaylandServer/dswayland-server-tzsh.cpp | 3945 ++++++++++++++++++++ src/DSWaylandServer/dswayland-server-tzsh.h | 1760 +++++++++ .../dswayland-server-xdg-shell-unstable-v6.cpp | 1471 ++++++++ .../dswayland-server-xdg-shell-unstable-v6.h | 659 ++++ src/DSWaylandServer/dswayland-server-xdg-shell.cpp | 1471 ++++++++ src/DSWaylandServer/dswayland-server-xdg-shell.h | 671 ++++ 12 files changed, 12041 insertions(+) create mode 100644 src/DSWaylandServer/dswayland-server-eom.cpp create mode 100644 src/DSWaylandServer/dswayland-server-eom.h create mode 100644 src/DSWaylandServer/dswayland-server-presentation-time.cpp create mode 100644 src/DSWaylandServer/dswayland-server-presentation-time.h create mode 100644 src/DSWaylandServer/dswayland-server-tizen_policy_ext.cpp create mode 100644 src/DSWaylandServer/dswayland-server-tizen_policy_ext.h create mode 100644 src/DSWaylandServer/dswayland-server-tzsh.cpp create mode 100644 src/DSWaylandServer/dswayland-server-tzsh.h create mode 100644 src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.cpp create mode 100644 src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.h create mode 100644 src/DSWaylandServer/dswayland-server-xdg-shell.cpp create mode 100644 src/DSWaylandServer/dswayland-server-xdg-shell.h diff --git a/src/DSWaylandServer/dswayland-server-eom.cpp b/src/DSWaylandServer/dswayland-server-eom.cpp new file mode 100644 index 0000000..fe2281a --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-eom.cpp @@ -0,0 +1,429 @@ +/* Protocol XML file : wayland-extension/eom.xml */ + +#include "dswayland-server-wl-eom.h" + +#ifndef DS_UNLIKELY +#define DS_UNLIKELY(X) X +#endif +#ifndef DS_UNUSED +#define DS_UNUSED(X) X +#endif +#ifndef DS_ASSERT +#define DS_ASSERT(COND) assert(COND) +#endif +#ifndef DS_ASSERT_X +#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ + do {\ + if (! (COND))\ + {\ + fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ + assert(COND);\ + }\ + } while(0) +#endif +#ifndef WRN +#define WRN(X...) fprintf(stderr,##X) +#endif + +namespace DSWaylandServer { + wl_eom::wl_eom(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + wl_eom::wl_eom(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + wl_eom::wl_eom(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + wl_eom::wl_eom() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + wl_eom::~wl_eom() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + wl_eom::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void wl_eom::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void wl_eom::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + wl_eom::Resource *wl_eom::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + wl_eom::Resource *wl_eom::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void wl_eom::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::wl_eom_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = wl_eom::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *wl_eom::interface() + { + return &::wl_eom_interface; + } + + wl_eom::Resource *wl_eom::eom_allocate() + { + return new Resource; + } + + void wl_eom::eom_bind_resource(Resource *) + { + } + + void wl_eom::eom_destroy_resource(Resource *) + { + } + + void wl_eom::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + wl_eom *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void wl_eom::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + wl_eom *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void wl_eom::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + wl_eom *that = resource->eom_object; + that->m_resource_map.erase(resource->client()); + that->eom_destroy_resource(resource); + delete resource; + } + + wl_eom::Resource *wl_eom::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::wl_eom_interface, version, id); + return bind(handle); + } + + wl_eom::Resource *wl_eom::bind(struct ::wl_resource *handle) + { + Resource *resource = eom_allocate(); + resource->eom_object = this; + + wl_resource_set_implementation(handle, &m_wl_eom_interface, resource, destroy_func); + resource->handle = handle; + eom_bind_resource(resource); + return resource; + } + wl_eom::Resource *wl_eom::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::wl_eom_interface, &m_wl_eom_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::wl_eom_interface wl_eom::m_wl_eom_interface = { + wl_eom::handle_set_attribute, + wl_eom::handle_set_shell_window, + wl_eom::handle_get_output_info + }; + + void wl_eom::eom_set_attribute(Resource *, uint32_t , uint32_t ) + { + } + + void wl_eom::eom_set_shell_window(Resource *, uint32_t , struct ::wl_resource *) + { + } + + void wl_eom::eom_get_output_info(Resource *, uint32_t ) + { + } + + + void wl_eom::handle_set_attribute( + ::wl_client *client, + struct wl_resource *resource, + uint32_t output_id, + uint32_t attribute) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->eom_object)->eom_set_attribute( + r, + output_id, + attribute); + } + + void wl_eom::handle_set_shell_window( + ::wl_client *client, + struct wl_resource *resource, + uint32_t output_id, + struct ::wl_resource *surface) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->eom_object)->eom_set_shell_window( + r, + output_id, + surface); + } + + void wl_eom::handle_get_output_info( + ::wl_client *client, + struct wl_resource *resource, + uint32_t output_id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->eom_object)->eom_get_output_info( + r, + output_id); + } + + void wl_eom::send_output_count(uint32_t count) + { + DS_ASSERT_X(m_resource, "wl_eom::output_count", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_eom::output_count as it's not initialised"); + return; + } + send_output_count( + m_resource->handle, + count); + } + + void wl_eom::send_output_count(struct ::wl_resource *resource, uint32_t count) + { + wl_eom_send_output_count( + resource, + count); + } + + + void wl_eom::send_output_info(uint32_t output_id, uint32_t type, uint32_t mode, uint32_t w, uint32_t h, uint32_t w_mm, uint32_t h_mm, uint32_t connection, uint32_t skip, uint32_t attribute, uint32_t attribute_state, uint32_t error) + { + DS_ASSERT_X(m_resource, "wl_eom::output_info", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_eom::output_info as it's not initialised"); + return; + } + send_output_info( + m_resource->handle, + output_id, + type, + mode, + w, + h, + w_mm, + h_mm, + connection, + skip, + attribute, + attribute_state, + error); + } + + void wl_eom::send_output_info(struct ::wl_resource *resource, uint32_t output_id, uint32_t type, uint32_t mode, uint32_t w, uint32_t h, uint32_t w_mm, uint32_t h_mm, uint32_t connection, uint32_t skip, uint32_t attribute, uint32_t attribute_state, uint32_t error) + { + wl_eom_send_output_info( + resource, + output_id, + type, + mode, + w, + h, + w_mm, + h_mm, + connection, + skip, + attribute, + attribute_state, + error); + } + + + void wl_eom::send_output_type(uint32_t output_id, uint32_t type, uint32_t status) + { + DS_ASSERT_X(m_resource, "wl_eom::output_type", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_eom::output_type as it's not initialised"); + return; + } + send_output_type( + m_resource->handle, + output_id, + type, + status); + } + + void wl_eom::send_output_type(struct ::wl_resource *resource, uint32_t output_id, uint32_t type, uint32_t status) + { + wl_eom_send_output_type( + resource, + output_id, + type, + status); + } + + + void wl_eom::send_output_mode(uint32_t output_id, uint32_t mode) + { + DS_ASSERT_X(m_resource, "wl_eom::output_mode", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_eom::output_mode as it's not initialised"); + return; + } + send_output_mode( + m_resource->handle, + output_id, + mode); + } + + void wl_eom::send_output_mode(struct ::wl_resource *resource, uint32_t output_id, uint32_t mode) + { + wl_eom_send_output_mode( + resource, + output_id, + mode); + } + + + void wl_eom::send_output_attribute(uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error) + { + DS_ASSERT_X(m_resource, "wl_eom::output_attribute", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_eom::output_attribute as it's not initialised"); + return; + } + send_output_attribute( + m_resource->handle, + output_id, + attribute, + attribute_state, + error); + } + + void wl_eom::send_output_attribute(struct ::wl_resource *resource, uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error) + { + wl_eom_send_output_attribute( + resource, + output_id, + attribute, + attribute_state, + error); + } + + + void wl_eom::send_output_set_window(uint32_t output_id, uint32_t error) + { + DS_ASSERT_X(m_resource, "wl_eom::output_set_window", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_eom::output_set_window as it's not initialised"); + return; + } + send_output_set_window( + m_resource->handle, + output_id, + error); + } + + void wl_eom::send_output_set_window(struct ::wl_resource *resource, uint32_t output_id, uint32_t error) + { + wl_eom_send_output_set_window( + resource, + output_id, + error); + } + + + void wl_eom::send_output_add(uint32_t output_id) + { + DS_ASSERT_X(m_resource, "wl_eom::output_add", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_eom::output_add as it's not initialised"); + return; + } + send_output_add( + m_resource->handle, + output_id); + } + + void wl_eom::send_output_add(struct ::wl_resource *resource, uint32_t output_id) + { + wl_eom_send_output_add( + resource, + output_id); + } + + + void wl_eom::send_output_remove(uint32_t output_id) + { + DS_ASSERT_X(m_resource, "wl_eom::output_remove", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_eom::output_remove as it's not initialised"); + return; + } + send_output_remove( + m_resource->handle, + output_id); + } + + void wl_eom::send_output_remove(struct ::wl_resource *resource, uint32_t output_id) + { + wl_eom_send_output_remove( + resource, + output_id); + } + +} + diff --git a/src/DSWaylandServer/dswayland-server-eom.h b/src/DSWaylandServer/dswayland-server-eom.h new file mode 100644 index 0000000..dc45e8b --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-eom.h @@ -0,0 +1,187 @@ +/* Protocol XML file : wayland-extension/eom.xml */ + +#ifndef __DS_WL_EOM_PROTOCOL_H__ +#define __DS_WL_EOM_PROTOCOL_H__ + +#include "wayland-server-core.h" +#include "wl-eom-server-protocol.h" +#include +#include +#include +#include +#include + +#ifndef WAYLAND_VERSION_CHECK +#define WAYLAND_VERSION_CHECK(major, minor, micro) \ + ((WAYLAND_VERSION_MAJOR > (major)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) +#endif + + +namespace DSWaylandServer { + class wl_eom + { + public: + wl_eom(struct ::wl_client *client, int id, int version); + wl_eom(struct ::wl_display *display, int version); + wl_eom(struct ::wl_resource *resource); + wl_eom(); + + virtual ~wl_eom(); + + class Resource + { + public: + Resource() : eom_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + wl_eom *eom_object; + wl_eom *object() { return eom_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_none = 0, // no error + error_no_output = 1, // Given output is invalid. + error_no_attribute = 2, // Given attribute is invalid. + error_output_occupied = 3, // The key has been grabbed already. + }; + + enum type { + type_none = 0, // none + type_vga = 1, // VGA output connector type + type_dvii = 2, // DVI-I output connector type + type_dvid = 3, // DVI-D output connector type + type_dvia = 4, // DVI-A output connector type + type_composite = 5, // Composite output connector type + type_svideo = 6, // S-Video output connector type + type_lvds = 7, // LVDS output connector type + type_component = 8, // Component output connector type + type_9pindin = 9, // 9 pin DIN output connector type + type_displayport = 10, // DisplayPort output connector type + type_hdmia = 11, // HDMI type A output connector type + type_hdmib = 12, // HDMI type B output connector type + type_tv = 13, // TV output connector type + type_edp = 14, // eDP output connector type + type_virtual = 15, // Virtual output connector type + type_dsi = 16, // DSI output connector type + }; + + enum status { + status_none = 0, // none + status_connection = 1, // output connected + status_disconnection = 2, // output disconnected + }; + + enum mode { + mode_none = 0, // none + mode_mirror = 1, // mirror mode + mode_presentation = 2, // presentation mode + }; + + enum attribute { + attribute_none = 0, // none + attribute_normal = 1, // nomal attribute + attribute_exclusive_share = 2, // exclusive share attribute + attribute_exclusive = 3, // exclusive attribute + }; + + enum attribute_state { + attribute_state_none = 0, // none + attribute_state_active = 1, // attribute is active on the output + attribute_state_inactive = 2, // attribute is inactive on the output + attribute_state_lost = 3, // the connection of output is lost + }; + + void send_output_count(uint32_t count); + void send_output_count(struct ::wl_resource *resource, uint32_t count); + void send_output_info(uint32_t output_id, uint32_t type, uint32_t mode, uint32_t w, uint32_t h, uint32_t w_mm, uint32_t h_mm, uint32_t connection, uint32_t skip, uint32_t attribute, uint32_t attribute_state, uint32_t error); + void send_output_info(struct ::wl_resource *resource, uint32_t output_id, uint32_t type, uint32_t mode, uint32_t w, uint32_t h, uint32_t w_mm, uint32_t h_mm, uint32_t connection, uint32_t skip, uint32_t attribute, uint32_t attribute_state, uint32_t error); + void send_output_type(uint32_t output_id, uint32_t type, uint32_t status); + void send_output_type(struct ::wl_resource *resource, uint32_t output_id, uint32_t type, uint32_t status); + void send_output_mode(uint32_t output_id, uint32_t mode); + void send_output_mode(struct ::wl_resource *resource, uint32_t output_id, uint32_t mode); + void send_output_attribute(uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error); + void send_output_attribute(struct ::wl_resource *resource, uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error); + void send_output_set_window(uint32_t output_id, uint32_t error); + void send_output_set_window(struct ::wl_resource *resource, uint32_t output_id, uint32_t error); + void send_output_add(uint32_t output_id); + void send_output_add(struct ::wl_resource *resource, uint32_t output_id); + void send_output_remove(uint32_t output_id); + void send_output_remove(struct ::wl_resource *resource, uint32_t output_id); + + protected: + virtual Resource *eom_allocate(); + + virtual void eom_bind_resource(Resource *resource); + virtual void eom_destroy_resource(Resource *resource); + + virtual void eom_set_attribute(Resource *resource, uint32_t output_id, uint32_t attribute); + virtual void eom_set_shell_window(Resource *resource, uint32_t output_id, struct ::wl_resource *surface); + virtual void eom_get_output_info(Resource *resource, uint32_t output_id); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::wl_eom_interface m_wl_eom_interface; + + static void handle_set_attribute( + ::wl_client *client, + struct wl_resource *resource, + uint32_t output_id, + uint32_t attribute); + static void handle_set_shell_window( + ::wl_client *client, + struct wl_resource *resource, + uint32_t output_id, + struct ::wl_resource *surface); + static void handle_get_output_info( + ::wl_client *client, + struct wl_resource *resource, + uint32_t output_id); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + wl_eom *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; +} + +#endif diff --git a/src/DSWaylandServer/dswayland-server-presentation-time.cpp b/src/DSWaylandServer/dswayland-server-presentation-time.cpp new file mode 100644 index 0000000..baa0ce0 --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-presentation-time.cpp @@ -0,0 +1,447 @@ +/* Protocol XML file : wayland-extension/presentation-time.xml */ + +#include "dswayland-server-presentation-time.h" + +#ifndef DS_UNLIKELY +#define DS_UNLIKELY(X) X +#endif +#ifndef DS_UNUSED +#define DS_UNUSED(X) X +#endif +#ifndef DS_ASSERT +#define DS_ASSERT(COND) assert(COND) +#endif +#ifndef DS_ASSERT_X +#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ + do {\ + if (! (COND))\ + {\ + fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ + assert(COND);\ + }\ + } while(0) +#endif +#ifndef WRN +#define WRN(X...) fprintf(stderr,##X) +#endif + +namespace DSWaylandServer { + wp_presentation::wp_presentation(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + wp_presentation::wp_presentation(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + wp_presentation::wp_presentation(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + wp_presentation::wp_presentation() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + wp_presentation::~wp_presentation() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + wp_presentation::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void wp_presentation::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void wp_presentation::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + wp_presentation::Resource *wp_presentation::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + wp_presentation::Resource *wp_presentation::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void wp_presentation::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::wp_presentation_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = wp_presentation::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *wp_presentation::interface() + { + return &::wp_presentation_interface; + } + + wp_presentation::Resource *wp_presentation::wp_presentation_allocate() + { + return new Resource; + } + + void wp_presentation::wp_presentation_bind_resource(Resource *) + { + } + + void wp_presentation::wp_presentation_destroy_resource(Resource *) + { + } + + void wp_presentation::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + wp_presentation *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void wp_presentation::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + wp_presentation *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void wp_presentation::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + wp_presentation *that = resource->wp_presentation_object; + that->m_resource_map.erase(resource->client()); + that->wp_presentation_destroy_resource(resource); + delete resource; + } + + wp_presentation::Resource *wp_presentation::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::wp_presentation_interface, version, id); + return bind(handle); + } + + wp_presentation::Resource *wp_presentation::bind(struct ::wl_resource *handle) + { + Resource *resource = wp_presentation_allocate(); + resource->wp_presentation_object = this; + + wl_resource_set_implementation(handle, &m_wp_presentation_interface, resource, destroy_func); + resource->handle = handle; + wp_presentation_bind_resource(resource); + return resource; + } + wp_presentation::Resource *wp_presentation::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::wp_presentation_interface, &m_wp_presentation_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::wp_presentation_interface wp_presentation::m_wp_presentation_interface = { + wp_presentation::handle_destroy, + wp_presentation::handle_feedback + }; + + void wp_presentation::wp_presentation_destroy(Resource *) + { + } + + void wp_presentation::wp_presentation_feedback(Resource *, struct ::wl_resource *, uint32_t) + { + } + + + void wp_presentation::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->wp_presentation_object)->wp_presentation_destroy( + r); + } + + void wp_presentation::handle_feedback( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *surface, + uint32_t callback) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->wp_presentation_object)->wp_presentation_feedback( + r, + surface, + callback); + } + + void wp_presentation::send_clock_id(uint32_t clk_id) + { + DS_ASSERT_X(m_resource, "wp_presentation::clock_id", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wp_presentation::clock_id as it's not initialised"); + return; + } + send_clock_id( + m_resource->handle, + clk_id); + } + + void wp_presentation::send_clock_id(struct ::wl_resource *resource, uint32_t clk_id) + { + wp_presentation_send_clock_id( + resource, + clk_id); + } + + + wp_presentation_feedback::wp_presentation_feedback(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + wp_presentation_feedback::wp_presentation_feedback(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + wp_presentation_feedback::wp_presentation_feedback(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + wp_presentation_feedback::wp_presentation_feedback() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + wp_presentation_feedback::~wp_presentation_feedback() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + wp_presentation_feedback::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void wp_presentation_feedback::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void wp_presentation_feedback::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + wp_presentation_feedback::Resource *wp_presentation_feedback::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + wp_presentation_feedback::Resource *wp_presentation_feedback::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void wp_presentation_feedback::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::wp_presentation_feedback_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = wp_presentation_feedback::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *wp_presentation_feedback::interface() + { + return &::wp_presentation_feedback_interface; + } + + wp_presentation_feedback::Resource *wp_presentation_feedback::wp_presentation_feedback_allocate() + { + return new Resource; + } + + void wp_presentation_feedback::wp_presentation_feedback_bind_resource(Resource *) + { + } + + void wp_presentation_feedback::wp_presentation_feedback_destroy_resource(Resource *) + { + } + + void wp_presentation_feedback::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + wp_presentation_feedback *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void wp_presentation_feedback::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + wp_presentation_feedback *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void wp_presentation_feedback::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + wp_presentation_feedback *that = resource->wp_presentation_feedback_object; + that->m_resource_map.erase(resource->client()); + that->wp_presentation_feedback_destroy_resource(resource); + delete resource; + } + + wp_presentation_feedback::Resource *wp_presentation_feedback::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::wp_presentation_feedback_interface, version, id); + return bind(handle); + } + + wp_presentation_feedback::Resource *wp_presentation_feedback::bind(struct ::wl_resource *handle) + { + Resource *resource = wp_presentation_feedback_allocate(); + resource->wp_presentation_feedback_object = this; + + wl_resource_set_implementation(handle, NULL, resource, destroy_func); + resource->handle = handle; + wp_presentation_feedback_bind_resource(resource); + return resource; + } + wp_presentation_feedback::Resource *wp_presentation_feedback::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::wp_presentation_feedback_interface, NULL)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + void wp_presentation_feedback::send_sync_output(struct ::wl_resource *output) + { + DS_ASSERT_X(m_resource, "wp_presentation_feedback::sync_output", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wp_presentation_feedback::sync_output as it's not initialised"); + return; + } + send_sync_output( + m_resource->handle, + output); + } + + void wp_presentation_feedback::send_sync_output(struct ::wl_resource *resource, struct ::wl_resource *output) + { + wp_presentation_feedback_send_sync_output( + resource, + output); + } + + + void wp_presentation_feedback::send_presented(uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags) + { + DS_ASSERT_X(m_resource, "wp_presentation_feedback::presented", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wp_presentation_feedback::presented as it's not initialised"); + return; + } + send_presented( + m_resource->handle, + tv_sec_hi, + tv_sec_lo, + tv_nsec, + refresh, + seq_hi, + seq_lo, + flags); + } + + void wp_presentation_feedback::send_presented(struct ::wl_resource *resource, uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags) + { + wp_presentation_feedback_send_presented( + resource, + tv_sec_hi, + tv_sec_lo, + tv_nsec, + refresh, + seq_hi, + seq_lo, + flags); + } + + + void wp_presentation_feedback::send_discarded() + { + DS_ASSERT_X(m_resource, "wp_presentation_feedback::discarded", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wp_presentation_feedback::discarded as it's not initialised"); + return; + } + send_discarded( + m_resource->handle); + } + + void wp_presentation_feedback::send_discarded(struct ::wl_resource *resource) + { + wp_presentation_feedback_send_discarded( + resource); + } + +} + diff --git a/src/DSWaylandServer/dswayland-server-presentation-time.h b/src/DSWaylandServer/dswayland-server-presentation-time.h new file mode 100644 index 0000000..7e7144d --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-presentation-time.h @@ -0,0 +1,204 @@ +/* Protocol XML file : wayland-extension/presentation-time.xml */ + +#ifndef __DS_PRESENTATION_TIME_PROTOCOL_H__ +#define __DS_PRESENTATION_TIME_PROTOCOL_H__ + +#include "wayland-server-core.h" +#include "presentation-time-server-protocol.h" +#include +#include +#include +#include +#include + +#ifndef WAYLAND_VERSION_CHECK +#define WAYLAND_VERSION_CHECK(major, minor, micro) \ + ((WAYLAND_VERSION_MAJOR > (major)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) +#endif + + +namespace DSWaylandServer { + class wp_presentation + { + public: + wp_presentation(struct ::wl_client *client, int id, int version); + wp_presentation(struct ::wl_display *display, int version); + wp_presentation(struct ::wl_resource *resource); + wp_presentation(); + + virtual ~wp_presentation(); + + class Resource + { + public: + Resource() : wp_presentation_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + wp_presentation *wp_presentation_object; + wp_presentation *object() { return wp_presentation_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_invalid_timestamp = 0, // invalid value in tv_nsec + error_invalid_flag = 1, // invalid flag + }; + + void send_clock_id(uint32_t clk_id); + void send_clock_id(struct ::wl_resource *resource, uint32_t clk_id); + + protected: + virtual Resource *wp_presentation_allocate(); + + virtual void wp_presentation_bind_resource(Resource *resource); + virtual void wp_presentation_destroy_resource(Resource *resource); + + virtual void wp_presentation_destroy(Resource *resource); + virtual void wp_presentation_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t callback); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::wp_presentation_interface m_wp_presentation_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_feedback( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *surface, + uint32_t callback); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + wp_presentation *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class wp_presentation_feedback + { + public: + wp_presentation_feedback(struct ::wl_client *client, int id, int version); + wp_presentation_feedback(struct ::wl_display *display, int version); + wp_presentation_feedback(struct ::wl_resource *resource); + wp_presentation_feedback(); + + virtual ~wp_presentation_feedback(); + + class Resource + { + public: + Resource() : wp_presentation_feedback_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + wp_presentation_feedback *wp_presentation_feedback_object; + wp_presentation_feedback *object() { return wp_presentation_feedback_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum kind { + kind_vsync = 0x1, // presentation was vsync'd + kind_hw_clock = 0x2, // hardware provided the presentation timestamp + kind_hw_completion = 0x4, // hardware signalled the start of the presentation + kind_zero_copy = 0x8, // presentation was done zero-copy + }; + + void send_sync_output(struct ::wl_resource *output); + void send_sync_output(struct ::wl_resource *resource, struct ::wl_resource *output); + void send_presented(uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags); + void send_presented(struct ::wl_resource *resource, uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags); + void send_discarded(); + void send_discarded(struct ::wl_resource *resource); + + protected: + virtual Resource *wp_presentation_feedback_allocate(); + + virtual void wp_presentation_feedback_bind_resource(Resource *resource); + virtual void wp_presentation_feedback_destroy_resource(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + wp_presentation_feedback *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; +} + +#endif diff --git a/src/DSWaylandServer/dswayland-server-tizen_policy_ext.cpp b/src/DSWaylandServer/dswayland-server-tizen_policy_ext.cpp new file mode 100644 index 0000000..d425828 --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-tizen_policy_ext.cpp @@ -0,0 +1,562 @@ +/* Protocol XML file : wayland-extension/tizen_policy_ext.xml */ + +#include "dswayland-server-tizen-policy-ext.h" + +#ifndef DS_UNLIKELY +#define DS_UNLIKELY(X) X +#endif +#ifndef DS_UNUSED +#define DS_UNUSED(X) X +#endif +#ifndef DS_ASSERT +#define DS_ASSERT(COND) assert(COND) +#endif +#ifndef DS_ASSERT_X +#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ + do {\ + if (! (COND))\ + {\ + fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ + assert(COND);\ + }\ + } while(0) +#endif +#ifndef WRN +#define WRN(X...) fprintf(stderr,##X) +#endif + +namespace DSWaylandServer { + tizen_policy_ext::tizen_policy_ext(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tizen_policy_ext::tizen_policy_ext(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tizen_policy_ext::tizen_policy_ext(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tizen_policy_ext::tizen_policy_ext() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tizen_policy_ext::~tizen_policy_ext() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tizen_policy_ext::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tizen_policy_ext::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tizen_policy_ext::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tizen_policy_ext::Resource *tizen_policy_ext::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tizen_policy_ext::Resource *tizen_policy_ext::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tizen_policy_ext::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tizen_policy_ext_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tizen_policy_ext::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tizen_policy_ext::interface() + { + return &::tizen_policy_ext_interface; + } + + tizen_policy_ext::Resource *tizen_policy_ext::tizen_policy_ext_allocate() + { + return new Resource; + } + + void tizen_policy_ext::tizen_policy_ext_bind_resource(Resource *) + { + } + + void tizen_policy_ext::tizen_policy_ext_destroy_resource(Resource *) + { + } + + void tizen_policy_ext::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tizen_policy_ext *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tizen_policy_ext::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tizen_policy_ext *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tizen_policy_ext::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tizen_policy_ext *that = resource->tizen_policy_ext_object; + that->m_resource_map.erase(resource->client()); + that->tizen_policy_ext_destroy_resource(resource); + delete resource; + } + + tizen_policy_ext::Resource *tizen_policy_ext::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tizen_policy_ext_interface, version, id); + return bind(handle); + } + + tizen_policy_ext::Resource *tizen_policy_ext::bind(struct ::wl_resource *handle) + { + Resource *resource = tizen_policy_ext_allocate(); + resource->tizen_policy_ext_object = this; + + wl_resource_set_implementation(handle, &m_tizen_policy_ext_interface, resource, destroy_func); + resource->handle = handle; + tizen_policy_ext_bind_resource(resource); + return resource; + } + tizen_policy_ext::Resource *tizen_policy_ext::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tizen_policy_ext_interface, &m_tizen_policy_ext_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tizen_policy_ext_interface tizen_policy_ext::m_tizen_policy_ext_interface = { + tizen_policy_ext::handle_get_rotation, + tizen_policy_ext::handle_get_active_angle + }; + + void tizen_policy_ext::tizen_policy_ext_get_rotation(Resource *, uint32_t, struct ::wl_resource *) + { + } + + void tizen_policy_ext::tizen_policy_ext_get_active_angle(Resource *, struct ::wl_resource *) + { + } + + + void tizen_policy_ext::handle_get_rotation( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *surface) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_policy_ext_object)->tizen_policy_ext_get_rotation( + r, + id, + surface); + } + + void tizen_policy_ext::handle_get_active_angle( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *surface) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_policy_ext_object)->tizen_policy_ext_get_active_angle( + r, + surface); + } + + void tizen_policy_ext::send_active_angle(uint32_t angle) + { + DS_ASSERT_X(m_resource, "tizen_policy_ext::active_angle", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_policy_ext::active_angle as it's not initialised"); + return; + } + send_active_angle( + m_resource->handle, + angle); + } + + void tizen_policy_ext::send_active_angle(struct ::wl_resource *resource, uint32_t angle) + { + tizen_policy_ext_send_active_angle( + resource, + angle); + } + + + tizen_rotation::tizen_rotation(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tizen_rotation::tizen_rotation(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tizen_rotation::tizen_rotation(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tizen_rotation::tizen_rotation() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tizen_rotation::~tizen_rotation() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tizen_rotation::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tizen_rotation::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tizen_rotation::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tizen_rotation::Resource *tizen_rotation::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tizen_rotation::Resource *tizen_rotation::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tizen_rotation::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tizen_rotation_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tizen_rotation::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tizen_rotation::interface() + { + return &::tizen_rotation_interface; + } + + tizen_rotation::Resource *tizen_rotation::tizen_rotation_allocate() + { + return new Resource; + } + + void tizen_rotation::tizen_rotation_bind_resource(Resource *) + { + } + + void tizen_rotation::tizen_rotation_destroy_resource(Resource *) + { + } + + void tizen_rotation::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tizen_rotation *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tizen_rotation::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tizen_rotation *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tizen_rotation::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tizen_rotation *that = resource->tizen_rotation_object; + that->m_resource_map.erase(resource->client()); + that->tizen_rotation_destroy_resource(resource); + delete resource; + } + + tizen_rotation::Resource *tizen_rotation::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tizen_rotation_interface, version, id); + return bind(handle); + } + + tizen_rotation::Resource *tizen_rotation::bind(struct ::wl_resource *handle) + { + Resource *resource = tizen_rotation_allocate(); + resource->tizen_rotation_object = this; + + wl_resource_set_implementation(handle, &m_tizen_rotation_interface, resource, destroy_func); + resource->handle = handle; + tizen_rotation_bind_resource(resource); + return resource; + } + tizen_rotation::Resource *tizen_rotation::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tizen_rotation_interface, &m_tizen_rotation_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tizen_rotation_interface tizen_rotation::m_tizen_rotation_interface = { + tizen_rotation::handle_destroy, + tizen_rotation::handle_set_available_angles, + tizen_rotation::handle_set_preferred_angle, + tizen_rotation::handle_ack_angle_change, + tizen_rotation::handle_set_geometry_hint + }; + + void tizen_rotation::tizen_rotation_destroy(Resource *) + { + } + + void tizen_rotation::tizen_rotation_set_available_angles(Resource *, uint32_t ) + { + } + + void tizen_rotation::tizen_rotation_set_preferred_angle(Resource *, uint32_t ) + { + } + + void tizen_rotation::tizen_rotation_ack_angle_change(Resource *, uint32_t ) + { + } + + void tizen_rotation::tizen_rotation_set_geometry_hint(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) + { + } + + + void tizen_rotation::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_rotation_object)->tizen_rotation_destroy( + r); + } + + void tizen_rotation::handle_set_available_angles( + ::wl_client *client, + struct wl_resource *resource, + uint32_t angles) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_rotation_object)->tizen_rotation_set_available_angles( + r, + angles); + } + + void tizen_rotation::handle_set_preferred_angle( + ::wl_client *client, + struct wl_resource *resource, + uint32_t angle) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_rotation_object)->tizen_rotation_set_preferred_angle( + r, + angle); + } + + void tizen_rotation::handle_ack_angle_change( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_rotation_object)->tizen_rotation_ack_angle_change( + r, + serial); + } + + void tizen_rotation::handle_set_geometry_hint( + ::wl_client *client, + struct wl_resource *resource, + uint32_t angle, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_rotation_object)->tizen_rotation_set_geometry_hint( + r, + angle, + x, + y, + w, + h); + } + + void tizen_rotation::send_available_angles_done(uint32_t angles) + { + DS_ASSERT_X(m_resource, "tizen_rotation::available_angles_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_rotation::available_angles_done as it's not initialised"); + return; + } + send_available_angles_done( + m_resource->handle, + angles); + } + + void tizen_rotation::send_available_angles_done(struct ::wl_resource *resource, uint32_t angles) + { + tizen_rotation_send_available_angles_done( + resource, + angles); + } + + + void tizen_rotation::send_preferred_angle_done(uint32_t angle) + { + DS_ASSERT_X(m_resource, "tizen_rotation::preferred_angle_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_rotation::preferred_angle_done as it's not initialised"); + return; + } + send_preferred_angle_done( + m_resource->handle, + angle); + } + + void tizen_rotation::send_preferred_angle_done(struct ::wl_resource *resource, uint32_t angle) + { + tizen_rotation_send_preferred_angle_done( + resource, + angle); + } + + + void tizen_rotation::send_angle_change(uint32_t angle, uint32_t serial) + { + DS_ASSERT_X(m_resource, "tizen_rotation::angle_change", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_rotation::angle_change as it's not initialised"); + return; + } + send_angle_change( + m_resource->handle, + angle, + serial); + } + + void tizen_rotation::send_angle_change(struct ::wl_resource *resource, uint32_t angle, uint32_t serial) + { + tizen_rotation_send_angle_change( + resource, + angle, + serial); + } + + + void tizen_rotation::send_angle_change_with_resize(uint32_t angle, uint32_t serial, uint32_t width, uint32_t height) + { + DS_ASSERT_X(m_resource, "tizen_rotation::angle_change_with_resize", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_rotation::angle_change_with_resize as it's not initialised"); + return; + } + send_angle_change_with_resize( + m_resource->handle, + angle, + serial, + width, + height); + } + + void tizen_rotation::send_angle_change_with_resize(struct ::wl_resource *resource, uint32_t angle, uint32_t serial, uint32_t width, uint32_t height) + { + tizen_rotation_send_angle_change_with_resize( + resource, + angle, + serial, + width, + height); + } + +} + diff --git a/src/DSWaylandServer/dswayland-server-tizen_policy_ext.h b/src/DSWaylandServer/dswayland-server-tizen_policy_ext.h new file mode 100644 index 0000000..1cb1844 --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-tizen_policy_ext.h @@ -0,0 +1,235 @@ +/* Protocol XML file : wayland-extension/tizen_policy_ext.xml */ + +#ifndef __DS_TIZEN_POLICY_EXT_PROTOCOL_H__ +#define __DS_TIZEN_POLICY_EXT_PROTOCOL_H__ + +#include "wayland-server-core.h" +#include "tizen-policy-ext-server-protocol.h" +#include +#include +#include +#include +#include + +#ifndef WAYLAND_VERSION_CHECK +#define WAYLAND_VERSION_CHECK(major, minor, micro) \ + ((WAYLAND_VERSION_MAJOR > (major)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) +#endif + + +namespace DSWaylandServer { + class tizen_policy_ext + { + public: + tizen_policy_ext(struct ::wl_client *client, int id, int version); + tizen_policy_ext(struct ::wl_display *display, int version); + tizen_policy_ext(struct ::wl_resource *resource); + tizen_policy_ext(); + + virtual ~tizen_policy_ext(); + + class Resource + { + public: + Resource() : tizen_policy_ext_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tizen_policy_ext *tizen_policy_ext_object; + tizen_policy_ext *object() { return tizen_policy_ext_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + void send_active_angle(uint32_t angle); + void send_active_angle(struct ::wl_resource *resource, uint32_t angle); + + protected: + virtual Resource *tizen_policy_ext_allocate(); + + virtual void tizen_policy_ext_bind_resource(Resource *resource); + virtual void tizen_policy_ext_destroy_resource(Resource *resource); + + virtual void tizen_policy_ext_get_rotation(Resource *resource, uint32_t id, struct ::wl_resource *surface); + virtual void tizen_policy_ext_get_active_angle(Resource *resource, struct ::wl_resource *surface); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tizen_policy_ext_interface m_tizen_policy_ext_interface; + + static void handle_get_rotation( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *surface); + static void handle_get_active_angle( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *surface); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tizen_policy_ext *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tizen_rotation + { + public: + tizen_rotation(struct ::wl_client *client, int id, int version); + tizen_rotation(struct ::wl_display *display, int version); + tizen_rotation(struct ::wl_resource *resource); + tizen_rotation(); + + virtual ~tizen_rotation(); + + class Resource + { + public: + Resource() : tizen_rotation_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tizen_rotation *tizen_rotation_object; + tizen_rotation *object() { return tizen_rotation_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum angle { + angle_none = 0, + angle_0 = 1, + angle_90 = 2, + angle_180 = 4, + angle_270 = 8, + }; + + void send_available_angles_done(uint32_t angles); + void send_available_angles_done(struct ::wl_resource *resource, uint32_t angles); + void send_preferred_angle_done(uint32_t angle); + void send_preferred_angle_done(struct ::wl_resource *resource, uint32_t angle); + void send_angle_change(uint32_t angle, uint32_t serial); + void send_angle_change(struct ::wl_resource *resource, uint32_t angle, uint32_t serial); + void send_angle_change_with_resize(uint32_t angle, uint32_t serial, uint32_t width, uint32_t height); + void send_angle_change_with_resize(struct ::wl_resource *resource, uint32_t angle, uint32_t serial, uint32_t width, uint32_t height); + + protected: + virtual Resource *tizen_rotation_allocate(); + + virtual void tizen_rotation_bind_resource(Resource *resource); + virtual void tizen_rotation_destroy_resource(Resource *resource); + + virtual void tizen_rotation_destroy(Resource *resource); + virtual void tizen_rotation_set_available_angles(Resource *resource, uint32_t angles); + virtual void tizen_rotation_set_preferred_angle(Resource *resource, uint32_t angle); + virtual void tizen_rotation_ack_angle_change(Resource *resource, uint32_t serial); + virtual void tizen_rotation_set_geometry_hint(Resource *resource, uint32_t angle, uint32_t x, uint32_t y, uint32_t w, uint32_t h); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tizen_rotation_interface m_tizen_rotation_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_set_available_angles( + ::wl_client *client, + struct wl_resource *resource, + uint32_t angles); + static void handle_set_preferred_angle( + ::wl_client *client, + struct wl_resource *resource, + uint32_t angle); + static void handle_ack_angle_change( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial); + static void handle_set_geometry_hint( + ::wl_client *client, + struct wl_resource *resource, + uint32_t angle, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tizen_rotation *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; +} + +#endif diff --git a/src/DSWaylandServer/dswayland-server-tzsh.cpp b/src/DSWaylandServer/dswayland-server-tzsh.cpp new file mode 100644 index 0000000..c1826ed --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-tzsh.cpp @@ -0,0 +1,3945 @@ +/* Protocol XML file : wayland-extension/tzsh.xml */ + +#include "dswayland-server-tizen-ws-shell.h" + +#ifndef DS_UNLIKELY +#define DS_UNLIKELY(X) X +#endif +#ifndef DS_UNUSED +#define DS_UNUSED(X) X +#endif +#ifndef DS_ASSERT +#define DS_ASSERT(COND) assert(COND) +#endif +#ifndef DS_ASSERT_X +#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ + do {\ + if (! (COND))\ + {\ + fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ + assert(COND);\ + }\ + } while(0) +#endif +#ifndef WRN +#define WRN(X...) fprintf(stderr,##X) +#endif + +namespace DSWaylandServer { + tizen_ws_shell::tizen_ws_shell(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tizen_ws_shell::tizen_ws_shell(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tizen_ws_shell::tizen_ws_shell(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tizen_ws_shell::tizen_ws_shell() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tizen_ws_shell::~tizen_ws_shell() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tizen_ws_shell::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tizen_ws_shell::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tizen_ws_shell::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tizen_ws_shell::Resource *tizen_ws_shell::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tizen_ws_shell::Resource *tizen_ws_shell::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tizen_ws_shell::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tizen_ws_shell_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tizen_ws_shell::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tizen_ws_shell::interface() + { + return &::tizen_ws_shell_interface; + } + + tizen_ws_shell::Resource *tizen_ws_shell::tizen_ws_shell_allocate() + { + return new Resource; + } + + void tizen_ws_shell::tizen_ws_shell_bind_resource(Resource *) + { + } + + void tizen_ws_shell::tizen_ws_shell_destroy_resource(Resource *) + { + } + + void tizen_ws_shell::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tizen_ws_shell *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tizen_ws_shell::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tizen_ws_shell *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tizen_ws_shell::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tizen_ws_shell *that = resource->tizen_ws_shell_object; + that->m_resource_map.erase(resource->client()); + that->tizen_ws_shell_destroy_resource(resource); + delete resource; + } + + tizen_ws_shell::Resource *tizen_ws_shell::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tizen_ws_shell_interface, version, id); + return bind(handle); + } + + tizen_ws_shell::Resource *tizen_ws_shell::bind(struct ::wl_resource *handle) + { + Resource *resource = tizen_ws_shell_allocate(); + resource->tizen_ws_shell_object = this; + + wl_resource_set_implementation(handle, &m_tizen_ws_shell_interface, resource, destroy_func); + resource->handle = handle; + tizen_ws_shell_bind_resource(resource); + return resource; + } + tizen_ws_shell::Resource *tizen_ws_shell::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tizen_ws_shell_interface, &m_tizen_ws_shell_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tizen_ws_shell_interface tizen_ws_shell::m_tizen_ws_shell_interface = { + tizen_ws_shell::handle_destroy, + tizen_ws_shell::handle_service_create, + tizen_ws_shell::handle_region_create, + tizen_ws_shell::handle_quickpanel_get, + tizen_ws_shell::handle_tvsrv_get, + tizen_ws_shell::handle_extension_get, + tizen_ws_shell::handle_softkey_get, + tizen_ws_shell::handle_shared_widget_launch_get + }; + + void tizen_ws_shell::tizen_ws_shell_destroy(Resource *) + { + } + + void tizen_ws_shell::tizen_ws_shell_service_create(Resource *, uint32_t, uint32_t , const std::string &) + { + } + + void tizen_ws_shell::tizen_ws_shell_region_create(Resource *, uint32_t) + { + } + + void tizen_ws_shell::tizen_ws_shell_quickpanel_get(Resource *, uint32_t, uint32_t ) + { + } + + void tizen_ws_shell::tizen_ws_shell_tvsrv_get(Resource *, uint32_t, uint32_t ) + { + } + + void tizen_ws_shell::tizen_ws_shell_extension_get(Resource *, uint32_t, const std::string &) + { + } + + void tizen_ws_shell::tizen_ws_shell_softkey_get(Resource *, uint32_t, uint32_t ) + { + } + + void tizen_ws_shell::tizen_ws_shell_shared_widget_launch_get(Resource *, uint32_t, uint32_t ) + { + } + + + void tizen_ws_shell::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_destroy( + r); + } + + void tizen_ws_shell::handle_service_create( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win, + const char *name) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_service_create( + r, + id, + win, + std::string(name)); + } + + void tizen_ws_shell::handle_region_create( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_region_create( + r, + id); + } + + void tizen_ws_shell::handle_quickpanel_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_quickpanel_get( + r, + id, + win); + } + + void tizen_ws_shell::handle_tvsrv_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_tvsrv_get( + r, + id, + win); + } + + void tizen_ws_shell::handle_extension_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + const char *name) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_extension_get( + r, + id, + std::string(name)); + } + + void tizen_ws_shell::handle_softkey_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_softkey_get( + r, + id, + win); + } + + void tizen_ws_shell::handle_shared_widget_launch_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_shared_widget_launch_get( + r, + id, + win); + } + + void tizen_ws_shell::send_service_register(const std::string &name) + { + DS_ASSERT_X(m_resource, "tizen_ws_shell::service_register", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_ws_shell::service_register as it's not initialised"); + return; + } + send_service_register( + m_resource->handle, + name); + } + + void tizen_ws_shell::send_service_register(struct ::wl_resource *resource, const std::string &name) + { + tizen_ws_shell_send_service_register( + resource, + name.c_str()); + } + + + void tizen_ws_shell::send_service_unregister(const std::string &name) + { + DS_ASSERT_X(m_resource, "tizen_ws_shell::service_unregister", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_ws_shell::service_unregister as it's not initialised"); + return; + } + send_service_unregister( + m_resource->handle, + name); + } + + void tizen_ws_shell::send_service_unregister(struct ::wl_resource *resource, const std::string &name) + { + tizen_ws_shell_send_service_unregister( + resource, + name.c_str()); + } + + + void tizen_ws_shell::send_error(uint32_t error_state) + { + DS_ASSERT_X(m_resource, "tizen_ws_shell::error", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_ws_shell::error as it's not initialised"); + return; + } + send_error( + m_resource->handle, + error_state); + } + + void tizen_ws_shell::send_error(struct ::wl_resource *resource, uint32_t error_state) + { + tizen_ws_shell_send_error( + resource, + error_state); + } + + + tws_quickpanel::tws_quickpanel(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_quickpanel::tws_quickpanel(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_quickpanel::tws_quickpanel(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_quickpanel::tws_quickpanel() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_quickpanel::~tws_quickpanel() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_quickpanel::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_quickpanel::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_quickpanel::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_quickpanel::Resource *tws_quickpanel::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_quickpanel::Resource *tws_quickpanel::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_quickpanel::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_quickpanel_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_quickpanel::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_quickpanel::interface() + { + return &::tws_quickpanel_interface; + } + + tws_quickpanel::Resource *tws_quickpanel::tws_quickpanel_allocate() + { + return new Resource; + } + + void tws_quickpanel::tws_quickpanel_bind_resource(Resource *) + { + } + + void tws_quickpanel::tws_quickpanel_destroy_resource(Resource *) + { + } + + void tws_quickpanel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_quickpanel *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_quickpanel::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_quickpanel *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_quickpanel::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_quickpanel *that = resource->tws_quickpanel_object; + that->m_resource_map.erase(resource->client()); + that->tws_quickpanel_destroy_resource(resource); + delete resource; + } + + tws_quickpanel::Resource *tws_quickpanel::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_quickpanel_interface, version, id); + return bind(handle); + } + + tws_quickpanel::Resource *tws_quickpanel::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_quickpanel_allocate(); + resource->tws_quickpanel_object = this; + + wl_resource_set_implementation(handle, &m_tws_quickpanel_interface, resource, destroy_func); + resource->handle = handle; + tws_quickpanel_bind_resource(resource); + return resource; + } + tws_quickpanel::Resource *tws_quickpanel::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_quickpanel_interface, &m_tws_quickpanel_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_quickpanel_interface tws_quickpanel::m_tws_quickpanel_interface = { + tws_quickpanel::handle_release, + tws_quickpanel::handle_show, + tws_quickpanel::handle_hide, + tws_quickpanel::handle_enable, + tws_quickpanel::handle_disable, + tws_quickpanel::handle_state_get, + tws_quickpanel::handle_type_set, + tws_quickpanel::handle_scrollable_state_set + }; + + void tws_quickpanel::tws_quickpanel_release(Resource *) + { + } + + void tws_quickpanel::tws_quickpanel_show(Resource *) + { + } + + void tws_quickpanel::tws_quickpanel_hide(Resource *) + { + } + + void tws_quickpanel::tws_quickpanel_enable(Resource *) + { + } + + void tws_quickpanel::tws_quickpanel_disable(Resource *) + { + } + + void tws_quickpanel::tws_quickpanel_state_get(Resource *, int32_t ) + { + } + + void tws_quickpanel::tws_quickpanel_type_set(Resource *, uint32_t ) + { + } + + void tws_quickpanel::tws_quickpanel_scrollable_state_set(Resource *, int32_t ) + { + } + + + void tws_quickpanel::handle_release( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_quickpanel_object)->tws_quickpanel_release( + r); + } + + void tws_quickpanel::handle_show( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_quickpanel_object)->tws_quickpanel_show( + r); + } + + void tws_quickpanel::handle_hide( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_quickpanel_object)->tws_quickpanel_hide( + r); + } + + void tws_quickpanel::handle_enable( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_quickpanel_object)->tws_quickpanel_enable( + r); + } + + void tws_quickpanel::handle_disable( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_quickpanel_object)->tws_quickpanel_disable( + r); + } + + void tws_quickpanel::handle_state_get( + ::wl_client *client, + struct wl_resource *resource, + int32_t type) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_quickpanel_object)->tws_quickpanel_state_get( + r, + type); + } + + void tws_quickpanel::handle_type_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t type) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_quickpanel_object)->tws_quickpanel_type_set( + r, + type); + } + + void tws_quickpanel::handle_scrollable_state_set( + ::wl_client *client, + struct wl_resource *resource, + int32_t type) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_quickpanel_object)->tws_quickpanel_scrollable_state_set( + r, + type); + } + + void tws_quickpanel::send_state_get_done(int32_t type, int32_t value, uint32_t error_state) + { + DS_ASSERT_X(m_resource, "tws_quickpanel::state_get_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_quickpanel::state_get_done as it's not initialised"); + return; + } + send_state_get_done( + m_resource->handle, + type, + value, + error_state); + } + + void tws_quickpanel::send_state_get_done(struct ::wl_resource *resource, int32_t type, int32_t value, uint32_t error_state) + { + tws_quickpanel_send_state_get_done( + resource, + type, + value, + error_state); + } + + + void tws_quickpanel::send_state_changed(const std::string &states) + { + DS_ASSERT_X(m_resource, "tws_quickpanel::state_changed", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_quickpanel::state_changed as it's not initialised"); + return; + } + send_state_changed( + m_resource->handle, + states); + } + + void tws_quickpanel::send_state_changed(struct ::wl_resource *resource, const std::string &states) + { + struct wl_array states_data; + states_data.size = states.size(); + states_data.data = static_cast(const_cast(states.c_str())); + states_data.alloc = 0; + + tws_quickpanel_send_state_changed( + resource, + &states_data); + } + + + tws_tvsrv::tws_tvsrv(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_tvsrv::tws_tvsrv(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_tvsrv::tws_tvsrv(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_tvsrv::tws_tvsrv() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_tvsrv::~tws_tvsrv() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_tvsrv::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_tvsrv::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_tvsrv::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_tvsrv::Resource *tws_tvsrv::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_tvsrv::Resource *tws_tvsrv::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_tvsrv::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_tvsrv_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_tvsrv::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_tvsrv::interface() + { + return &::tws_tvsrv_interface; + } + + tws_tvsrv::Resource *tws_tvsrv::tws_tvsrv_allocate() + { + return new Resource; + } + + void tws_tvsrv::tws_tvsrv_bind_resource(Resource *) + { + } + + void tws_tvsrv::tws_tvsrv_destroy_resource(Resource *) + { + } + + void tws_tvsrv::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_tvsrv *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_tvsrv::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_tvsrv *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_tvsrv::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_tvsrv *that = resource->tws_tvsrv_object; + that->m_resource_map.erase(resource->client()); + that->tws_tvsrv_destroy_resource(resource); + delete resource; + } + + tws_tvsrv::Resource *tws_tvsrv::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_tvsrv_interface, version, id); + return bind(handle); + } + + tws_tvsrv::Resource *tws_tvsrv::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_tvsrv_allocate(); + resource->tws_tvsrv_object = this; + + wl_resource_set_implementation(handle, &m_tws_tvsrv_interface, resource, destroy_func); + resource->handle = handle; + tws_tvsrv_bind_resource(resource); + return resource; + } + tws_tvsrv::Resource *tws_tvsrv::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_tvsrv_interface, &m_tws_tvsrv_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_tvsrv_interface tws_tvsrv::m_tws_tvsrv_interface = { + tws_tvsrv::handle_release, + tws_tvsrv::handle_bind, + tws_tvsrv::handle_unbind + }; + + void tws_tvsrv::tws_tvsrv_release(Resource *) + { + } + + void tws_tvsrv::tws_tvsrv_bind(Resource *) + { + } + + void tws_tvsrv::tws_tvsrv_unbind(Resource *) + { + } + + + void tws_tvsrv::handle_release( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_tvsrv_object)->tws_tvsrv_release( + r); + } + + void tws_tvsrv::handle_bind( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_tvsrv_object)->tws_tvsrv_bind( + r); + } + + void tws_tvsrv::handle_unbind( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_tvsrv_object)->tws_tvsrv_unbind( + r); + } + + tws_region::tws_region(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_region::tws_region(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_region::tws_region(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_region::tws_region() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_region::~tws_region() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_region::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_region::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_region::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_region::Resource *tws_region::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_region::Resource *tws_region::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_region::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_region_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_region::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_region::interface() + { + return &::tws_region_interface; + } + + tws_region::Resource *tws_region::tws_region_allocate() + { + return new Resource; + } + + void tws_region::tws_region_bind_resource(Resource *) + { + } + + void tws_region::tws_region_destroy_resource(Resource *) + { + } + + void tws_region::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_region *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_region::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_region *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_region::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_region *that = resource->tws_region_object; + that->m_resource_map.erase(resource->client()); + that->tws_region_destroy_resource(resource); + delete resource; + } + + tws_region::Resource *tws_region::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_region_interface, version, id); + return bind(handle); + } + + tws_region::Resource *tws_region::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_region_allocate(); + resource->tws_region_object = this; + + wl_resource_set_implementation(handle, &m_tws_region_interface, resource, destroy_func); + resource->handle = handle; + tws_region_bind_resource(resource); + return resource; + } + tws_region::Resource *tws_region::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_region_interface, &m_tws_region_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_region_interface tws_region::m_tws_region_interface = { + tws_region::handle_destroy, + tws_region::handle_add, + tws_region::handle_subtract + }; + + void tws_region::tws_region_destroy(Resource *) + { + } + + void tws_region::tws_region_add(Resource *, int32_t , int32_t , int32_t , int32_t ) + { + } + + void tws_region::tws_region_subtract(Resource *, int32_t , int32_t , int32_t , int32_t ) + { + } + + + void tws_region::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_region_object)->tws_region_destroy( + r); + } + + void tws_region::handle_add( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t w, + int32_t h) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_region_object)->tws_region_add( + r, + x, + y, + w, + h); + } + + void tws_region::handle_subtract( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t w, + int32_t h) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_region_object)->tws_region_subtract( + r, + x, + y, + w, + h); + } + + tws_service::tws_service(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_service::tws_service(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_service::tws_service(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_service::tws_service() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_service::~tws_service() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_service::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_service::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_service::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_service::Resource *tws_service::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_service::Resource *tws_service::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_service::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_service_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_service::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_service::interface() + { + return &::tws_service_interface; + } + + tws_service::Resource *tws_service::tws_service_allocate() + { + return new Resource; + } + + void tws_service::tws_service_bind_resource(Resource *) + { + } + + void tws_service::tws_service_destroy_resource(Resource *) + { + } + + void tws_service::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_service *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_service::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_service *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_service::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_service *that = resource->tws_service_object; + that->m_resource_map.erase(resource->client()); + that->tws_service_destroy_resource(resource); + delete resource; + } + + tws_service::Resource *tws_service::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_interface, version, id); + return bind(handle); + } + + tws_service::Resource *tws_service::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_service_allocate(); + resource->tws_service_object = this; + + wl_resource_set_implementation(handle, &m_tws_service_interface, resource, destroy_func); + resource->handle = handle; + tws_service_bind_resource(resource); + return resource; + } + tws_service::Resource *tws_service::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_service_interface, &m_tws_service_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_service_interface tws_service::m_tws_service_interface = { + tws_service::handle_destroy, + tws_service::handle_region_set, + tws_service::handle_indicator_get, + tws_service::handle_quickpanel_get, + tws_service::handle_screensaver_manager_get, + tws_service::handle_screensaver_get, + tws_service::handle_cbhm_get, + tws_service::handle_softkey_get, + tws_service::handle_magnifier_get, + tws_service::handle_launcher_get + }; + + void tws_service::tws_service_destroy(Resource *) + { + } + + void tws_service::tws_service_region_set(Resource *, int32_t , int32_t , struct ::wl_resource *) + { + } + + void tws_service::tws_service_indicator_get(Resource *, uint32_t) + { + } + + void tws_service::tws_service_quickpanel_get(Resource *, uint32_t) + { + } + + void tws_service::tws_service_screensaver_manager_get(Resource *, uint32_t) + { + } + + void tws_service::tws_service_screensaver_get(Resource *, uint32_t) + { + } + + void tws_service::tws_service_cbhm_get(Resource *, uint32_t) + { + } + + void tws_service::tws_service_softkey_get(Resource *, uint32_t) + { + } + + void tws_service::tws_service_magnifier_get(Resource *, uint32_t) + { + } + + void tws_service::tws_service_launcher_get(Resource *, uint32_t) + { + } + + + void tws_service::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_destroy( + r); + } + + void tws_service::handle_region_set( + ::wl_client *client, + struct wl_resource *resource, + int32_t type, + int32_t angle, + struct ::wl_resource *region) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_region_set( + r, + type, + angle, + region); + } + + void tws_service::handle_indicator_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_indicator_get( + r, + id); + } + + void tws_service::handle_quickpanel_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_quickpanel_get( + r, + id); + } + + void tws_service::handle_screensaver_manager_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_screensaver_manager_get( + r, + id); + } + + void tws_service::handle_screensaver_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_screensaver_get( + r, + id); + } + + void tws_service::handle_cbhm_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_cbhm_get( + r, + id); + } + + void tws_service::handle_softkey_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_softkey_get( + r, + id); + } + + void tws_service::handle_magnifier_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_magnifier_get( + r, + id); + } + + void tws_service::handle_launcher_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_object)->tws_service_launcher_get( + r, + id); + } + + tws_service_indicator::tws_service_indicator(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_service_indicator::tws_service_indicator(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_service_indicator::tws_service_indicator(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_service_indicator::tws_service_indicator() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_service_indicator::~tws_service_indicator() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_service_indicator::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_service_indicator::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_service_indicator::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_service_indicator::Resource *tws_service_indicator::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_service_indicator::Resource *tws_service_indicator::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_service_indicator::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_service_indicator_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_service_indicator::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_service_indicator::interface() + { + return &::tws_service_indicator_interface; + } + + tws_service_indicator::Resource *tws_service_indicator::tws_service_indicator_allocate() + { + return new Resource; + } + + void tws_service_indicator::tws_service_indicator_bind_resource(Resource *) + { + } + + void tws_service_indicator::tws_service_indicator_destroy_resource(Resource *) + { + } + + void tws_service_indicator::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_service_indicator *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_service_indicator::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_service_indicator *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_service_indicator::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_service_indicator *that = resource->tws_service_indicator_object; + that->m_resource_map.erase(resource->client()); + that->tws_service_indicator_destroy_resource(resource); + delete resource; + } + + tws_service_indicator::Resource *tws_service_indicator::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_indicator_interface, version, id); + return bind(handle); + } + + tws_service_indicator::Resource *tws_service_indicator::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_service_indicator_allocate(); + resource->tws_service_indicator_object = this; + + wl_resource_set_implementation(handle, &m_tws_service_indicator_interface, resource, destroy_func); + resource->handle = handle; + tws_service_indicator_bind_resource(resource); + return resource; + } + tws_service_indicator::Resource *tws_service_indicator::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_service_indicator_interface, &m_tws_service_indicator_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_service_indicator_interface tws_service_indicator::m_tws_service_indicator_interface = { + tws_service_indicator::handle_destroy + }; + + void tws_service_indicator::tws_service_indicator_destroy(Resource *) + { + } + + + void tws_service_indicator::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_indicator_object)->tws_service_indicator_destroy( + r); + } + + void tws_service_indicator::send_property_change(int32_t angle, int32_t opacity) + { + DS_ASSERT_X(m_resource, "tws_service_indicator::property_change", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_indicator::property_change as it's not initialised"); + return; + } + send_property_change( + m_resource->handle, + angle, + opacity); + } + + void tws_service_indicator::send_property_change(struct ::wl_resource *resource, int32_t angle, int32_t opacity) + { + tws_service_indicator_send_property_change( + resource, + angle, + opacity); + } + + + tws_service_quickpanel::tws_service_quickpanel(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_service_quickpanel::tws_service_quickpanel(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_service_quickpanel::tws_service_quickpanel(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_service_quickpanel::tws_service_quickpanel() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_service_quickpanel::~tws_service_quickpanel() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_service_quickpanel::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_service_quickpanel::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_service_quickpanel::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_service_quickpanel::Resource *tws_service_quickpanel::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_service_quickpanel::Resource *tws_service_quickpanel::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_service_quickpanel::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_service_quickpanel_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_service_quickpanel::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_service_quickpanel::interface() + { + return &::tws_service_quickpanel_interface; + } + + tws_service_quickpanel::Resource *tws_service_quickpanel::tws_service_quickpanel_allocate() + { + return new Resource; + } + + void tws_service_quickpanel::tws_service_quickpanel_bind_resource(Resource *) + { + } + + void tws_service_quickpanel::tws_service_quickpanel_destroy_resource(Resource *) + { + } + + void tws_service_quickpanel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_service_quickpanel *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_service_quickpanel::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_service_quickpanel *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_service_quickpanel::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_service_quickpanel *that = resource->tws_service_quickpanel_object; + that->m_resource_map.erase(resource->client()); + that->tws_service_quickpanel_destroy_resource(resource); + delete resource; + } + + tws_service_quickpanel::Resource *tws_service_quickpanel::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_quickpanel_interface, version, id); + return bind(handle); + } + + tws_service_quickpanel::Resource *tws_service_quickpanel::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_service_quickpanel_allocate(); + resource->tws_service_quickpanel_object = this; + + wl_resource_set_implementation(handle, &m_tws_service_quickpanel_interface, resource, destroy_func); + resource->handle = handle; + tws_service_quickpanel_bind_resource(resource); + return resource; + } + tws_service_quickpanel::Resource *tws_service_quickpanel::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_service_quickpanel_interface, &m_tws_service_quickpanel_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_service_quickpanel_interface tws_service_quickpanel::m_tws_service_quickpanel_interface = { + tws_service_quickpanel::handle_destroy, + tws_service_quickpanel::handle_msg_send, + tws_service_quickpanel::handle_effect_type_set, + tws_service_quickpanel::handle_scroll_lock_set + }; + + void tws_service_quickpanel::tws_service_quickpanel_destroy(Resource *) + { + } + + void tws_service_quickpanel::tws_service_quickpanel_msg_send(Resource *, uint32_t ) + { + } + + void tws_service_quickpanel::tws_service_quickpanel_effect_type_set(Resource *, uint32_t ) + { + } + + void tws_service_quickpanel::tws_service_quickpanel_scroll_lock_set(Resource *, uint32_t ) + { + } + + + void tws_service_quickpanel::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_quickpanel_object)->tws_service_quickpanel_destroy( + r); + } + + void tws_service_quickpanel::handle_msg_send( + ::wl_client *client, + struct wl_resource *resource, + uint32_t msg) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_quickpanel_object)->tws_service_quickpanel_msg_send( + r, + msg); + } + + void tws_service_quickpanel::handle_effect_type_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t type) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_quickpanel_object)->tws_service_quickpanel_effect_type_set( + r, + type); + } + + void tws_service_quickpanel::handle_scroll_lock_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t lock) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_quickpanel_object)->tws_service_quickpanel_scroll_lock_set( + r, + lock); + } + + tws_service_screensaver_manager::tws_service_screensaver_manager(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_service_screensaver_manager::tws_service_screensaver_manager(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_service_screensaver_manager::tws_service_screensaver_manager(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_service_screensaver_manager::tws_service_screensaver_manager() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_service_screensaver_manager::~tws_service_screensaver_manager() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_service_screensaver_manager::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_service_screensaver_manager::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_service_screensaver_manager::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_service_screensaver_manager::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_service_screensaver_manager_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_service_screensaver_manager::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_service_screensaver_manager::interface() + { + return &::tws_service_screensaver_manager_interface; + } + + tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::tws_service_screensaver_manager_allocate() + { + return new Resource; + } + + void tws_service_screensaver_manager::tws_service_screensaver_manager_bind_resource(Resource *) + { + } + + void tws_service_screensaver_manager::tws_service_screensaver_manager_destroy_resource(Resource *) + { + } + + void tws_service_screensaver_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_service_screensaver_manager *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_service_screensaver_manager::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_service_screensaver_manager *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_service_screensaver_manager::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_service_screensaver_manager *that = resource->tws_service_screensaver_manager_object; + that->m_resource_map.erase(resource->client()); + that->tws_service_screensaver_manager_destroy_resource(resource); + delete resource; + } + + tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_screensaver_manager_interface, version, id); + return bind(handle); + } + + tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_service_screensaver_manager_allocate(); + resource->tws_service_screensaver_manager_object = this; + + wl_resource_set_implementation(handle, &m_tws_service_screensaver_manager_interface, resource, destroy_func); + resource->handle = handle; + tws_service_screensaver_manager_bind_resource(resource); + return resource; + } + tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_service_screensaver_manager_interface, &m_tws_service_screensaver_manager_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_service_screensaver_manager_interface tws_service_screensaver_manager::m_tws_service_screensaver_manager_interface = { + tws_service_screensaver_manager::handle_destroy, + tws_service_screensaver_manager::handle_enable, + tws_service_screensaver_manager::handle_disable, + tws_service_screensaver_manager::handle_idle_time_set, + tws_service_screensaver_manager::handle_state_get + }; + + void tws_service_screensaver_manager::tws_service_screensaver_manager_destroy(Resource *) + { + } + + void tws_service_screensaver_manager::tws_service_screensaver_manager_enable(Resource *) + { + } + + void tws_service_screensaver_manager::tws_service_screensaver_manager_disable(Resource *) + { + } + + void tws_service_screensaver_manager::tws_service_screensaver_manager_idle_time_set(Resource *, uint32_t ) + { + } + + void tws_service_screensaver_manager::tws_service_screensaver_manager_state_get(Resource *) + { + } + + + void tws_service_screensaver_manager::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_destroy( + r); + } + + void tws_service_screensaver_manager::handle_enable( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_enable( + r); + } + + void tws_service_screensaver_manager::handle_disable( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_disable( + r); + } + + void tws_service_screensaver_manager::handle_idle_time_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_idle_time_set( + r, + id); + } + + void tws_service_screensaver_manager::handle_state_get( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_state_get( + r); + } + + void tws_service_screensaver_manager::send_idle() + { + DS_ASSERT_X(m_resource, "tws_service_screensaver_manager::idle", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_screensaver_manager::idle as it's not initialised"); + return; + } + send_idle( + m_resource->handle); + } + + void tws_service_screensaver_manager::send_idle(struct ::wl_resource *resource) + { + tws_service_screensaver_manager_send_idle( + resource); + } + + + void tws_service_screensaver_manager::send_active() + { + DS_ASSERT_X(m_resource, "tws_service_screensaver_manager::active", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_screensaver_manager::active as it's not initialised"); + return; + } + send_active( + m_resource->handle); + } + + void tws_service_screensaver_manager::send_active(struct ::wl_resource *resource) + { + tws_service_screensaver_manager_send_active( + resource); + } + + + void tws_service_screensaver_manager::send_state_get_done(uint32_t state_type, uint32_t value, uint32_t error_state) + { + DS_ASSERT_X(m_resource, "tws_service_screensaver_manager::state_get_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_screensaver_manager::state_get_done as it's not initialised"); + return; + } + send_state_get_done( + m_resource->handle, + state_type, + value, + error_state); + } + + void tws_service_screensaver_manager::send_state_get_done(struct ::wl_resource *resource, uint32_t state_type, uint32_t value, uint32_t error_state) + { + tws_service_screensaver_manager_send_state_get_done( + resource, + state_type, + value, + error_state); + } + + + tws_service_screensaver::tws_service_screensaver(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_service_screensaver::tws_service_screensaver(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_service_screensaver::tws_service_screensaver(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_service_screensaver::tws_service_screensaver() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_service_screensaver::~tws_service_screensaver() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_service_screensaver::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_service_screensaver::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_service_screensaver::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_service_screensaver::Resource *tws_service_screensaver::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_service_screensaver::Resource *tws_service_screensaver::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_service_screensaver::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_service_screensaver_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_service_screensaver::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_service_screensaver::interface() + { + return &::tws_service_screensaver_interface; + } + + tws_service_screensaver::Resource *tws_service_screensaver::tws_service_screensaver_allocate() + { + return new Resource; + } + + void tws_service_screensaver::tws_service_screensaver_bind_resource(Resource *) + { + } + + void tws_service_screensaver::tws_service_screensaver_destroy_resource(Resource *) + { + } + + void tws_service_screensaver::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_service_screensaver *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_service_screensaver::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_service_screensaver *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_service_screensaver::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_service_screensaver *that = resource->tws_service_screensaver_object; + that->m_resource_map.erase(resource->client()); + that->tws_service_screensaver_destroy_resource(resource); + delete resource; + } + + tws_service_screensaver::Resource *tws_service_screensaver::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_screensaver_interface, version, id); + return bind(handle); + } + + tws_service_screensaver::Resource *tws_service_screensaver::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_service_screensaver_allocate(); + resource->tws_service_screensaver_object = this; + + wl_resource_set_implementation(handle, &m_tws_service_screensaver_interface, resource, destroy_func); + resource->handle = handle; + tws_service_screensaver_bind_resource(resource); + return resource; + } + tws_service_screensaver::Resource *tws_service_screensaver::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_service_screensaver_interface, &m_tws_service_screensaver_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_service_screensaver_interface tws_service_screensaver::m_tws_service_screensaver_interface = { + tws_service_screensaver::handle_release + }; + + void tws_service_screensaver::tws_service_screensaver_release(Resource *) + { + } + + + void tws_service_screensaver::handle_release( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_screensaver_object)->tws_service_screensaver_release( + r); + } + + tws_service_cbhm::tws_service_cbhm(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_service_cbhm::tws_service_cbhm(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_service_cbhm::tws_service_cbhm(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_service_cbhm::tws_service_cbhm() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_service_cbhm::~tws_service_cbhm() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_service_cbhm::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_service_cbhm::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_service_cbhm::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_service_cbhm::Resource *tws_service_cbhm::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_service_cbhm::Resource *tws_service_cbhm::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_service_cbhm::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_service_cbhm_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_service_cbhm::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_service_cbhm::interface() + { + return &::tws_service_cbhm_interface; + } + + tws_service_cbhm::Resource *tws_service_cbhm::tws_service_cbhm_allocate() + { + return new Resource; + } + + void tws_service_cbhm::tws_service_cbhm_bind_resource(Resource *) + { + } + + void tws_service_cbhm::tws_service_cbhm_destroy_resource(Resource *) + { + } + + void tws_service_cbhm::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_service_cbhm *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_service_cbhm::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_service_cbhm *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_service_cbhm::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_service_cbhm *that = resource->tws_service_cbhm_object; + that->m_resource_map.erase(resource->client()); + that->tws_service_cbhm_destroy_resource(resource); + delete resource; + } + + tws_service_cbhm::Resource *tws_service_cbhm::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_cbhm_interface, version, id); + return bind(handle); + } + + tws_service_cbhm::Resource *tws_service_cbhm::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_service_cbhm_allocate(); + resource->tws_service_cbhm_object = this; + + wl_resource_set_implementation(handle, &m_tws_service_cbhm_interface, resource, destroy_func); + resource->handle = handle; + tws_service_cbhm_bind_resource(resource); + return resource; + } + tws_service_cbhm::Resource *tws_service_cbhm::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_service_cbhm_interface, &m_tws_service_cbhm_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_service_cbhm_interface tws_service_cbhm::m_tws_service_cbhm_interface = { + tws_service_cbhm::handle_destroy, + tws_service_cbhm::handle_msg_send + }; + + void tws_service_cbhm::tws_service_cbhm_destroy(Resource *) + { + } + + void tws_service_cbhm::tws_service_cbhm_msg_send(Resource *, uint32_t ) + { + } + + + void tws_service_cbhm::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_cbhm_object)->tws_service_cbhm_destroy( + r); + } + + void tws_service_cbhm::handle_msg_send( + ::wl_client *client, + struct wl_resource *resource, + uint32_t msg) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_cbhm_object)->tws_service_cbhm_msg_send( + r, + msg); + } + + tws_dummy_extension::tws_dummy_extension(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_dummy_extension::tws_dummy_extension(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_dummy_extension::tws_dummy_extension(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_dummy_extension::tws_dummy_extension() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_dummy_extension::~tws_dummy_extension() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_dummy_extension::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_dummy_extension::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_dummy_extension::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_dummy_extension::Resource *tws_dummy_extension::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_dummy_extension::Resource *tws_dummy_extension::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_dummy_extension::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_dummy_extension_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_dummy_extension::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_dummy_extension::interface() + { + return &::tws_dummy_extension_interface; + } + + tws_dummy_extension::Resource *tws_dummy_extension::tws_dummy_extension_allocate() + { + return new Resource; + } + + void tws_dummy_extension::tws_dummy_extension_bind_resource(Resource *) + { + } + + void tws_dummy_extension::tws_dummy_extension_destroy_resource(Resource *) + { + } + + void tws_dummy_extension::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_dummy_extension *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_dummy_extension::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_dummy_extension *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_dummy_extension::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_dummy_extension *that = resource->tws_dummy_extension_object; + that->m_resource_map.erase(resource->client()); + that->tws_dummy_extension_destroy_resource(resource); + delete resource; + } + + tws_dummy_extension::Resource *tws_dummy_extension::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_dummy_extension_interface, version, id); + return bind(handle); + } + + tws_dummy_extension::Resource *tws_dummy_extension::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_dummy_extension_allocate(); + resource->tws_dummy_extension_object = this; + + wl_resource_set_implementation(handle, &m_tws_dummy_extension_interface, resource, destroy_func); + resource->handle = handle; + tws_dummy_extension_bind_resource(resource); + return resource; + } + tws_dummy_extension::Resource *tws_dummy_extension::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_dummy_extension_interface, &m_tws_dummy_extension_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_dummy_extension_interface tws_dummy_extension::m_tws_dummy_extension_interface = { + tws_dummy_extension::handle_destroy + }; + + void tws_dummy_extension::tws_dummy_extension_destroy(Resource *) + { + } + + + void tws_dummy_extension::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_dummy_extension_object)->tws_dummy_extension_destroy( + r); + } + + tws_service_softkey::tws_service_softkey(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_service_softkey::tws_service_softkey(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_service_softkey::tws_service_softkey(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_service_softkey::tws_service_softkey() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_service_softkey::~tws_service_softkey() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_service_softkey::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_service_softkey::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_service_softkey::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_service_softkey::Resource *tws_service_softkey::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_service_softkey::Resource *tws_service_softkey::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_service_softkey::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_service_softkey_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_service_softkey::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_service_softkey::interface() + { + return &::tws_service_softkey_interface; + } + + tws_service_softkey::Resource *tws_service_softkey::tws_service_softkey_allocate() + { + return new Resource; + } + + void tws_service_softkey::tws_service_softkey_bind_resource(Resource *) + { + } + + void tws_service_softkey::tws_service_softkey_destroy_resource(Resource *) + { + } + + void tws_service_softkey::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_service_softkey *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_service_softkey::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_service_softkey *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_service_softkey::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_service_softkey *that = resource->tws_service_softkey_object; + that->m_resource_map.erase(resource->client()); + that->tws_service_softkey_destroy_resource(resource); + delete resource; + } + + tws_service_softkey::Resource *tws_service_softkey::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_softkey_interface, version, id); + return bind(handle); + } + + tws_service_softkey::Resource *tws_service_softkey::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_service_softkey_allocate(); + resource->tws_service_softkey_object = this; + + wl_resource_set_implementation(handle, &m_tws_service_softkey_interface, resource, destroy_func); + resource->handle = handle; + tws_service_softkey_bind_resource(resource); + return resource; + } + tws_service_softkey::Resource *tws_service_softkey::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_service_softkey_interface, &m_tws_service_softkey_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_service_softkey_interface tws_service_softkey::m_tws_service_softkey_interface = { + tws_service_softkey::handle_destroy, + tws_service_softkey::handle_msg_send + }; + + void tws_service_softkey::tws_service_softkey_destroy(Resource *) + { + } + + void tws_service_softkey::tws_service_softkey_msg_send(Resource *, uint32_t ) + { + } + + + void tws_service_softkey::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_softkey_object)->tws_service_softkey_destroy( + r); + } + + void tws_service_softkey::handle_msg_send( + ::wl_client *client, + struct wl_resource *resource, + uint32_t msg) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_softkey_object)->tws_service_softkey_msg_send( + r, + msg); + } + + void tws_service_softkey::send_visible_change_request(int32_t show) + { + DS_ASSERT_X(m_resource, "tws_service_softkey::visible_change_request", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_softkey::visible_change_request as it's not initialised"); + return; + } + send_visible_change_request( + m_resource->handle, + show); + } + + void tws_service_softkey::send_visible_change_request(struct ::wl_resource *resource, int32_t show) + { + tws_service_softkey_send_visible_change_request( + resource, + show); + } + + + void tws_service_softkey::send_expand_change_request(int32_t expand) + { + DS_ASSERT_X(m_resource, "tws_service_softkey::expand_change_request", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_softkey::expand_change_request as it's not initialised"); + return; + } + send_expand_change_request( + m_resource->handle, + expand); + } + + void tws_service_softkey::send_expand_change_request(struct ::wl_resource *resource, int32_t expand) + { + tws_service_softkey_send_expand_change_request( + resource, + expand); + } + + + void tws_service_softkey::send_opacity_change_request(int32_t opacity) + { + DS_ASSERT_X(m_resource, "tws_service_softkey::opacity_change_request", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_softkey::opacity_change_request as it's not initialised"); + return; + } + send_opacity_change_request( + m_resource->handle, + opacity); + } + + void tws_service_softkey::send_opacity_change_request(struct ::wl_resource *resource, int32_t opacity) + { + tws_service_softkey_send_opacity_change_request( + resource, + opacity); + } + + + tws_softkey::tws_softkey(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_softkey::tws_softkey(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_softkey::tws_softkey(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_softkey::tws_softkey() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_softkey::~tws_softkey() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_softkey::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_softkey::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_softkey::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_softkey::Resource *tws_softkey::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_softkey::Resource *tws_softkey::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_softkey::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_softkey_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_softkey::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_softkey::interface() + { + return &::tws_softkey_interface; + } + + tws_softkey::Resource *tws_softkey::tws_softkey_allocate() + { + return new Resource; + } + + void tws_softkey::tws_softkey_bind_resource(Resource *) + { + } + + void tws_softkey::tws_softkey_destroy_resource(Resource *) + { + } + + void tws_softkey::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_softkey *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_softkey::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_softkey *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_softkey::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_softkey *that = resource->tws_softkey_object; + that->m_resource_map.erase(resource->client()); + that->tws_softkey_destroy_resource(resource); + delete resource; + } + + tws_softkey::Resource *tws_softkey::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_softkey_interface, version, id); + return bind(handle); + } + + tws_softkey::Resource *tws_softkey::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_softkey_allocate(); + resource->tws_softkey_object = this; + + wl_resource_set_implementation(handle, &m_tws_softkey_interface, resource, destroy_func); + resource->handle = handle; + tws_softkey_bind_resource(resource); + return resource; + } + tws_softkey::Resource *tws_softkey::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_softkey_interface, &m_tws_softkey_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_softkey_interface tws_softkey::m_tws_softkey_interface = { + tws_softkey::handle_release, + tws_softkey::handle_support_check, + tws_softkey::handle_show, + tws_softkey::handle_hide, + tws_softkey::handle_state_set, + tws_softkey::handle_state_get + }; + + void tws_softkey::tws_softkey_release(Resource *) + { + } + + void tws_softkey::tws_softkey_support_check(Resource *) + { + } + + void tws_softkey::tws_softkey_show(Resource *) + { + } + + void tws_softkey::tws_softkey_hide(Resource *) + { + } + + void tws_softkey::tws_softkey_state_set(Resource *) + { + } + + void tws_softkey::tws_softkey_state_get(Resource *) + { + } + + + void tws_softkey::handle_release( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_softkey_object)->tws_softkey_release( + r); + } + + void tws_softkey::handle_support_check( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_softkey_object)->tws_softkey_support_check( + r); + } + + void tws_softkey::handle_show( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_softkey_object)->tws_softkey_show( + r); + } + + void tws_softkey::handle_hide( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_softkey_object)->tws_softkey_hide( + r); + } + + void tws_softkey::handle_state_set( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_softkey_object)->tws_softkey_state_set( + r); + } + + void tws_softkey::handle_state_get( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_softkey_object)->tws_softkey_state_get( + r); + } + + void tws_softkey::send_support_check_done(int32_t support) + { + DS_ASSERT_X(m_resource, "tws_softkey::support_check_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_softkey::support_check_done as it's not initialised"); + return; + } + send_support_check_done( + m_resource->handle, + support); + } + + void tws_softkey::send_support_check_done(struct ::wl_resource *resource, int32_t support) + { + tws_softkey_send_support_check_done( + resource, + support); + } + + + void tws_softkey::send_state_get_done(int32_t type, int32_t value, uint32_t error_state) + { + DS_ASSERT_X(m_resource, "tws_softkey::state_get_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_softkey::state_get_done as it's not initialised"); + return; + } + send_state_get_done( + m_resource->handle, + type, + value, + error_state); + } + + void tws_softkey::send_state_get_done(struct ::wl_resource *resource, int32_t type, int32_t value, uint32_t error_state) + { + tws_softkey_send_state_get_done( + resource, + type, + value, + error_state); + } + + + tws_service_magnifier::tws_service_magnifier(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_service_magnifier::tws_service_magnifier(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_service_magnifier::tws_service_magnifier(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_service_magnifier::tws_service_magnifier() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_service_magnifier::~tws_service_magnifier() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_service_magnifier::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_service_magnifier::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_service_magnifier::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_service_magnifier::Resource *tws_service_magnifier::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_service_magnifier::Resource *tws_service_magnifier::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_service_magnifier::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_service_magnifier_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_service_magnifier::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_service_magnifier::interface() + { + return &::tws_service_magnifier_interface; + } + + tws_service_magnifier::Resource *tws_service_magnifier::tws_service_magnifier_allocate() + { + return new Resource; + } + + void tws_service_magnifier::tws_service_magnifier_bind_resource(Resource *) + { + } + + void tws_service_magnifier::tws_service_magnifier_destroy_resource(Resource *) + { + } + + void tws_service_magnifier::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_service_magnifier *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_service_magnifier::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_service_magnifier *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_service_magnifier::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_service_magnifier *that = resource->tws_service_magnifier_object; + that->m_resource_map.erase(resource->client()); + that->tws_service_magnifier_destroy_resource(resource); + delete resource; + } + + tws_service_magnifier::Resource *tws_service_magnifier::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_magnifier_interface, version, id); + return bind(handle); + } + + tws_service_magnifier::Resource *tws_service_magnifier::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_service_magnifier_allocate(); + resource->tws_service_magnifier_object = this; + + wl_resource_set_implementation(handle, &m_tws_service_magnifier_interface, resource, destroy_func); + resource->handle = handle; + tws_service_magnifier_bind_resource(resource); + return resource; + } + tws_service_magnifier::Resource *tws_service_magnifier::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_service_magnifier_interface, &m_tws_service_magnifier_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_service_magnifier_interface tws_service_magnifier::m_tws_service_magnifier_interface = { + tws_service_magnifier::handle_destroy, + tws_service_magnifier::handle_zoom_geometry_set, + tws_service_magnifier::handle_zoom_ratio_set, + tws_service_magnifier::handle_zoom_enable_set + }; + + void tws_service_magnifier::tws_service_magnifier_destroy(Resource *) + { + } + + void tws_service_magnifier::tws_service_magnifier_zoom_geometry_set(Resource *, uint32_t , int32_t , int32_t , uint32_t , uint32_t ) + { + } + + void tws_service_magnifier::tws_service_magnifier_zoom_ratio_set(Resource *, int32_t ) + { + } + + void tws_service_magnifier::tws_service_magnifier_zoom_enable_set(Resource *, int32_t ) + { + } + + + void tws_service_magnifier::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_magnifier_object)->tws_service_magnifier_destroy( + r); + } + + void tws_service_magnifier::handle_zoom_geometry_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t angle, + int32_t x, + int32_t y, + uint32_t w, + uint32_t h) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_magnifier_object)->tws_service_magnifier_zoom_geometry_set( + r, + angle, + x, + y, + w, + h); + } + + void tws_service_magnifier::handle_zoom_ratio_set( + ::wl_client *client, + struct wl_resource *resource, + int32_t ratio) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_magnifier_object)->tws_service_magnifier_zoom_ratio_set( + r, + ratio); + } + + void tws_service_magnifier::handle_zoom_enable_set( + ::wl_client *client, + struct wl_resource *resource, + int32_t enable) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_magnifier_object)->tws_service_magnifier_zoom_enable_set( + r, + enable); + } + + tws_service_launcher::tws_service_launcher(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_service_launcher::tws_service_launcher(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_service_launcher::tws_service_launcher(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_service_launcher::tws_service_launcher() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_service_launcher::~tws_service_launcher() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_service_launcher::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_service_launcher::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_service_launcher::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_service_launcher::Resource *tws_service_launcher::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_service_launcher::Resource *tws_service_launcher::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_service_launcher::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_service_launcher_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_service_launcher::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_service_launcher::interface() + { + return &::tws_service_launcher_interface; + } + + tws_service_launcher::Resource *tws_service_launcher::tws_service_launcher_allocate() + { + return new Resource; + } + + void tws_service_launcher::tws_service_launcher_bind_resource(Resource *) + { + } + + void tws_service_launcher::tws_service_launcher_destroy_resource(Resource *) + { + } + + void tws_service_launcher::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_service_launcher *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_service_launcher::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_service_launcher *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_service_launcher::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_service_launcher *that = resource->tws_service_launcher_object; + that->m_resource_map.erase(resource->client()); + that->tws_service_launcher_destroy_resource(resource); + delete resource; + } + + tws_service_launcher::Resource *tws_service_launcher::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_launcher_interface, version, id); + return bind(handle); + } + + tws_service_launcher::Resource *tws_service_launcher::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_service_launcher_allocate(); + resource->tws_service_launcher_object = this; + + wl_resource_set_implementation(handle, &m_tws_service_launcher_interface, resource, destroy_func); + resource->handle = handle; + tws_service_launcher_bind_resource(resource); + return resource; + } + tws_service_launcher::Resource *tws_service_launcher::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_service_launcher_interface, &m_tws_service_launcher_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_service_launcher_interface tws_service_launcher::m_tws_service_launcher_interface = { + tws_service_launcher::handle_destroy, + tws_service_launcher::handle_launch, + tws_service_launcher::handle_launch_with_shared_widget, + tws_service_launcher::handle_launching, + tws_service_launcher::handle_launch_done, + tws_service_launcher::handle_launch_cancel + }; + + void tws_service_launcher::tws_service_launcher_destroy(Resource *) + { + } + + void tws_service_launcher::tws_service_launcher_launch(Resource *, const std::string &, const std::string &, int32_t , uint32_t ) + { + } + + void tws_service_launcher::tws_service_launcher_launch_with_shared_widget(Resource *, const std::string &, const std::string &, int32_t , uint32_t ) + { + } + + void tws_service_launcher::tws_service_launcher_launching(Resource *, uint32_t ) + { + } + + void tws_service_launcher::tws_service_launcher_launch_done(Resource *, uint32_t ) + { + } + + void tws_service_launcher::tws_service_launcher_launch_cancel(Resource *, uint32_t ) + { + } + + + void tws_service_launcher::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_launcher_object)->tws_service_launcher_destroy( + r); + } + + void tws_service_launcher::handle_launch( + ::wl_client *client, + struct wl_resource *resource, + const char *app_id, + const char *instance_id, + int32_t pid, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_launcher_object)->tws_service_launcher_launch( + r, + std::string(app_id), + std::string(instance_id), + pid, + serial); + } + + void tws_service_launcher::handle_launch_with_shared_widget( + ::wl_client *client, + struct wl_resource *resource, + const char *app_id, + const char *instance_id, + int32_t pid, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_launcher_object)->tws_service_launcher_launch_with_shared_widget( + r, + std::string(app_id), + std::string(instance_id), + pid, + serial); + } + + void tws_service_launcher::handle_launching( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_launcher_object)->tws_service_launcher_launching( + r, + serial); + } + + void tws_service_launcher::handle_launch_done( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_launcher_object)->tws_service_launcher_launch_done( + r, + serial); + } + + void tws_service_launcher::handle_launch_cancel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_service_launcher_object)->tws_service_launcher_launch_cancel( + r, + serial); + } + + void tws_service_launcher::send_prepare(uint32_t target_type, const std::string &target_info, uint32_t direction, int32_t x, int32_t y, const std::string &shared_widget_info, uint32_t serial) + { + DS_ASSERT_X(m_resource, "tws_service_launcher::prepare", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_launcher::prepare as it's not initialised"); + return; + } + send_prepare( + m_resource->handle, + target_type, + target_info, + direction, + x, + y, + shared_widget_info, + serial); + } + + void tws_service_launcher::send_prepare(struct ::wl_resource *resource, uint32_t target_type, const std::string &target_info, uint32_t direction, int32_t x, int32_t y, const std::string &shared_widget_info, uint32_t serial) + { + struct wl_array target_info_data; + target_info_data.size = target_info.size(); + target_info_data.data = static_cast(const_cast(target_info.c_str())); + target_info_data.alloc = 0; + + tws_service_launcher_send_prepare( + resource, + target_type, + &target_info_data, + direction, + x, + y, + shared_widget_info.c_str(), + serial); + } + + + void tws_service_launcher::send_stop(uint32_t serial) + { + DS_ASSERT_X(m_resource, "tws_service_launcher::stop", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_launcher::stop as it's not initialised"); + return; + } + send_stop( + m_resource->handle, + serial); + } + + void tws_service_launcher::send_stop(struct ::wl_resource *resource, uint32_t serial) + { + tws_service_launcher_send_stop( + resource, + serial); + } + + + void tws_service_launcher::send_error(uint32_t code, uint32_t serial) + { + DS_ASSERT_X(m_resource, "tws_service_launcher::error", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_launcher::error as it's not initialised"); + return; + } + send_error( + m_resource->handle, + code, + serial); + } + + void tws_service_launcher::send_error(struct ::wl_resource *resource, uint32_t code, uint32_t serial) + { + tws_service_launcher_send_error( + resource, + code, + serial); + } + + + void tws_service_launcher::send_cleanup(uint32_t serial) + { + DS_ASSERT_X(m_resource, "tws_service_launcher::cleanup", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_service_launcher::cleanup as it's not initialised"); + return; + } + send_cleanup( + m_resource->handle, + serial); + } + + void tws_service_launcher::send_cleanup(struct ::wl_resource *resource, uint32_t serial) + { + tws_service_launcher_send_cleanup( + resource, + serial); + } + + + tws_shared_widget_launch::tws_shared_widget_launch(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + tws_shared_widget_launch::tws_shared_widget_launch(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + tws_shared_widget_launch::tws_shared_widget_launch(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + tws_shared_widget_launch::tws_shared_widget_launch() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + tws_shared_widget_launch::~tws_shared_widget_launch() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tws_shared_widget_launch::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tws_shared_widget_launch::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void tws_shared_widget_launch::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tws_shared_widget_launch::Resource *tws_shared_widget_launch::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tws_shared_widget_launch::Resource *tws_shared_widget_launch::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tws_shared_widget_launch::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tws_shared_widget_launch_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tws_shared_widget_launch::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tws_shared_widget_launch::interface() + { + return &::tws_shared_widget_launch_interface; + } + + tws_shared_widget_launch::Resource *tws_shared_widget_launch::tws_shared_widget_launch_allocate() + { + return new Resource; + } + + void tws_shared_widget_launch::tws_shared_widget_launch_bind_resource(Resource *) + { + } + + void tws_shared_widget_launch::tws_shared_widget_launch_destroy_resource(Resource *) + { + } + + void tws_shared_widget_launch::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tws_shared_widget_launch *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tws_shared_widget_launch::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tws_shared_widget_launch *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tws_shared_widget_launch::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tws_shared_widget_launch *that = resource->tws_shared_widget_launch_object; + that->m_resource_map.erase(resource->client()); + that->tws_shared_widget_launch_destroy_resource(resource); + delete resource; + } + + tws_shared_widget_launch::Resource *tws_shared_widget_launch::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tws_shared_widget_launch_interface, version, id); + return bind(handle); + } + + tws_shared_widget_launch::Resource *tws_shared_widget_launch::bind(struct ::wl_resource *handle) + { + Resource *resource = tws_shared_widget_launch_allocate(); + resource->tws_shared_widget_launch_object = this; + + wl_resource_set_implementation(handle, &m_tws_shared_widget_launch_interface, resource, destroy_func); + resource->handle = handle; + tws_shared_widget_launch_bind_resource(resource); + return resource; + } + tws_shared_widget_launch::Resource *tws_shared_widget_launch::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tws_shared_widget_launch_interface, &m_tws_shared_widget_launch_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tws_shared_widget_launch_interface tws_shared_widget_launch::m_tws_shared_widget_launch_interface = { + tws_shared_widget_launch::handle_release, + tws_shared_widget_launch::handle_prepare_shared_widget_done + }; + + void tws_shared_widget_launch::tws_shared_widget_launch_release(Resource *) + { + } + + void tws_shared_widget_launch::tws_shared_widget_launch_prepare_shared_widget_done(Resource *, const std::string &, uint32_t , uint32_t ) + { + } + + + void tws_shared_widget_launch::handle_release( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_shared_widget_launch_object)->tws_shared_widget_launch_release( + r); + } + + void tws_shared_widget_launch::handle_prepare_shared_widget_done( + ::wl_client *client, + struct wl_resource *resource, + const char *shared_widget_info, + uint32_t state, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tws_shared_widget_launch_object)->tws_shared_widget_launch_prepare_shared_widget_done( + r, + std::string(shared_widget_info), + state, + serial); + } + + void tws_shared_widget_launch::send_prepare_shared_widget(uint32_t state, uint32_t serial) + { + DS_ASSERT_X(m_resource, "tws_shared_widget_launch::prepare_shared_widget", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tws_shared_widget_launch::prepare_shared_widget as it's not initialised"); + return; + } + send_prepare_shared_widget( + m_resource->handle, + state, + serial); + } + + void tws_shared_widget_launch::send_prepare_shared_widget(struct ::wl_resource *resource, uint32_t state, uint32_t serial) + { + tws_shared_widget_launch_send_prepare_shared_widget( + resource, + state, + serial); + } + +} + diff --git a/src/DSWaylandServer/dswayland-server-tzsh.h b/src/DSWaylandServer/dswayland-server-tzsh.h new file mode 100644 index 0000000..11ef986 --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-tzsh.h @@ -0,0 +1,1760 @@ +/* Protocol XML file : wayland-extension/tzsh.xml */ + +#ifndef __DS_TIZEN_WS_SHELL_PROTOCOL_H__ +#define __DS_TIZEN_WS_SHELL_PROTOCOL_H__ + +#include "wayland-server-core.h" +#include "tizen-ws-shell-server-protocol.h" +#include +#include +#include +#include +#include + +#ifndef WAYLAND_VERSION_CHECK +#define WAYLAND_VERSION_CHECK(major, minor, micro) \ + ((WAYLAND_VERSION_MAJOR > (major)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) +#endif + + +namespace DSWaylandServer { + class tizen_ws_shell + { + public: + tizen_ws_shell(struct ::wl_client *client, int id, int version); + tizen_ws_shell(struct ::wl_display *display, int version); + tizen_ws_shell(struct ::wl_resource *resource); + tizen_ws_shell(); + + virtual ~tizen_ws_shell(); + + class Resource + { + public: + Resource() : tizen_ws_shell_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tizen_ws_shell *tizen_ws_shell_object; + tizen_ws_shell *object() { return tizen_ws_shell_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_none = 0, // no error. succeed. + error_out_of_memory = 1, // server is not have enought memory. + error_invalid_parameter = 2, // given request have invalid parameter. + error_permission_denied = 3, // client is not have right permission. + error_no_service = 4, // there is no service to support request + error_not_supported = 5, // given request is not supported + }; + + void send_service_register(const std::string &name); + void send_service_register(struct ::wl_resource *resource, const std::string &name); + void send_service_unregister(const std::string &name); + void send_service_unregister(struct ::wl_resource *resource, const std::string &name); + void send_error(uint32_t error_state); + void send_error(struct ::wl_resource *resource, uint32_t error_state); + + protected: + virtual Resource *tizen_ws_shell_allocate(); + + virtual void tizen_ws_shell_bind_resource(Resource *resource); + virtual void tizen_ws_shell_destroy_resource(Resource *resource); + + virtual void tizen_ws_shell_destroy(Resource *resource); + virtual void tizen_ws_shell_service_create(Resource *resource, uint32_t id, uint32_t win, const std::string &name); + virtual void tizen_ws_shell_region_create(Resource *resource, uint32_t id); + virtual void tizen_ws_shell_quickpanel_get(Resource *resource, uint32_t id, uint32_t win); + virtual void tizen_ws_shell_tvsrv_get(Resource *resource, uint32_t id, uint32_t win); + virtual void tizen_ws_shell_extension_get(Resource *resource, uint32_t id, const std::string &name); + virtual void tizen_ws_shell_softkey_get(Resource *resource, uint32_t id, uint32_t win); + virtual void tizen_ws_shell_shared_widget_launch_get(Resource *resource, uint32_t id, uint32_t win); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tizen_ws_shell_interface m_tizen_ws_shell_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_service_create( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win, + const char *name); + static void handle_region_create( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_quickpanel_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win); + static void handle_tvsrv_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win); + static void handle_extension_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + const char *name); + static void handle_softkey_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win); + static void handle_shared_widget_launch_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t win); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tizen_ws_shell *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_quickpanel + { + public: + tws_quickpanel(struct ::wl_client *client, int id, int version); + tws_quickpanel(struct ::wl_display *display, int version); + tws_quickpanel(struct ::wl_resource *resource); + tws_quickpanel(); + + virtual ~tws_quickpanel(); + + class Resource + { + public: + Resource() : tws_quickpanel_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_quickpanel *tws_quickpanel_object; + tws_quickpanel *object() { return tws_quickpanel_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_request_rejected = 0, // given request is denied + }; + + enum state_type { + state_type_unknown = 0, + state_type_visibility = 1, + state_type_scrollable = 2, + state_type_orientation = 3, + }; + + enum state_value { + state_value_unknown = 0, + state_value_visible_show = 1, + state_value_visible_hide = 2, + state_value_scrollable_set = 3, + state_value_scrollable_unset = 4, + state_value_orientation_0 = 5, + state_value_orientation_90 = 6, + state_value_orientation_180 = 7, + state_value_orientation_270 = 8, + state_value_scrollable_retain = 9, + }; + + enum type_value { + type_value_unknown = 0, + type_value_system_default = 1, + type_value_context_menu = 2, + }; + + void send_state_get_done(int32_t type, int32_t value, uint32_t error_state); + void send_state_get_done(struct ::wl_resource *resource, int32_t type, int32_t value, uint32_t error_state); + void send_state_changed(const std::string &states); + void send_state_changed(struct ::wl_resource *resource, const std::string &states); + + protected: + virtual Resource *tws_quickpanel_allocate(); + + virtual void tws_quickpanel_bind_resource(Resource *resource); + virtual void tws_quickpanel_destroy_resource(Resource *resource); + + virtual void tws_quickpanel_release(Resource *resource); + virtual void tws_quickpanel_show(Resource *resource); + virtual void tws_quickpanel_hide(Resource *resource); + virtual void tws_quickpanel_enable(Resource *resource); + virtual void tws_quickpanel_disable(Resource *resource); + virtual void tws_quickpanel_state_get(Resource *resource, int32_t type); + virtual void tws_quickpanel_type_set(Resource *resource, uint32_t type); + virtual void tws_quickpanel_scrollable_state_set(Resource *resource, int32_t type); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_quickpanel_interface m_tws_quickpanel_interface; + + static void handle_release( + ::wl_client *client, + struct wl_resource *resource); + static void handle_show( + ::wl_client *client, + struct wl_resource *resource); + static void handle_hide( + ::wl_client *client, + struct wl_resource *resource); + static void handle_enable( + ::wl_client *client, + struct wl_resource *resource); + static void handle_disable( + ::wl_client *client, + struct wl_resource *resource); + static void handle_state_get( + ::wl_client *client, + struct wl_resource *resource, + int32_t type); + static void handle_type_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t type); + static void handle_scrollable_state_set( + ::wl_client *client, + struct wl_resource *resource, + int32_t type); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_quickpanel *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_tvsrv + { + public: + tws_tvsrv(struct ::wl_client *client, int id, int version); + tws_tvsrv(struct ::wl_display *display, int version); + tws_tvsrv(struct ::wl_resource *resource); + tws_tvsrv(); + + virtual ~tws_tvsrv(); + + class Resource + { + public: + Resource() : tws_tvsrv_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_tvsrv *tws_tvsrv_object; + tws_tvsrv *object() { return tws_tvsrv_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_request_rejected = 0, // given request is denied + }; + + protected: + virtual Resource *tws_tvsrv_allocate(); + + virtual void tws_tvsrv_bind_resource(Resource *resource); + virtual void tws_tvsrv_destroy_resource(Resource *resource); + + virtual void tws_tvsrv_release(Resource *resource); + virtual void tws_tvsrv_bind(Resource *resource); + virtual void tws_tvsrv_unbind(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_tvsrv_interface m_tws_tvsrv_interface; + + static void handle_release( + ::wl_client *client, + struct wl_resource *resource); + static void handle_bind( + ::wl_client *client, + struct wl_resource *resource); + static void handle_unbind( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_tvsrv *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_region + { + public: + tws_region(struct ::wl_client *client, int id, int version); + tws_region(struct ::wl_display *display, int version); + tws_region(struct ::wl_resource *resource); + tws_region(); + + virtual ~tws_region(); + + class Resource + { + public: + Resource() : tws_region_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_region *tws_region_object; + tws_region *object() { return tws_region_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + protected: + virtual Resource *tws_region_allocate(); + + virtual void tws_region_bind_resource(Resource *resource); + virtual void tws_region_destroy_resource(Resource *resource); + + virtual void tws_region_destroy(Resource *resource); + virtual void tws_region_add(Resource *resource, int32_t x, int32_t y, int32_t w, int32_t h); + virtual void tws_region_subtract(Resource *resource, int32_t x, int32_t y, int32_t w, int32_t h); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_region_interface m_tws_region_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_add( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t w, + int32_t h); + static void handle_subtract( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t w, + int32_t h); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_region *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_service + { + public: + tws_service(struct ::wl_client *client, int id, int version); + tws_service(struct ::wl_display *display, int version); + tws_service(struct ::wl_resource *resource); + tws_service(); + + virtual ~tws_service(); + + class Resource + { + public: + Resource() : tws_service_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_service *tws_service_object; + tws_service *object() { return tws_service_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum region_type { + region_type_handler = 0, + region_type_content = 1, + }; + + protected: + virtual Resource *tws_service_allocate(); + + virtual void tws_service_bind_resource(Resource *resource); + virtual void tws_service_destroy_resource(Resource *resource); + + virtual void tws_service_destroy(Resource *resource); + virtual void tws_service_region_set(Resource *resource, int32_t type, int32_t angle, struct ::wl_resource *region); + virtual void tws_service_indicator_get(Resource *resource, uint32_t id); + virtual void tws_service_quickpanel_get(Resource *resource, uint32_t id); + virtual void tws_service_screensaver_manager_get(Resource *resource, uint32_t id); + virtual void tws_service_screensaver_get(Resource *resource, uint32_t id); + virtual void tws_service_cbhm_get(Resource *resource, uint32_t id); + virtual void tws_service_softkey_get(Resource *resource, uint32_t id); + virtual void tws_service_magnifier_get(Resource *resource, uint32_t id); + virtual void tws_service_launcher_get(Resource *resource, uint32_t id); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_service_interface m_tws_service_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_region_set( + ::wl_client *client, + struct wl_resource *resource, + int32_t type, + int32_t angle, + struct ::wl_resource *region); + static void handle_indicator_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_quickpanel_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_screensaver_manager_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_screensaver_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_cbhm_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_softkey_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_magnifier_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_launcher_get( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_service *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_service_indicator + { + public: + tws_service_indicator(struct ::wl_client *client, int id, int version); + tws_service_indicator(struct ::wl_display *display, int version); + tws_service_indicator(struct ::wl_resource *resource); + tws_service_indicator(); + + virtual ~tws_service_indicator(); + + class Resource + { + public: + Resource() : tws_service_indicator_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_service_indicator *tws_service_indicator_object; + tws_service_indicator *object() { return tws_service_indicator_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + void send_property_change(int32_t angle, int32_t opacity); + void send_property_change(struct ::wl_resource *resource, int32_t angle, int32_t opacity); + + protected: + virtual Resource *tws_service_indicator_allocate(); + + virtual void tws_service_indicator_bind_resource(Resource *resource); + virtual void tws_service_indicator_destroy_resource(Resource *resource); + + virtual void tws_service_indicator_destroy(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_service_indicator_interface m_tws_service_indicator_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_service_indicator *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_service_quickpanel + { + public: + tws_service_quickpanel(struct ::wl_client *client, int id, int version); + tws_service_quickpanel(struct ::wl_display *display, int version); + tws_service_quickpanel(struct ::wl_resource *resource); + tws_service_quickpanel(); + + virtual ~tws_service_quickpanel(); + + class Resource + { + public: + Resource() : tws_service_quickpanel_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_service_quickpanel *tws_service_quickpanel_object; + tws_service_quickpanel *object() { return tws_service_quickpanel_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum effect_type { + effect_type_swipe = 0, + effect_type_move = 1, + effect_type_app_custom = 2, + }; + + enum msg { + msg_show = 0, + msg_hide = 1, + }; + + protected: + virtual Resource *tws_service_quickpanel_allocate(); + + virtual void tws_service_quickpanel_bind_resource(Resource *resource); + virtual void tws_service_quickpanel_destroy_resource(Resource *resource); + + virtual void tws_service_quickpanel_destroy(Resource *resource); + virtual void tws_service_quickpanel_msg_send(Resource *resource, uint32_t msg); + virtual void tws_service_quickpanel_effect_type_set(Resource *resource, uint32_t type); + virtual void tws_service_quickpanel_scroll_lock_set(Resource *resource, uint32_t lock); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_service_quickpanel_interface m_tws_service_quickpanel_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_msg_send( + ::wl_client *client, + struct wl_resource *resource, + uint32_t msg); + static void handle_effect_type_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t type); + static void handle_scroll_lock_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t lock); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_service_quickpanel *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_service_screensaver_manager + { + public: + tws_service_screensaver_manager(struct ::wl_client *client, int id, int version); + tws_service_screensaver_manager(struct ::wl_display *display, int version); + tws_service_screensaver_manager(struct ::wl_resource *resource); + tws_service_screensaver_manager(); + + virtual ~tws_service_screensaver_manager(); + + class Resource + { + public: + Resource() : tws_service_screensaver_manager_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_service_screensaver_manager *tws_service_screensaver_manager_object; + tws_service_screensaver_manager *object() { return tws_service_screensaver_manager_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum state_type { + state_type_unknown = 0, + state_type_enable = 1, + state_type_active = 2, + state_type_idle_timeout = 3, + }; + + void send_idle(); + void send_idle(struct ::wl_resource *resource); + void send_active(); + void send_active(struct ::wl_resource *resource); + void send_state_get_done(uint32_t state_type, uint32_t value, uint32_t error_state); + void send_state_get_done(struct ::wl_resource *resource, uint32_t state_type, uint32_t value, uint32_t error_state); + + protected: + virtual Resource *tws_service_screensaver_manager_allocate(); + + virtual void tws_service_screensaver_manager_bind_resource(Resource *resource); + virtual void tws_service_screensaver_manager_destroy_resource(Resource *resource); + + virtual void tws_service_screensaver_manager_destroy(Resource *resource); + virtual void tws_service_screensaver_manager_enable(Resource *resource); + virtual void tws_service_screensaver_manager_disable(Resource *resource); + virtual void tws_service_screensaver_manager_idle_time_set(Resource *resource, uint32_t id); + virtual void tws_service_screensaver_manager_state_get(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_service_screensaver_manager_interface m_tws_service_screensaver_manager_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_enable( + ::wl_client *client, + struct wl_resource *resource); + static void handle_disable( + ::wl_client *client, + struct wl_resource *resource); + static void handle_idle_time_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_state_get( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_service_screensaver_manager *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_service_screensaver + { + public: + tws_service_screensaver(struct ::wl_client *client, int id, int version); + tws_service_screensaver(struct ::wl_display *display, int version); + tws_service_screensaver(struct ::wl_resource *resource); + tws_service_screensaver(); + + virtual ~tws_service_screensaver(); + + class Resource + { + public: + Resource() : tws_service_screensaver_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_service_screensaver *tws_service_screensaver_object; + tws_service_screensaver *object() { return tws_service_screensaver_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_request_rejected = 0, // given request is denied + }; + + protected: + virtual Resource *tws_service_screensaver_allocate(); + + virtual void tws_service_screensaver_bind_resource(Resource *resource); + virtual void tws_service_screensaver_destroy_resource(Resource *resource); + + virtual void tws_service_screensaver_release(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_service_screensaver_interface m_tws_service_screensaver_interface; + + static void handle_release( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_service_screensaver *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_service_cbhm + { + public: + tws_service_cbhm(struct ::wl_client *client, int id, int version); + tws_service_cbhm(struct ::wl_display *display, int version); + tws_service_cbhm(struct ::wl_resource *resource); + tws_service_cbhm(); + + virtual ~tws_service_cbhm(); + + class Resource + { + public: + Resource() : tws_service_cbhm_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_service_cbhm *tws_service_cbhm_object; + tws_service_cbhm *object() { return tws_service_cbhm_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum msg { + msg_show = 0, + msg_hide = 1, + msg_data_selected = 2, + }; + + protected: + virtual Resource *tws_service_cbhm_allocate(); + + virtual void tws_service_cbhm_bind_resource(Resource *resource); + virtual void tws_service_cbhm_destroy_resource(Resource *resource); + + virtual void tws_service_cbhm_destroy(Resource *resource); + virtual void tws_service_cbhm_msg_send(Resource *resource, uint32_t msg); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_service_cbhm_interface m_tws_service_cbhm_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_msg_send( + ::wl_client *client, + struct wl_resource *resource, + uint32_t msg); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_service_cbhm *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_dummy_extension + { + public: + tws_dummy_extension(struct ::wl_client *client, int id, int version); + tws_dummy_extension(struct ::wl_display *display, int version); + tws_dummy_extension(struct ::wl_resource *resource); + tws_dummy_extension(); + + virtual ~tws_dummy_extension(); + + class Resource + { + public: + Resource() : tws_dummy_extension_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_dummy_extension *tws_dummy_extension_object; + tws_dummy_extension *object() { return tws_dummy_extension_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + protected: + virtual Resource *tws_dummy_extension_allocate(); + + virtual void tws_dummy_extension_bind_resource(Resource *resource); + virtual void tws_dummy_extension_destroy_resource(Resource *resource); + + virtual void tws_dummy_extension_destroy(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_dummy_extension_interface m_tws_dummy_extension_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_dummy_extension *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_service_softkey + { + public: + tws_service_softkey(struct ::wl_client *client, int id, int version); + tws_service_softkey(struct ::wl_display *display, int version); + tws_service_softkey(struct ::wl_resource *resource); + tws_service_softkey(); + + virtual ~tws_service_softkey(); + + class Resource + { + public: + Resource() : tws_service_softkey_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_service_softkey *tws_service_softkey_object; + tws_service_softkey *object() { return tws_service_softkey_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum msg { + msg_show = 0, + msg_hide = 1, + }; + + void send_visible_change_request(int32_t show); + void send_visible_change_request(struct ::wl_resource *resource, int32_t show); + void send_expand_change_request(int32_t expand); + void send_expand_change_request(struct ::wl_resource *resource, int32_t expand); + void send_opacity_change_request(int32_t opacity); + void send_opacity_change_request(struct ::wl_resource *resource, int32_t opacity); + + protected: + virtual Resource *tws_service_softkey_allocate(); + + virtual void tws_service_softkey_bind_resource(Resource *resource); + virtual void tws_service_softkey_destroy_resource(Resource *resource); + + virtual void tws_service_softkey_destroy(Resource *resource); + virtual void tws_service_softkey_msg_send(Resource *resource, uint32_t msg); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_service_softkey_interface m_tws_service_softkey_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_msg_send( + ::wl_client *client, + struct wl_resource *resource, + uint32_t msg); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_service_softkey *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_softkey + { + public: + tws_softkey(struct ::wl_client *client, int id, int version); + tws_softkey(struct ::wl_display *display, int version); + tws_softkey(struct ::wl_resource *resource); + tws_softkey(); + + virtual ~tws_softkey(); + + class Resource + { + public: + Resource() : tws_softkey_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_softkey *tws_softkey_object; + tws_softkey *object() { return tws_softkey_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_none = 0, // no error. succeed. + error_request_rejected = 1, // given request is denied + error_no_service = 2, // there is no softkey + }; + + enum state { + state_visible = 0, + state_expand = 1, + state_opacity = 2, + }; + + enum state_visible { + state_visible_unknown = 0, + state_visible_show = 1, + state_visible_hide = 2, + }; + + enum state_expand { + state_expand_unknown = 10, + state_expand_on = 11, + state_expand_off = 12, + }; + + enum state_opacity { + state_opacity_unknown = 20, + state_opacity_opaque = 21, + state_opacity_transparent = 22, + }; + + void send_support_check_done(int32_t support); + void send_support_check_done(struct ::wl_resource *resource, int32_t support); + void send_state_get_done(int32_t type, int32_t value, uint32_t error_state); + void send_state_get_done(struct ::wl_resource *resource, int32_t type, int32_t value, uint32_t error_state); + + protected: + virtual Resource *tws_softkey_allocate(); + + virtual void tws_softkey_bind_resource(Resource *resource); + virtual void tws_softkey_destroy_resource(Resource *resource); + + virtual void tws_softkey_release(Resource *resource); + virtual void tws_softkey_support_check(Resource *resource); + virtual void tws_softkey_show(Resource *resource); + virtual void tws_softkey_hide(Resource *resource); + virtual void tws_softkey_state_set(Resource *resource); + virtual void tws_softkey_state_get(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_softkey_interface m_tws_softkey_interface; + + static void handle_release( + ::wl_client *client, + struct wl_resource *resource); + static void handle_support_check( + ::wl_client *client, + struct wl_resource *resource); + static void handle_show( + ::wl_client *client, + struct wl_resource *resource); + static void handle_hide( + ::wl_client *client, + struct wl_resource *resource); + static void handle_state_set( + ::wl_client *client, + struct wl_resource *resource); + static void handle_state_get( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_softkey *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_service_magnifier + { + public: + tws_service_magnifier(struct ::wl_client *client, int id, int version); + tws_service_magnifier(struct ::wl_display *display, int version); + tws_service_magnifier(struct ::wl_resource *resource); + tws_service_magnifier(); + + virtual ~tws_service_magnifier(); + + class Resource + { + public: + Resource() : tws_service_magnifier_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_service_magnifier *tws_service_magnifier_object; + tws_service_magnifier *object() { return tws_service_magnifier_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum zoom_ratio { + zoom_ratio_100 = 100, + zoom_ratio_110 = 110, + zoom_ratio_120 = 120, + zoom_ratio_130 = 130, + zoom_ratio_140 = 140, + zoom_ratio_150 = 150, + zoom_ratio_160 = 160, + zoom_ratio_170 = 170, + zoom_ratio_180 = 180, + zoom_ratio_190 = 190, + zoom_ratio_200 = 200, + }; + + protected: + virtual Resource *tws_service_magnifier_allocate(); + + virtual void tws_service_magnifier_bind_resource(Resource *resource); + virtual void tws_service_magnifier_destroy_resource(Resource *resource); + + virtual void tws_service_magnifier_destroy(Resource *resource); + virtual void tws_service_magnifier_zoom_geometry_set(Resource *resource, uint32_t angle, int32_t x, int32_t y, uint32_t w, uint32_t h); + virtual void tws_service_magnifier_zoom_ratio_set(Resource *resource, int32_t ratio); + virtual void tws_service_magnifier_zoom_enable_set(Resource *resource, int32_t enable); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_service_magnifier_interface m_tws_service_magnifier_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_zoom_geometry_set( + ::wl_client *client, + struct wl_resource *resource, + uint32_t angle, + int32_t x, + int32_t y, + uint32_t w, + uint32_t h); + static void handle_zoom_ratio_set( + ::wl_client *client, + struct wl_resource *resource, + int32_t ratio); + static void handle_zoom_enable_set( + ::wl_client *client, + struct wl_resource *resource, + int32_t enable); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_service_magnifier *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_service_launcher + { + public: + tws_service_launcher(struct ::wl_client *client, int id, int version); + tws_service_launcher(struct ::wl_display *display, int version); + tws_service_launcher(struct ::wl_resource *resource); + tws_service_launcher(); + + virtual ~tws_service_launcher(); + + class Resource + { + public: + Resource() : tws_service_launcher_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_service_launcher *tws_service_launcher_object; + tws_service_launcher *object() { return tws_service_launcher_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum direction { + direction_forward = 0, // direction of transition to a launched app from a launcher + direction_backward = 1, // direction of transition to a launcher from a launched app + }; + + enum target_type { + target_type_remote_surface = 0, // can get target via remote surface + target_type_edje = 1, // can get target via edj file + target_type_image = 2, // can get target via image file + }; + + enum error { + error_none = 0, // no error. + error_disqualified = 1, // client is disqualified and any requests will be ignored from now. + error_wrong_request = 2, + }; + + void send_prepare(uint32_t target_type, const std::string &target_info, uint32_t direction, int32_t x, int32_t y, const std::string &shared_widget_info, uint32_t serial); + void send_prepare(struct ::wl_resource *resource, uint32_t target_type, const std::string &target_info, uint32_t direction, int32_t x, int32_t y, const std::string &shared_widget_info, uint32_t serial); + void send_stop(uint32_t serial); + void send_stop(struct ::wl_resource *resource, uint32_t serial); + void send_error(uint32_t code, uint32_t serial); + void send_error(struct ::wl_resource *resource, uint32_t code, uint32_t serial); + void send_cleanup(uint32_t serial); + void send_cleanup(struct ::wl_resource *resource, uint32_t serial); + + protected: + virtual Resource *tws_service_launcher_allocate(); + + virtual void tws_service_launcher_bind_resource(Resource *resource); + virtual void tws_service_launcher_destroy_resource(Resource *resource); + + virtual void tws_service_launcher_destroy(Resource *resource); + virtual void tws_service_launcher_launch(Resource *resource, const std::string &app_id, const std::string &instance_id, int32_t pid, uint32_t serial); + virtual void tws_service_launcher_launch_with_shared_widget(Resource *resource, const std::string &app_id, const std::string &instance_id, int32_t pid, uint32_t serial); + virtual void tws_service_launcher_launching(Resource *resource, uint32_t serial); + virtual void tws_service_launcher_launch_done(Resource *resource, uint32_t serial); + virtual void tws_service_launcher_launch_cancel(Resource *resource, uint32_t serial); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_service_launcher_interface m_tws_service_launcher_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_launch( + ::wl_client *client, + struct wl_resource *resource, + const char *app_id, + const char *instance_id, + int32_t pid, + uint32_t serial); + static void handle_launch_with_shared_widget( + ::wl_client *client, + struct wl_resource *resource, + const char *app_id, + const char *instance_id, + int32_t pid, + uint32_t serial); + static void handle_launching( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial); + static void handle_launch_done( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial); + static void handle_launch_cancel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_service_launcher *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tws_shared_widget_launch + { + public: + tws_shared_widget_launch(struct ::wl_client *client, int id, int version); + tws_shared_widget_launch(struct ::wl_display *display, int version); + tws_shared_widget_launch(struct ::wl_resource *resource); + tws_shared_widget_launch(); + + virtual ~tws_shared_widget_launch(); + + class Resource + { + public: + Resource() : tws_shared_widget_launch_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tws_shared_widget_launch *tws_shared_widget_launch_object; + tws_shared_widget_launch *object() { return tws_shared_widget_launch_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum prepare_state { + prepare_state_widget_show = 0, + prepare_state_widget_hide = 1, + }; + + void send_prepare_shared_widget(uint32_t state, uint32_t serial); + void send_prepare_shared_widget(struct ::wl_resource *resource, uint32_t state, uint32_t serial); + + protected: + virtual Resource *tws_shared_widget_launch_allocate(); + + virtual void tws_shared_widget_launch_bind_resource(Resource *resource); + virtual void tws_shared_widget_launch_destroy_resource(Resource *resource); + + virtual void tws_shared_widget_launch_release(Resource *resource); + virtual void tws_shared_widget_launch_prepare_shared_widget_done(Resource *resource, const std::string &shared_widget_info, uint32_t state, uint32_t serial); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tws_shared_widget_launch_interface m_tws_shared_widget_launch_interface; + + static void handle_release( + ::wl_client *client, + struct wl_resource *resource); + static void handle_prepare_shared_widget_done( + ::wl_client *client, + struct wl_resource *resource, + const char *shared_widget_info, + uint32_t state, + uint32_t serial); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tws_shared_widget_launch *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; +} + +#endif diff --git a/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.cpp b/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.cpp new file mode 100644 index 0000000..d19b9b1 --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.cpp @@ -0,0 +1,1471 @@ +/* Protocol XML file : wayland-extension/xdg-shell-unstable-v6.xml */ + +#include "dswayland-server-xdg-shell-unstable-v6.h" + +#ifndef DS_UNLIKELY +#define DS_UNLIKELY(X) X +#endif +#ifndef DS_UNUSED +#define DS_UNUSED(X) X +#endif +#ifndef DS_ASSERT +#define DS_ASSERT(COND) assert(COND) +#endif +#ifndef DS_ASSERT_X +#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ + do {\ + if (! (COND))\ + {\ + fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ + assert(COND);\ + }\ + } while(0) +#endif +#ifndef WRN +#define WRN(X...) fprintf(stderr,##X) +#endif + +namespace DSWaylandServer { + zxdg_shell_v6::zxdg_shell_v6(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + zxdg_shell_v6::zxdg_shell_v6(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + zxdg_shell_v6::zxdg_shell_v6(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + zxdg_shell_v6::zxdg_shell_v6() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + zxdg_shell_v6::~zxdg_shell_v6() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zxdg_shell_v6::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zxdg_shell_v6::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void zxdg_shell_v6::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zxdg_shell_v6::Resource *zxdg_shell_v6::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zxdg_shell_v6::Resource *zxdg_shell_v6::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zxdg_shell_v6::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zxdg_shell_v6_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zxdg_shell_v6::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zxdg_shell_v6::interface() + { + return &::zxdg_shell_v6_interface; + } + + zxdg_shell_v6::Resource *zxdg_shell_v6::zxdg_shell_v6_allocate() + { + return new Resource; + } + + void zxdg_shell_v6::zxdg_shell_v6_bind_resource(Resource *) + { + } + + void zxdg_shell_v6::zxdg_shell_v6_destroy_resource(Resource *) + { + } + + void zxdg_shell_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zxdg_shell_v6 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zxdg_shell_v6::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zxdg_shell_v6 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zxdg_shell_v6::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zxdg_shell_v6 *that = resource->zxdg_shell_v6_object; + that->m_resource_map.erase(resource->client()); + that->zxdg_shell_v6_destroy_resource(resource); + delete resource; + } + + zxdg_shell_v6::Resource *zxdg_shell_v6::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_shell_v6_interface, version, id); + return bind(handle); + } + + zxdg_shell_v6::Resource *zxdg_shell_v6::bind(struct ::wl_resource *handle) + { + Resource *resource = zxdg_shell_v6_allocate(); + resource->zxdg_shell_v6_object = this; + + wl_resource_set_implementation(handle, &m_zxdg_shell_v6_interface, resource, destroy_func); + resource->handle = handle; + zxdg_shell_v6_bind_resource(resource); + return resource; + } + zxdg_shell_v6::Resource *zxdg_shell_v6::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zxdg_shell_v6_interface, &m_zxdg_shell_v6_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::zxdg_shell_v6_interface zxdg_shell_v6::m_zxdg_shell_v6_interface = { + zxdg_shell_v6::handle_destroy, + zxdg_shell_v6::handle_create_positioner, + zxdg_shell_v6::handle_get_xdg_surface, + zxdg_shell_v6::handle_pong + }; + + void zxdg_shell_v6::zxdg_shell_v6_destroy(Resource *) + { + } + + void zxdg_shell_v6::zxdg_shell_v6_create_positioner(Resource *, uint32_t) + { + } + + void zxdg_shell_v6::zxdg_shell_v6_get_xdg_surface(Resource *, uint32_t, struct ::wl_resource *) + { + } + + void zxdg_shell_v6::zxdg_shell_v6_pong(Resource *, uint32_t ) + { + } + + + void zxdg_shell_v6::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_shell_v6_object)->zxdg_shell_v6_destroy( + r); + } + + void zxdg_shell_v6::handle_create_positioner( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_shell_v6_object)->zxdg_shell_v6_create_positioner( + r, + id); + } + + void zxdg_shell_v6::handle_get_xdg_surface( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *surface) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_shell_v6_object)->zxdg_shell_v6_get_xdg_surface( + r, + id, + surface); + } + + void zxdg_shell_v6::handle_pong( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_shell_v6_object)->zxdg_shell_v6_pong( + r, + serial); + } + + void zxdg_shell_v6::send_ping(uint32_t serial) + { + DS_ASSERT_X(m_resource, "zxdg_shell_v6::ping", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zxdg_shell_v6::ping as it's not initialised"); + return; + } + send_ping( + m_resource->handle, + serial); + } + + void zxdg_shell_v6::send_ping(struct ::wl_resource *resource, uint32_t serial) + { + zxdg_shell_v6_send_ping( + resource, + serial); + } + + + zxdg_positioner_v6::zxdg_positioner_v6(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + zxdg_positioner_v6::zxdg_positioner_v6(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + zxdg_positioner_v6::zxdg_positioner_v6(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + zxdg_positioner_v6::zxdg_positioner_v6() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + zxdg_positioner_v6::~zxdg_positioner_v6() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zxdg_positioner_v6::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zxdg_positioner_v6::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void zxdg_positioner_v6::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zxdg_positioner_v6::Resource *zxdg_positioner_v6::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zxdg_positioner_v6::Resource *zxdg_positioner_v6::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zxdg_positioner_v6::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zxdg_positioner_v6_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zxdg_positioner_v6::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zxdg_positioner_v6::interface() + { + return &::zxdg_positioner_v6_interface; + } + + zxdg_positioner_v6::Resource *zxdg_positioner_v6::zxdg_positioner_v6_allocate() + { + return new Resource; + } + + void zxdg_positioner_v6::zxdg_positioner_v6_bind_resource(Resource *) + { + } + + void zxdg_positioner_v6::zxdg_positioner_v6_destroy_resource(Resource *) + { + } + + void zxdg_positioner_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zxdg_positioner_v6 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zxdg_positioner_v6::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zxdg_positioner_v6 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zxdg_positioner_v6::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zxdg_positioner_v6 *that = resource->zxdg_positioner_v6_object; + that->m_resource_map.erase(resource->client()); + that->zxdg_positioner_v6_destroy_resource(resource); + delete resource; + } + + zxdg_positioner_v6::Resource *zxdg_positioner_v6::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_positioner_v6_interface, version, id); + return bind(handle); + } + + zxdg_positioner_v6::Resource *zxdg_positioner_v6::bind(struct ::wl_resource *handle) + { + Resource *resource = zxdg_positioner_v6_allocate(); + resource->zxdg_positioner_v6_object = this; + + wl_resource_set_implementation(handle, &m_zxdg_positioner_v6_interface, resource, destroy_func); + resource->handle = handle; + zxdg_positioner_v6_bind_resource(resource); + return resource; + } + zxdg_positioner_v6::Resource *zxdg_positioner_v6::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zxdg_positioner_v6_interface, &m_zxdg_positioner_v6_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::zxdg_positioner_v6_interface zxdg_positioner_v6::m_zxdg_positioner_v6_interface = { + zxdg_positioner_v6::handle_destroy, + zxdg_positioner_v6::handle_set_size, + zxdg_positioner_v6::handle_set_anchor_rect, + zxdg_positioner_v6::handle_set_anchor, + zxdg_positioner_v6::handle_set_gravity, + zxdg_positioner_v6::handle_set_constraint_adjustment, + zxdg_positioner_v6::handle_set_offset + }; + + void zxdg_positioner_v6::zxdg_positioner_v6_destroy(Resource *) + { + } + + void zxdg_positioner_v6::zxdg_positioner_v6_set_size(Resource *, int32_t , int32_t ) + { + } + + void zxdg_positioner_v6::zxdg_positioner_v6_set_anchor_rect(Resource *, int32_t , int32_t , int32_t , int32_t ) + { + } + + void zxdg_positioner_v6::zxdg_positioner_v6_set_anchor(Resource *, uint32_t ) + { + } + + void zxdg_positioner_v6::zxdg_positioner_v6_set_gravity(Resource *, uint32_t ) + { + } + + void zxdg_positioner_v6::zxdg_positioner_v6_set_constraint_adjustment(Resource *, uint32_t ) + { + } + + void zxdg_positioner_v6::zxdg_positioner_v6_set_offset(Resource *, int32_t , int32_t ) + { + } + + + void zxdg_positioner_v6::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_destroy( + r); + } + + void zxdg_positioner_v6::handle_set_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_size( + r, + width, + height); + } + + void zxdg_positioner_v6::handle_set_anchor_rect( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_anchor_rect( + r, + x, + y, + width, + height); + } + + void zxdg_positioner_v6::handle_set_anchor( + ::wl_client *client, + struct wl_resource *resource, + uint32_t anchor) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_anchor( + r, + anchor); + } + + void zxdg_positioner_v6::handle_set_gravity( + ::wl_client *client, + struct wl_resource *resource, + uint32_t gravity) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_gravity( + r, + gravity); + } + + void zxdg_positioner_v6::handle_set_constraint_adjustment( + ::wl_client *client, + struct wl_resource *resource, + uint32_t constraint_adjustment) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_constraint_adjustment( + r, + constraint_adjustment); + } + + void zxdg_positioner_v6::handle_set_offset( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_offset( + r, + x, + y); + } + + zxdg_surface_v6::zxdg_surface_v6(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + zxdg_surface_v6::zxdg_surface_v6(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + zxdg_surface_v6::zxdg_surface_v6(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + zxdg_surface_v6::zxdg_surface_v6() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + zxdg_surface_v6::~zxdg_surface_v6() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zxdg_surface_v6::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zxdg_surface_v6::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void zxdg_surface_v6::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zxdg_surface_v6::Resource *zxdg_surface_v6::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zxdg_surface_v6::Resource *zxdg_surface_v6::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zxdg_surface_v6::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zxdg_surface_v6_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zxdg_surface_v6::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zxdg_surface_v6::interface() + { + return &::zxdg_surface_v6_interface; + } + + zxdg_surface_v6::Resource *zxdg_surface_v6::zxdg_surface_v6_allocate() + { + return new Resource; + } + + void zxdg_surface_v6::zxdg_surface_v6_bind_resource(Resource *) + { + } + + void zxdg_surface_v6::zxdg_surface_v6_destroy_resource(Resource *) + { + } + + void zxdg_surface_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zxdg_surface_v6 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zxdg_surface_v6::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zxdg_surface_v6 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zxdg_surface_v6::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zxdg_surface_v6 *that = resource->zxdg_surface_v6_object; + that->m_resource_map.erase(resource->client()); + that->zxdg_surface_v6_destroy_resource(resource); + delete resource; + } + + zxdg_surface_v6::Resource *zxdg_surface_v6::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_surface_v6_interface, version, id); + return bind(handle); + } + + zxdg_surface_v6::Resource *zxdg_surface_v6::bind(struct ::wl_resource *handle) + { + Resource *resource = zxdg_surface_v6_allocate(); + resource->zxdg_surface_v6_object = this; + + wl_resource_set_implementation(handle, &m_zxdg_surface_v6_interface, resource, destroy_func); + resource->handle = handle; + zxdg_surface_v6_bind_resource(resource); + return resource; + } + zxdg_surface_v6::Resource *zxdg_surface_v6::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zxdg_surface_v6_interface, &m_zxdg_surface_v6_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::zxdg_surface_v6_interface zxdg_surface_v6::m_zxdg_surface_v6_interface = { + zxdg_surface_v6::handle_destroy, + zxdg_surface_v6::handle_get_toplevel, + zxdg_surface_v6::handle_get_popup, + zxdg_surface_v6::handle_set_window_geometry, + zxdg_surface_v6::handle_ack_configure + }; + + void zxdg_surface_v6::zxdg_surface_v6_destroy(Resource *) + { + } + + void zxdg_surface_v6::zxdg_surface_v6_get_toplevel(Resource *, uint32_t) + { + } + + void zxdg_surface_v6::zxdg_surface_v6_get_popup(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *) + { + } + + void zxdg_surface_v6::zxdg_surface_v6_set_window_geometry(Resource *, int32_t , int32_t , int32_t , int32_t ) + { + } + + void zxdg_surface_v6::zxdg_surface_v6_ack_configure(Resource *, uint32_t ) + { + } + + + void zxdg_surface_v6::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_destroy( + r); + } + + void zxdg_surface_v6::handle_get_toplevel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_get_toplevel( + r, + id); + } + + void zxdg_surface_v6::handle_get_popup( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *parent, + struct ::wl_resource *positioner) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_get_popup( + r, + id, + parent, + positioner); + } + + void zxdg_surface_v6::handle_set_window_geometry( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_set_window_geometry( + r, + x, + y, + width, + height); + } + + void zxdg_surface_v6::handle_ack_configure( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_ack_configure( + r, + serial); + } + + void zxdg_surface_v6::send_configure(uint32_t serial) + { + DS_ASSERT_X(m_resource, "zxdg_surface_v6::configure", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zxdg_surface_v6::configure as it's not initialised"); + return; + } + send_configure( + m_resource->handle, + serial); + } + + void zxdg_surface_v6::send_configure(struct ::wl_resource *resource, uint32_t serial) + { + zxdg_surface_v6_send_configure( + resource, + serial); + } + + + zxdg_toplevel_v6::zxdg_toplevel_v6(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + zxdg_toplevel_v6::zxdg_toplevel_v6(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + zxdg_toplevel_v6::zxdg_toplevel_v6(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + zxdg_toplevel_v6::zxdg_toplevel_v6() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + zxdg_toplevel_v6::~zxdg_toplevel_v6() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zxdg_toplevel_v6::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zxdg_toplevel_v6::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void zxdg_toplevel_v6::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zxdg_toplevel_v6::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zxdg_toplevel_v6_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zxdg_toplevel_v6::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zxdg_toplevel_v6::interface() + { + return &::zxdg_toplevel_v6_interface; + } + + zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::zxdg_toplevel_v6_allocate() + { + return new Resource; + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_bind_resource(Resource *) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_destroy_resource(Resource *) + { + } + + void zxdg_toplevel_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zxdg_toplevel_v6 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zxdg_toplevel_v6::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zxdg_toplevel_v6 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zxdg_toplevel_v6::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zxdg_toplevel_v6 *that = resource->zxdg_toplevel_v6_object; + that->m_resource_map.erase(resource->client()); + that->zxdg_toplevel_v6_destroy_resource(resource); + delete resource; + } + + zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_toplevel_v6_interface, version, id); + return bind(handle); + } + + zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::bind(struct ::wl_resource *handle) + { + Resource *resource = zxdg_toplevel_v6_allocate(); + resource->zxdg_toplevel_v6_object = this; + + wl_resource_set_implementation(handle, &m_zxdg_toplevel_v6_interface, resource, destroy_func); + resource->handle = handle; + zxdg_toplevel_v6_bind_resource(resource); + return resource; + } + zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zxdg_toplevel_v6_interface, &m_zxdg_toplevel_v6_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::zxdg_toplevel_v6_interface zxdg_toplevel_v6::m_zxdg_toplevel_v6_interface = { + zxdg_toplevel_v6::handle_destroy, + zxdg_toplevel_v6::handle_set_parent, + zxdg_toplevel_v6::handle_set_title, + zxdg_toplevel_v6::handle_set_app_id, + zxdg_toplevel_v6::handle_show_window_menu, + zxdg_toplevel_v6::handle_move, + zxdg_toplevel_v6::handle_resize, + zxdg_toplevel_v6::handle_set_max_size, + zxdg_toplevel_v6::handle_set_min_size, + zxdg_toplevel_v6::handle_set_maximized, + zxdg_toplevel_v6::handle_unset_maximized, + zxdg_toplevel_v6::handle_set_fullscreen, + zxdg_toplevel_v6::handle_unset_fullscreen, + zxdg_toplevel_v6::handle_set_minimized + }; + + void zxdg_toplevel_v6::zxdg_toplevel_v6_destroy(Resource *) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_set_parent(Resource *, struct ::wl_resource *) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_set_title(Resource *, const std::string &) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_set_app_id(Resource *, const std::string &) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_show_window_menu(Resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t ) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_move(Resource *, struct ::wl_resource *, uint32_t ) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_resize(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_set_max_size(Resource *, int32_t , int32_t ) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_set_min_size(Resource *, int32_t , int32_t ) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_set_maximized(Resource *) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_unset_maximized(Resource *) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_set_fullscreen(Resource *, struct ::wl_resource *) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_unset_fullscreen(Resource *) + { + } + + void zxdg_toplevel_v6::zxdg_toplevel_v6_set_minimized(Resource *) + { + } + + + void zxdg_toplevel_v6::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_destroy( + r); + } + + void zxdg_toplevel_v6::handle_set_parent( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *parent) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_parent( + r, + parent); + } + + void zxdg_toplevel_v6::handle_set_title( + ::wl_client *client, + struct wl_resource *resource, + const char *title) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_title( + r, + std::string(title)); + } + + void zxdg_toplevel_v6::handle_set_app_id( + ::wl_client *client, + struct wl_resource *resource, + const char *app_id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_app_id( + r, + std::string(app_id)); + } + + void zxdg_toplevel_v6::handle_show_window_menu( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial, + int32_t x, + int32_t y) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_show_window_menu( + r, + seat, + serial, + x, + y); + } + + void zxdg_toplevel_v6::handle_move( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_move( + r, + seat, + serial); + } + + void zxdg_toplevel_v6::handle_resize( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial, + uint32_t edges) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_resize( + r, + seat, + serial, + edges); + } + + void zxdg_toplevel_v6::handle_set_max_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_max_size( + r, + width, + height); + } + + void zxdg_toplevel_v6::handle_set_min_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_min_size( + r, + width, + height); + } + + void zxdg_toplevel_v6::handle_set_maximized( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_maximized( + r); + } + + void zxdg_toplevel_v6::handle_unset_maximized( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_unset_maximized( + r); + } + + void zxdg_toplevel_v6::handle_set_fullscreen( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *output) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_fullscreen( + r, + output); + } + + void zxdg_toplevel_v6::handle_unset_fullscreen( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_unset_fullscreen( + r); + } + + void zxdg_toplevel_v6::handle_set_minimized( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_minimized( + r); + } + + void zxdg_toplevel_v6::send_configure(int32_t width, int32_t height, const std::string &states) + { + DS_ASSERT_X(m_resource, "zxdg_toplevel_v6::configure", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zxdg_toplevel_v6::configure as it's not initialised"); + return; + } + send_configure( + m_resource->handle, + width, + height, + states); + } + + void zxdg_toplevel_v6::send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const std::string &states) + { + struct wl_array states_data; + states_data.size = states.size(); + states_data.data = static_cast(const_cast(states.c_str())); + states_data.alloc = 0; + + zxdg_toplevel_v6_send_configure( + resource, + width, + height, + &states_data); + } + + + void zxdg_toplevel_v6::send_close() + { + DS_ASSERT_X(m_resource, "zxdg_toplevel_v6::close", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zxdg_toplevel_v6::close as it's not initialised"); + return; + } + send_close( + m_resource->handle); + } + + void zxdg_toplevel_v6::send_close(struct ::wl_resource *resource) + { + zxdg_toplevel_v6_send_close( + resource); + } + + + zxdg_popup_v6::zxdg_popup_v6(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + zxdg_popup_v6::zxdg_popup_v6(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + zxdg_popup_v6::zxdg_popup_v6(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + zxdg_popup_v6::zxdg_popup_v6() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + zxdg_popup_v6::~zxdg_popup_v6() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zxdg_popup_v6::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zxdg_popup_v6::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void zxdg_popup_v6::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zxdg_popup_v6::Resource *zxdg_popup_v6::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zxdg_popup_v6::Resource *zxdg_popup_v6::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zxdg_popup_v6::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zxdg_popup_v6_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zxdg_popup_v6::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zxdg_popup_v6::interface() + { + return &::zxdg_popup_v6_interface; + } + + zxdg_popup_v6::Resource *zxdg_popup_v6::zxdg_popup_v6_allocate() + { + return new Resource; + } + + void zxdg_popup_v6::zxdg_popup_v6_bind_resource(Resource *) + { + } + + void zxdg_popup_v6::zxdg_popup_v6_destroy_resource(Resource *) + { + } + + void zxdg_popup_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zxdg_popup_v6 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zxdg_popup_v6::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zxdg_popup_v6 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zxdg_popup_v6::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zxdg_popup_v6 *that = resource->zxdg_popup_v6_object; + that->m_resource_map.erase(resource->client()); + that->zxdg_popup_v6_destroy_resource(resource); + delete resource; + } + + zxdg_popup_v6::Resource *zxdg_popup_v6::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_popup_v6_interface, version, id); + return bind(handle); + } + + zxdg_popup_v6::Resource *zxdg_popup_v6::bind(struct ::wl_resource *handle) + { + Resource *resource = zxdg_popup_v6_allocate(); + resource->zxdg_popup_v6_object = this; + + wl_resource_set_implementation(handle, &m_zxdg_popup_v6_interface, resource, destroy_func); + resource->handle = handle; + zxdg_popup_v6_bind_resource(resource); + return resource; + } + zxdg_popup_v6::Resource *zxdg_popup_v6::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zxdg_popup_v6_interface, &m_zxdg_popup_v6_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::zxdg_popup_v6_interface zxdg_popup_v6::m_zxdg_popup_v6_interface = { + zxdg_popup_v6::handle_destroy, + zxdg_popup_v6::handle_grab + }; + + void zxdg_popup_v6::zxdg_popup_v6_destroy(Resource *) + { + } + + void zxdg_popup_v6::zxdg_popup_v6_grab(Resource *, struct ::wl_resource *, uint32_t ) + { + } + + + void zxdg_popup_v6::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_popup_v6_object)->zxdg_popup_v6_destroy( + r); + } + + void zxdg_popup_v6::handle_grab( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zxdg_popup_v6_object)->zxdg_popup_v6_grab( + r, + seat, + serial); + } + + void zxdg_popup_v6::send_configure(int32_t x, int32_t y, int32_t width, int32_t height) + { + DS_ASSERT_X(m_resource, "zxdg_popup_v6::configure", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zxdg_popup_v6::configure as it's not initialised"); + return; + } + send_configure( + m_resource->handle, + x, + y, + width, + height); + } + + void zxdg_popup_v6::send_configure(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) + { + zxdg_popup_v6_send_configure( + resource, + x, + y, + width, + height); + } + + + void zxdg_popup_v6::send_popup_done() + { + DS_ASSERT_X(m_resource, "zxdg_popup_v6::popup_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zxdg_popup_v6::popup_done as it's not initialised"); + return; + } + send_popup_done( + m_resource->handle); + } + + void zxdg_popup_v6::send_popup_done(struct ::wl_resource *resource) + { + zxdg_popup_v6_send_popup_done( + resource); + } + +} + diff --git a/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.h b/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.h new file mode 100644 index 0000000..6384957 --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.h @@ -0,0 +1,659 @@ +/* Protocol XML file : wayland-extension/xdg-shell-unstable-v6.xml */ + +#ifndef __DS_XDG_SHELL_UNSTABLE_V6_PROTOCOL_H__ +#define __DS_XDG_SHELL_UNSTABLE_V6_PROTOCOL_H__ + +#include "wayland-server-core.h" +#include "xdg-shell-unstable-v6-server-protocol.h" +#include +#include +#include +#include +#include + +#ifndef WAYLAND_VERSION_CHECK +#define WAYLAND_VERSION_CHECK(major, minor, micro) \ + ((WAYLAND_VERSION_MAJOR > (major)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) +#endif + + +namespace DSWaylandServer { + class zxdg_shell_v6 + { + public: + zxdg_shell_v6(struct ::wl_client *client, int id, int version); + zxdg_shell_v6(struct ::wl_display *display, int version); + zxdg_shell_v6(struct ::wl_resource *resource); + zxdg_shell_v6(); + + virtual ~zxdg_shell_v6(); + + class Resource + { + public: + Resource() : zxdg_shell_v6_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + zxdg_shell_v6 *zxdg_shell_v6_object; + zxdg_shell_v6 *object() { return zxdg_shell_v6_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_role = 0, // given wl_surface has another role + error_defunct_surfaces = 1, // xdg_shell was destroyed before children + error_not_the_topmost_popup = 2, // the client tried to map or destroy a non-topmost popup + error_invalid_popup_parent = 3, // the client specified an invalid popup parent surface + error_invalid_surface_state = 4, // the client provided an invalid surface state + error_invalid_positioner = 5, // the client provided an invalid positioner + }; + + void send_ping(uint32_t serial); + void send_ping(struct ::wl_resource *resource, uint32_t serial); + + protected: + virtual Resource *zxdg_shell_v6_allocate(); + + virtual void zxdg_shell_v6_bind_resource(Resource *resource); + virtual void zxdg_shell_v6_destroy_resource(Resource *resource); + + virtual void zxdg_shell_v6_destroy(Resource *resource); + virtual void zxdg_shell_v6_create_positioner(Resource *resource, uint32_t id); + virtual void zxdg_shell_v6_get_xdg_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); + virtual void zxdg_shell_v6_pong(Resource *resource, uint32_t serial); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::zxdg_shell_v6_interface m_zxdg_shell_v6_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_create_positioner( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_get_xdg_surface( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *surface); + static void handle_pong( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + zxdg_shell_v6 *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class zxdg_positioner_v6 + { + public: + zxdg_positioner_v6(struct ::wl_client *client, int id, int version); + zxdg_positioner_v6(struct ::wl_display *display, int version); + zxdg_positioner_v6(struct ::wl_resource *resource); + zxdg_positioner_v6(); + + virtual ~zxdg_positioner_v6(); + + class Resource + { + public: + Resource() : zxdg_positioner_v6_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + zxdg_positioner_v6 *zxdg_positioner_v6_object; + zxdg_positioner_v6 *object() { return zxdg_positioner_v6_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_invalid_input = 0, // invalid input provided + }; + + enum anchor { + anchor_none = 0, // the center of the anchor rectangle + anchor_top = 1, // the top edge of the anchor rectangle + anchor_bottom = 2, // the bottom edge of the anchor rectangle + anchor_left = 4, // the left edge of the anchor rectangle + anchor_right = 8, // the right edge of the anchor rectangle + }; + + enum gravity { + gravity_none = 0, // center over the anchor edge + gravity_top = 1, // position above the anchor edge + gravity_bottom = 2, // position below the anchor edge + gravity_left = 4, // position to the left of the anchor edge + gravity_right = 8, // position to the right of the anchor edge + }; + + enum constraint_adjustment { + constraint_adjustment_none = 0, + constraint_adjustment_slide_x = 1, + constraint_adjustment_slide_y = 2, + constraint_adjustment_flip_x = 4, + constraint_adjustment_flip_y = 8, + constraint_adjustment_resize_x = 16, + constraint_adjustment_resize_y = 32, + }; + + protected: + virtual Resource *zxdg_positioner_v6_allocate(); + + virtual void zxdg_positioner_v6_bind_resource(Resource *resource); + virtual void zxdg_positioner_v6_destroy_resource(Resource *resource); + + virtual void zxdg_positioner_v6_destroy(Resource *resource); + virtual void zxdg_positioner_v6_set_size(Resource *resource, int32_t width, int32_t height); + virtual void zxdg_positioner_v6_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); + virtual void zxdg_positioner_v6_set_anchor(Resource *resource, uint32_t anchor); + virtual void zxdg_positioner_v6_set_gravity(Resource *resource, uint32_t gravity); + virtual void zxdg_positioner_v6_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment); + virtual void zxdg_positioner_v6_set_offset(Resource *resource, int32_t x, int32_t y); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::zxdg_positioner_v6_interface m_zxdg_positioner_v6_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_set_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height); + static void handle_set_anchor_rect( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t width, + int32_t height); + static void handle_set_anchor( + ::wl_client *client, + struct wl_resource *resource, + uint32_t anchor); + static void handle_set_gravity( + ::wl_client *client, + struct wl_resource *resource, + uint32_t gravity); + static void handle_set_constraint_adjustment( + ::wl_client *client, + struct wl_resource *resource, + uint32_t constraint_adjustment); + static void handle_set_offset( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + zxdg_positioner_v6 *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class zxdg_surface_v6 + { + public: + zxdg_surface_v6(struct ::wl_client *client, int id, int version); + zxdg_surface_v6(struct ::wl_display *display, int version); + zxdg_surface_v6(struct ::wl_resource *resource); + zxdg_surface_v6(); + + virtual ~zxdg_surface_v6(); + + class Resource + { + public: + Resource() : zxdg_surface_v6_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + zxdg_surface_v6 *zxdg_surface_v6_object; + zxdg_surface_v6 *object() { return zxdg_surface_v6_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_not_constructed = 1, + error_already_constructed = 2, + error_unconfigured_buffer = 3, + }; + + void send_configure(uint32_t serial); + void send_configure(struct ::wl_resource *resource, uint32_t serial); + + protected: + virtual Resource *zxdg_surface_v6_allocate(); + + virtual void zxdg_surface_v6_bind_resource(Resource *resource); + virtual void zxdg_surface_v6_destroy_resource(Resource *resource); + + virtual void zxdg_surface_v6_destroy(Resource *resource); + virtual void zxdg_surface_v6_get_toplevel(Resource *resource, uint32_t id); + virtual void zxdg_surface_v6_get_popup(Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner); + virtual void zxdg_surface_v6_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); + virtual void zxdg_surface_v6_ack_configure(Resource *resource, uint32_t serial); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::zxdg_surface_v6_interface m_zxdg_surface_v6_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_get_toplevel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_get_popup( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *parent, + struct ::wl_resource *positioner); + static void handle_set_window_geometry( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t width, + int32_t height); + static void handle_ack_configure( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + zxdg_surface_v6 *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class zxdg_toplevel_v6 + { + public: + zxdg_toplevel_v6(struct ::wl_client *client, int id, int version); + zxdg_toplevel_v6(struct ::wl_display *display, int version); + zxdg_toplevel_v6(struct ::wl_resource *resource); + zxdg_toplevel_v6(); + + virtual ~zxdg_toplevel_v6(); + + class Resource + { + public: + Resource() : zxdg_toplevel_v6_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + zxdg_toplevel_v6 *zxdg_toplevel_v6_object; + zxdg_toplevel_v6 *object() { return zxdg_toplevel_v6_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum resize_edge { + resize_edge_none = 0, + resize_edge_top = 1, + resize_edge_bottom = 2, + resize_edge_left = 4, + resize_edge_top_left = 5, + resize_edge_bottom_left = 6, + resize_edge_right = 8, + resize_edge_top_right = 9, + resize_edge_bottom_right = 10, + }; + + enum state { + state_maximized = 1, // the surface is maximized + state_fullscreen = 2, // the surface is fullscreen + state_resizing = 3, // the surface is being resized + state_activated = 4, // the surface is now activated + }; + + void send_configure(int32_t width, int32_t height, const std::string &states); + void send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const std::string &states); + void send_close(); + void send_close(struct ::wl_resource *resource); + + protected: + virtual Resource *zxdg_toplevel_v6_allocate(); + + virtual void zxdg_toplevel_v6_bind_resource(Resource *resource); + virtual void zxdg_toplevel_v6_destroy_resource(Resource *resource); + + virtual void zxdg_toplevel_v6_destroy(Resource *resource); + virtual void zxdg_toplevel_v6_set_parent(Resource *resource, struct ::wl_resource *parent); + virtual void zxdg_toplevel_v6_set_title(Resource *resource, const std::string &title); + virtual void zxdg_toplevel_v6_set_app_id(Resource *resource, const std::string &app_id); + virtual void zxdg_toplevel_v6_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y); + virtual void zxdg_toplevel_v6_move(Resource *resource, struct ::wl_resource *seat, uint32_t serial); + virtual void zxdg_toplevel_v6_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges); + virtual void zxdg_toplevel_v6_set_max_size(Resource *resource, int32_t width, int32_t height); + virtual void zxdg_toplevel_v6_set_min_size(Resource *resource, int32_t width, int32_t height); + virtual void zxdg_toplevel_v6_set_maximized(Resource *resource); + virtual void zxdg_toplevel_v6_unset_maximized(Resource *resource); + virtual void zxdg_toplevel_v6_set_fullscreen(Resource *resource, struct ::wl_resource *output); + virtual void zxdg_toplevel_v6_unset_fullscreen(Resource *resource); + virtual void zxdg_toplevel_v6_set_minimized(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::zxdg_toplevel_v6_interface m_zxdg_toplevel_v6_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_set_parent( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *parent); + static void handle_set_title( + ::wl_client *client, + struct wl_resource *resource, + const char *title); + static void handle_set_app_id( + ::wl_client *client, + struct wl_resource *resource, + const char *app_id); + static void handle_show_window_menu( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial, + int32_t x, + int32_t y); + static void handle_move( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial); + static void handle_resize( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial, + uint32_t edges); + static void handle_set_max_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height); + static void handle_set_min_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height); + static void handle_set_maximized( + ::wl_client *client, + struct wl_resource *resource); + static void handle_unset_maximized( + ::wl_client *client, + struct wl_resource *resource); + static void handle_set_fullscreen( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *output); + static void handle_unset_fullscreen( + ::wl_client *client, + struct wl_resource *resource); + static void handle_set_minimized( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + zxdg_toplevel_v6 *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class zxdg_popup_v6 + { + public: + zxdg_popup_v6(struct ::wl_client *client, int id, int version); + zxdg_popup_v6(struct ::wl_display *display, int version); + zxdg_popup_v6(struct ::wl_resource *resource); + zxdg_popup_v6(); + + virtual ~zxdg_popup_v6(); + + class Resource + { + public: + Resource() : zxdg_popup_v6_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + zxdg_popup_v6 *zxdg_popup_v6_object; + zxdg_popup_v6 *object() { return zxdg_popup_v6_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_invalid_grab = 0, // tried to grab after being mapped + }; + + void send_configure(int32_t x, int32_t y, int32_t width, int32_t height); + void send_configure(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); + void send_popup_done(); + void send_popup_done(struct ::wl_resource *resource); + + protected: + virtual Resource *zxdg_popup_v6_allocate(); + + virtual void zxdg_popup_v6_bind_resource(Resource *resource); + virtual void zxdg_popup_v6_destroy_resource(Resource *resource); + + virtual void zxdg_popup_v6_destroy(Resource *resource); + virtual void zxdg_popup_v6_grab(Resource *resource, struct ::wl_resource *seat, uint32_t serial); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::zxdg_popup_v6_interface m_zxdg_popup_v6_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_grab( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + zxdg_popup_v6 *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; +} + +#endif diff --git a/src/DSWaylandServer/dswayland-server-xdg-shell.cpp b/src/DSWaylandServer/dswayland-server-xdg-shell.cpp new file mode 100644 index 0000000..cfaf588 --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-xdg-shell.cpp @@ -0,0 +1,1471 @@ +/* Protocol XML file : wayland-extension/xdg-shell.xml */ + +#include "dswayland-server-xdg-shell.h" + +#ifndef DS_UNLIKELY +#define DS_UNLIKELY(X) X +#endif +#ifndef DS_UNUSED +#define DS_UNUSED(X) X +#endif +#ifndef DS_ASSERT +#define DS_ASSERT(COND) assert(COND) +#endif +#ifndef DS_ASSERT_X +#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ + do {\ + if (! (COND))\ + {\ + fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ + assert(COND);\ + }\ + } while(0) +#endif +#ifndef WRN +#define WRN(X...) fprintf(stderr,##X) +#endif + +namespace DSWaylandServer { + xdg_wm_base::xdg_wm_base(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + xdg_wm_base::xdg_wm_base(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + xdg_wm_base::xdg_wm_base(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + xdg_wm_base::xdg_wm_base() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + xdg_wm_base::~xdg_wm_base() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + xdg_wm_base::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void xdg_wm_base::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void xdg_wm_base::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + xdg_wm_base::Resource *xdg_wm_base::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + xdg_wm_base::Resource *xdg_wm_base::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void xdg_wm_base::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::xdg_wm_base_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = xdg_wm_base::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *xdg_wm_base::interface() + { + return &::xdg_wm_base_interface; + } + + xdg_wm_base::Resource *xdg_wm_base::xdg_wm_base_allocate() + { + return new Resource; + } + + void xdg_wm_base::xdg_wm_base_bind_resource(Resource *) + { + } + + void xdg_wm_base::xdg_wm_base_destroy_resource(Resource *) + { + } + + void xdg_wm_base::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + xdg_wm_base *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void xdg_wm_base::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + xdg_wm_base *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void xdg_wm_base::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + xdg_wm_base *that = resource->xdg_wm_base_object; + that->m_resource_map.erase(resource->client()); + that->xdg_wm_base_destroy_resource(resource); + delete resource; + } + + xdg_wm_base::Resource *xdg_wm_base::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::xdg_wm_base_interface, version, id); + return bind(handle); + } + + xdg_wm_base::Resource *xdg_wm_base::bind(struct ::wl_resource *handle) + { + Resource *resource = xdg_wm_base_allocate(); + resource->xdg_wm_base_object = this; + + wl_resource_set_implementation(handle, &m_xdg_wm_base_interface, resource, destroy_func); + resource->handle = handle; + xdg_wm_base_bind_resource(resource); + return resource; + } + xdg_wm_base::Resource *xdg_wm_base::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::xdg_wm_base_interface, &m_xdg_wm_base_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::xdg_wm_base_interface xdg_wm_base::m_xdg_wm_base_interface = { + xdg_wm_base::handle_destroy, + xdg_wm_base::handle_create_positioner, + xdg_wm_base::handle_get_xdg_surface, + xdg_wm_base::handle_pong + }; + + void xdg_wm_base::xdg_wm_base_destroy(Resource *) + { + } + + void xdg_wm_base::xdg_wm_base_create_positioner(Resource *, uint32_t) + { + } + + void xdg_wm_base::xdg_wm_base_get_xdg_surface(Resource *, uint32_t, struct ::wl_resource *) + { + } + + void xdg_wm_base::xdg_wm_base_pong(Resource *, uint32_t ) + { + } + + + void xdg_wm_base::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_wm_base_object)->xdg_wm_base_destroy( + r); + } + + void xdg_wm_base::handle_create_positioner( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_wm_base_object)->xdg_wm_base_create_positioner( + r, + id); + } + + void xdg_wm_base::handle_get_xdg_surface( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *surface) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_wm_base_object)->xdg_wm_base_get_xdg_surface( + r, + id, + surface); + } + + void xdg_wm_base::handle_pong( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_wm_base_object)->xdg_wm_base_pong( + r, + serial); + } + + void xdg_wm_base::send_ping(uint32_t serial) + { + DS_ASSERT_X(m_resource, "xdg_wm_base::ping", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call xdg_wm_base::ping as it's not initialised"); + return; + } + send_ping( + m_resource->handle, + serial); + } + + void xdg_wm_base::send_ping(struct ::wl_resource *resource, uint32_t serial) + { + xdg_wm_base_send_ping( + resource, + serial); + } + + + xdg_positioner::xdg_positioner(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + xdg_positioner::xdg_positioner(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + xdg_positioner::xdg_positioner(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + xdg_positioner::xdg_positioner() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + xdg_positioner::~xdg_positioner() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + xdg_positioner::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void xdg_positioner::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void xdg_positioner::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + xdg_positioner::Resource *xdg_positioner::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + xdg_positioner::Resource *xdg_positioner::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void xdg_positioner::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::xdg_positioner_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = xdg_positioner::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *xdg_positioner::interface() + { + return &::xdg_positioner_interface; + } + + xdg_positioner::Resource *xdg_positioner::xdg_positioner_allocate() + { + return new Resource; + } + + void xdg_positioner::xdg_positioner_bind_resource(Resource *) + { + } + + void xdg_positioner::xdg_positioner_destroy_resource(Resource *) + { + } + + void xdg_positioner::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + xdg_positioner *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void xdg_positioner::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + xdg_positioner *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void xdg_positioner::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + xdg_positioner *that = resource->xdg_positioner_object; + that->m_resource_map.erase(resource->client()); + that->xdg_positioner_destroy_resource(resource); + delete resource; + } + + xdg_positioner::Resource *xdg_positioner::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::xdg_positioner_interface, version, id); + return bind(handle); + } + + xdg_positioner::Resource *xdg_positioner::bind(struct ::wl_resource *handle) + { + Resource *resource = xdg_positioner_allocate(); + resource->xdg_positioner_object = this; + + wl_resource_set_implementation(handle, &m_xdg_positioner_interface, resource, destroy_func); + resource->handle = handle; + xdg_positioner_bind_resource(resource); + return resource; + } + xdg_positioner::Resource *xdg_positioner::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::xdg_positioner_interface, &m_xdg_positioner_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::xdg_positioner_interface xdg_positioner::m_xdg_positioner_interface = { + xdg_positioner::handle_destroy, + xdg_positioner::handle_set_size, + xdg_positioner::handle_set_anchor_rect, + xdg_positioner::handle_set_anchor, + xdg_positioner::handle_set_gravity, + xdg_positioner::handle_set_constraint_adjustment, + xdg_positioner::handle_set_offset + }; + + void xdg_positioner::xdg_positioner_destroy(Resource *) + { + } + + void xdg_positioner::xdg_positioner_set_size(Resource *, int32_t , int32_t ) + { + } + + void xdg_positioner::xdg_positioner_set_anchor_rect(Resource *, int32_t , int32_t , int32_t , int32_t ) + { + } + + void xdg_positioner::xdg_positioner_set_anchor(Resource *, uint32_t ) + { + } + + void xdg_positioner::xdg_positioner_set_gravity(Resource *, uint32_t ) + { + } + + void xdg_positioner::xdg_positioner_set_constraint_adjustment(Resource *, uint32_t ) + { + } + + void xdg_positioner::xdg_positioner_set_offset(Resource *, int32_t , int32_t ) + { + } + + + void xdg_positioner::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_positioner_object)->xdg_positioner_destroy( + r); + } + + void xdg_positioner::handle_set_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_positioner_object)->xdg_positioner_set_size( + r, + width, + height); + } + + void xdg_positioner::handle_set_anchor_rect( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_positioner_object)->xdg_positioner_set_anchor_rect( + r, + x, + y, + width, + height); + } + + void xdg_positioner::handle_set_anchor( + ::wl_client *client, + struct wl_resource *resource, + uint32_t anchor) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_positioner_object)->xdg_positioner_set_anchor( + r, + anchor); + } + + void xdg_positioner::handle_set_gravity( + ::wl_client *client, + struct wl_resource *resource, + uint32_t gravity) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_positioner_object)->xdg_positioner_set_gravity( + r, + gravity); + } + + void xdg_positioner::handle_set_constraint_adjustment( + ::wl_client *client, + struct wl_resource *resource, + uint32_t constraint_adjustment) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_positioner_object)->xdg_positioner_set_constraint_adjustment( + r, + constraint_adjustment); + } + + void xdg_positioner::handle_set_offset( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_positioner_object)->xdg_positioner_set_offset( + r, + x, + y); + } + + xdg_surface::xdg_surface(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + xdg_surface::xdg_surface(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + xdg_surface::xdg_surface(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + xdg_surface::xdg_surface() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + xdg_surface::~xdg_surface() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + xdg_surface::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void xdg_surface::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void xdg_surface::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + xdg_surface::Resource *xdg_surface::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + xdg_surface::Resource *xdg_surface::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void xdg_surface::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::xdg_surface_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = xdg_surface::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *xdg_surface::interface() + { + return &::xdg_surface_interface; + } + + xdg_surface::Resource *xdg_surface::xdg_surface_allocate() + { + return new Resource; + } + + void xdg_surface::xdg_surface_bind_resource(Resource *) + { + } + + void xdg_surface::xdg_surface_destroy_resource(Resource *) + { + } + + void xdg_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + xdg_surface *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void xdg_surface::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + xdg_surface *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void xdg_surface::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + xdg_surface *that = resource->xdg_surface_object; + that->m_resource_map.erase(resource->client()); + that->xdg_surface_destroy_resource(resource); + delete resource; + } + + xdg_surface::Resource *xdg_surface::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::xdg_surface_interface, version, id); + return bind(handle); + } + + xdg_surface::Resource *xdg_surface::bind(struct ::wl_resource *handle) + { + Resource *resource = xdg_surface_allocate(); + resource->xdg_surface_object = this; + + wl_resource_set_implementation(handle, &m_xdg_surface_interface, resource, destroy_func); + resource->handle = handle; + xdg_surface_bind_resource(resource); + return resource; + } + xdg_surface::Resource *xdg_surface::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::xdg_surface_interface, &m_xdg_surface_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::xdg_surface_interface xdg_surface::m_xdg_surface_interface = { + xdg_surface::handle_destroy, + xdg_surface::handle_get_toplevel, + xdg_surface::handle_get_popup, + xdg_surface::handle_set_window_geometry, + xdg_surface::handle_ack_configure + }; + + void xdg_surface::xdg_surface_destroy(Resource *) + { + } + + void xdg_surface::xdg_surface_get_toplevel(Resource *, uint32_t) + { + } + + void xdg_surface::xdg_surface_get_popup(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *) + { + } + + void xdg_surface::xdg_surface_set_window_geometry(Resource *, int32_t , int32_t , int32_t , int32_t ) + { + } + + void xdg_surface::xdg_surface_ack_configure(Resource *, uint32_t ) + { + } + + + void xdg_surface::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_surface_object)->xdg_surface_destroy( + r); + } + + void xdg_surface::handle_get_toplevel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_surface_object)->xdg_surface_get_toplevel( + r, + id); + } + + void xdg_surface::handle_get_popup( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *parent, + struct ::wl_resource *positioner) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_surface_object)->xdg_surface_get_popup( + r, + id, + parent, + positioner); + } + + void xdg_surface::handle_set_window_geometry( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_surface_object)->xdg_surface_set_window_geometry( + r, + x, + y, + width, + height); + } + + void xdg_surface::handle_ack_configure( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_surface_object)->xdg_surface_ack_configure( + r, + serial); + } + + void xdg_surface::send_configure(uint32_t serial) + { + DS_ASSERT_X(m_resource, "xdg_surface::configure", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call xdg_surface::configure as it's not initialised"); + return; + } + send_configure( + m_resource->handle, + serial); + } + + void xdg_surface::send_configure(struct ::wl_resource *resource, uint32_t serial) + { + xdg_surface_send_configure( + resource, + serial); + } + + + xdg_toplevel::xdg_toplevel(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + xdg_toplevel::xdg_toplevel(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + xdg_toplevel::xdg_toplevel(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + xdg_toplevel::xdg_toplevel() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + xdg_toplevel::~xdg_toplevel() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + xdg_toplevel::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void xdg_toplevel::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void xdg_toplevel::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + xdg_toplevel::Resource *xdg_toplevel::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + xdg_toplevel::Resource *xdg_toplevel::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void xdg_toplevel::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::xdg_toplevel_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = xdg_toplevel::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *xdg_toplevel::interface() + { + return &::xdg_toplevel_interface; + } + + xdg_toplevel::Resource *xdg_toplevel::xdg_toplevel_allocate() + { + return new Resource; + } + + void xdg_toplevel::xdg_toplevel_bind_resource(Resource *) + { + } + + void xdg_toplevel::xdg_toplevel_destroy_resource(Resource *) + { + } + + void xdg_toplevel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + xdg_toplevel *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void xdg_toplevel::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + xdg_toplevel *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void xdg_toplevel::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + xdg_toplevel *that = resource->xdg_toplevel_object; + that->m_resource_map.erase(resource->client()); + that->xdg_toplevel_destroy_resource(resource); + delete resource; + } + + xdg_toplevel::Resource *xdg_toplevel::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::xdg_toplevel_interface, version, id); + return bind(handle); + } + + xdg_toplevel::Resource *xdg_toplevel::bind(struct ::wl_resource *handle) + { + Resource *resource = xdg_toplevel_allocate(); + resource->xdg_toplevel_object = this; + + wl_resource_set_implementation(handle, &m_xdg_toplevel_interface, resource, destroy_func); + resource->handle = handle; + xdg_toplevel_bind_resource(resource); + return resource; + } + xdg_toplevel::Resource *xdg_toplevel::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::xdg_toplevel_interface, &m_xdg_toplevel_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::xdg_toplevel_interface xdg_toplevel::m_xdg_toplevel_interface = { + xdg_toplevel::handle_destroy, + xdg_toplevel::handle_set_parent, + xdg_toplevel::handle_set_title, + xdg_toplevel::handle_set_app_id, + xdg_toplevel::handle_show_window_menu, + xdg_toplevel::handle_move, + xdg_toplevel::handle_resize, + xdg_toplevel::handle_set_max_size, + xdg_toplevel::handle_set_min_size, + xdg_toplevel::handle_set_maximized, + xdg_toplevel::handle_unset_maximized, + xdg_toplevel::handle_set_fullscreen, + xdg_toplevel::handle_unset_fullscreen, + xdg_toplevel::handle_set_minimized + }; + + void xdg_toplevel::xdg_toplevel_destroy(Resource *) + { + } + + void xdg_toplevel::xdg_toplevel_set_parent(Resource *, struct ::wl_resource *) + { + } + + void xdg_toplevel::xdg_toplevel_set_title(Resource *, const std::string &) + { + } + + void xdg_toplevel::xdg_toplevel_set_app_id(Resource *, const std::string &) + { + } + + void xdg_toplevel::xdg_toplevel_show_window_menu(Resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t ) + { + } + + void xdg_toplevel::xdg_toplevel_move(Resource *, struct ::wl_resource *, uint32_t ) + { + } + + void xdg_toplevel::xdg_toplevel_resize(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) + { + } + + void xdg_toplevel::xdg_toplevel_set_max_size(Resource *, int32_t , int32_t ) + { + } + + void xdg_toplevel::xdg_toplevel_set_min_size(Resource *, int32_t , int32_t ) + { + } + + void xdg_toplevel::xdg_toplevel_set_maximized(Resource *) + { + } + + void xdg_toplevel::xdg_toplevel_unset_maximized(Resource *) + { + } + + void xdg_toplevel::xdg_toplevel_set_fullscreen(Resource *, struct ::wl_resource *) + { + } + + void xdg_toplevel::xdg_toplevel_unset_fullscreen(Resource *) + { + } + + void xdg_toplevel::xdg_toplevel_set_minimized(Resource *) + { + } + + + void xdg_toplevel::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_destroy( + r); + } + + void xdg_toplevel::handle_set_parent( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *parent) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_parent( + r, + parent); + } + + void xdg_toplevel::handle_set_title( + ::wl_client *client, + struct wl_resource *resource, + const char *title) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_title( + r, + std::string(title)); + } + + void xdg_toplevel::handle_set_app_id( + ::wl_client *client, + struct wl_resource *resource, + const char *app_id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_app_id( + r, + std::string(app_id)); + } + + void xdg_toplevel::handle_show_window_menu( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial, + int32_t x, + int32_t y) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_show_window_menu( + r, + seat, + serial, + x, + y); + } + + void xdg_toplevel::handle_move( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_move( + r, + seat, + serial); + } + + void xdg_toplevel::handle_resize( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial, + uint32_t edges) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_resize( + r, + seat, + serial, + edges); + } + + void xdg_toplevel::handle_set_max_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_max_size( + r, + width, + height); + } + + void xdg_toplevel::handle_set_min_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_min_size( + r, + width, + height); + } + + void xdg_toplevel::handle_set_maximized( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_maximized( + r); + } + + void xdg_toplevel::handle_unset_maximized( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_unset_maximized( + r); + } + + void xdg_toplevel::handle_set_fullscreen( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *output) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_fullscreen( + r, + output); + } + + void xdg_toplevel::handle_unset_fullscreen( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_unset_fullscreen( + r); + } + + void xdg_toplevel::handle_set_minimized( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_minimized( + r); + } + + void xdg_toplevel::send_configure(int32_t width, int32_t height, const std::string &states) + { + DS_ASSERT_X(m_resource, "xdg_toplevel::configure", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call xdg_toplevel::configure as it's not initialised"); + return; + } + send_configure( + m_resource->handle, + width, + height, + states); + } + + void xdg_toplevel::send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const std::string &states) + { + struct wl_array states_data; + states_data.size = states.size(); + states_data.data = static_cast(const_cast(states.c_str())); + states_data.alloc = 0; + + xdg_toplevel_send_configure( + resource, + width, + height, + &states_data); + } + + + void xdg_toplevel::send_close() + { + DS_ASSERT_X(m_resource, "xdg_toplevel::close", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call xdg_toplevel::close as it's not initialised"); + return; + } + send_close( + m_resource->handle); + } + + void xdg_toplevel::send_close(struct ::wl_resource *resource) + { + xdg_toplevel_send_close( + resource); + } + + + xdg_popup::xdg_popup(struct ::wl_client *client, int id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(client, id, version); + } + + xdg_popup::xdg_popup(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(display, version); + } + + xdg_popup::xdg_popup(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + init(resource); + } + + xdg_popup::xdg_popup() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + { + } + + xdg_popup::~xdg_popup() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + xdg_popup::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void xdg_popup::init(struct ::wl_client *client, int id, int version) + { + m_resource = bind(client, id, version); + } + + void xdg_popup::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + xdg_popup::Resource *xdg_popup::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + xdg_popup::Resource *xdg_popup::add(struct ::wl_client *client, int id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void xdg_popup::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::xdg_popup_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = xdg_popup::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *xdg_popup::interface() + { + return &::xdg_popup_interface; + } + + xdg_popup::Resource *xdg_popup::xdg_popup_allocate() + { + return new Resource; + } + + void xdg_popup::xdg_popup_bind_resource(Resource *) + { + } + + void xdg_popup::xdg_popup_destroy_resource(Resource *) + { + } + + void xdg_popup::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + xdg_popup *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void xdg_popup::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + xdg_popup *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void xdg_popup::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + xdg_popup *that = resource->xdg_popup_object; + that->m_resource_map.erase(resource->client()); + that->xdg_popup_destroy_resource(resource); + delete resource; + } + + xdg_popup::Resource *xdg_popup::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::xdg_popup_interface, version, id); + return bind(handle); + } + + xdg_popup::Resource *xdg_popup::bind(struct ::wl_resource *handle) + { + Resource *resource = xdg_popup_allocate(); + resource->xdg_popup_object = this; + + wl_resource_set_implementation(handle, &m_xdg_popup_interface, resource, destroy_func); + resource->handle = handle; + xdg_popup_bind_resource(resource); + return resource; + } + xdg_popup::Resource *xdg_popup::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::xdg_popup_interface, &m_xdg_popup_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::xdg_popup_interface xdg_popup::m_xdg_popup_interface = { + xdg_popup::handle_destroy, + xdg_popup::handle_grab + }; + + void xdg_popup::xdg_popup_destroy(Resource *) + { + } + + void xdg_popup::xdg_popup_grab(Resource *, struct ::wl_resource *, uint32_t ) + { + } + + + void xdg_popup::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_popup_object)->xdg_popup_destroy( + r); + } + + void xdg_popup::handle_grab( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->xdg_popup_object)->xdg_popup_grab( + r, + seat, + serial); + } + + void xdg_popup::send_configure(int32_t x, int32_t y, int32_t width, int32_t height) + { + DS_ASSERT_X(m_resource, "xdg_popup::configure", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call xdg_popup::configure as it's not initialised"); + return; + } + send_configure( + m_resource->handle, + x, + y, + width, + height); + } + + void xdg_popup::send_configure(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) + { + xdg_popup_send_configure( + resource, + x, + y, + width, + height); + } + + + void xdg_popup::send_popup_done() + { + DS_ASSERT_X(m_resource, "xdg_popup::popup_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call xdg_popup::popup_done as it's not initialised"); + return; + } + send_popup_done( + m_resource->handle); + } + + void xdg_popup::send_popup_done(struct ::wl_resource *resource) + { + xdg_popup_send_popup_done( + resource); + } + +} + diff --git a/src/DSWaylandServer/dswayland-server-xdg-shell.h b/src/DSWaylandServer/dswayland-server-xdg-shell.h new file mode 100644 index 0000000..4d46443 --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-xdg-shell.h @@ -0,0 +1,671 @@ +/* Protocol XML file : wayland-extension/xdg-shell.xml */ + +#ifndef __DS_XDG_SHELL_PROTOCOL_H__ +#define __DS_XDG_SHELL_PROTOCOL_H__ + +#include "wayland-server-core.h" +#include "xdg-shell-server-protocol.h" +#include +#include +#include +#include +#include + +#ifndef WAYLAND_VERSION_CHECK +#define WAYLAND_VERSION_CHECK(major, minor, micro) \ + ((WAYLAND_VERSION_MAJOR > (major)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ + (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) +#endif + + +namespace DSWaylandServer { + class xdg_wm_base + { + public: + xdg_wm_base(struct ::wl_client *client, int id, int version); + xdg_wm_base(struct ::wl_display *display, int version); + xdg_wm_base(struct ::wl_resource *resource); + xdg_wm_base(); + + virtual ~xdg_wm_base(); + + class Resource + { + public: + Resource() : xdg_wm_base_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + xdg_wm_base *xdg_wm_base_object; + xdg_wm_base *object() { return xdg_wm_base_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_role = 0, // given wl_surface has another role + error_defunct_surfaces = 1, // xdg_wm_base was destroyed before children + error_not_the_topmost_popup = 2, // the client tried to map or destroy a non-topmost popup + error_invalid_popup_parent = 3, // the client specified an invalid popup parent surface + error_invalid_surface_state = 4, // the client provided an invalid surface state + error_invalid_positioner = 5, // the client provided an invalid positioner + }; + + void send_ping(uint32_t serial); + void send_ping(struct ::wl_resource *resource, uint32_t serial); + + protected: + virtual Resource *xdg_wm_base_allocate(); + + virtual void xdg_wm_base_bind_resource(Resource *resource); + virtual void xdg_wm_base_destroy_resource(Resource *resource); + + virtual void xdg_wm_base_destroy(Resource *resource); + virtual void xdg_wm_base_create_positioner(Resource *resource, uint32_t id); + virtual void xdg_wm_base_get_xdg_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); + virtual void xdg_wm_base_pong(Resource *resource, uint32_t serial); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::xdg_wm_base_interface m_xdg_wm_base_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_create_positioner( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_get_xdg_surface( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *surface); + static void handle_pong( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + xdg_wm_base *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class xdg_positioner + { + public: + xdg_positioner(struct ::wl_client *client, int id, int version); + xdg_positioner(struct ::wl_display *display, int version); + xdg_positioner(struct ::wl_resource *resource); + xdg_positioner(); + + virtual ~xdg_positioner(); + + class Resource + { + public: + Resource() : xdg_positioner_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + xdg_positioner *xdg_positioner_object; + xdg_positioner *object() { return xdg_positioner_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_invalid_input = 0, // invalid input provided + }; + + enum anchor { + anchor_none = 0, + anchor_top = 1, + anchor_bottom = 2, + anchor_left = 3, + anchor_right = 4, + anchor_top_left = 5, + anchor_bottom_left = 6, + anchor_top_right = 7, + anchor_bottom_right = 8, + }; + + enum gravity { + gravity_none = 0, + gravity_top = 1, + gravity_bottom = 2, + gravity_left = 3, + gravity_right = 4, + gravity_top_left = 5, + gravity_bottom_left = 6, + gravity_top_right = 7, + gravity_bottom_right = 8, + }; + + enum constraint_adjustment { + constraint_adjustment_none = 0, + constraint_adjustment_slide_x = 1, + constraint_adjustment_slide_y = 2, + constraint_adjustment_flip_x = 4, + constraint_adjustment_flip_y = 8, + constraint_adjustment_resize_x = 16, + constraint_adjustment_resize_y = 32, + }; + + protected: + virtual Resource *xdg_positioner_allocate(); + + virtual void xdg_positioner_bind_resource(Resource *resource); + virtual void xdg_positioner_destroy_resource(Resource *resource); + + virtual void xdg_positioner_destroy(Resource *resource); + virtual void xdg_positioner_set_size(Resource *resource, int32_t width, int32_t height); + virtual void xdg_positioner_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); + virtual void xdg_positioner_set_anchor(Resource *resource, uint32_t anchor); + virtual void xdg_positioner_set_gravity(Resource *resource, uint32_t gravity); + virtual void xdg_positioner_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment); + virtual void xdg_positioner_set_offset(Resource *resource, int32_t x, int32_t y); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::xdg_positioner_interface m_xdg_positioner_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_set_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height); + static void handle_set_anchor_rect( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t width, + int32_t height); + static void handle_set_anchor( + ::wl_client *client, + struct wl_resource *resource, + uint32_t anchor); + static void handle_set_gravity( + ::wl_client *client, + struct wl_resource *resource, + uint32_t gravity); + static void handle_set_constraint_adjustment( + ::wl_client *client, + struct wl_resource *resource, + uint32_t constraint_adjustment); + static void handle_set_offset( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + xdg_positioner *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class xdg_surface + { + public: + xdg_surface(struct ::wl_client *client, int id, int version); + xdg_surface(struct ::wl_display *display, int version); + xdg_surface(struct ::wl_resource *resource); + xdg_surface(); + + virtual ~xdg_surface(); + + class Resource + { + public: + Resource() : xdg_surface_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + xdg_surface *xdg_surface_object; + xdg_surface *object() { return xdg_surface_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_not_constructed = 1, + error_already_constructed = 2, + error_unconfigured_buffer = 3, + }; + + void send_configure(uint32_t serial); + void send_configure(struct ::wl_resource *resource, uint32_t serial); + + protected: + virtual Resource *xdg_surface_allocate(); + + virtual void xdg_surface_bind_resource(Resource *resource); + virtual void xdg_surface_destroy_resource(Resource *resource); + + virtual void xdg_surface_destroy(Resource *resource); + virtual void xdg_surface_get_toplevel(Resource *resource, uint32_t id); + virtual void xdg_surface_get_popup(Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner); + virtual void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); + virtual void xdg_surface_ack_configure(Resource *resource, uint32_t serial); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::xdg_surface_interface m_xdg_surface_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_get_toplevel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id); + static void handle_get_popup( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *parent, + struct ::wl_resource *positioner); + static void handle_set_window_geometry( + ::wl_client *client, + struct wl_resource *resource, + int32_t x, + int32_t y, + int32_t width, + int32_t height); + static void handle_ack_configure( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + xdg_surface *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class xdg_toplevel + { + public: + xdg_toplevel(struct ::wl_client *client, int id, int version); + xdg_toplevel(struct ::wl_display *display, int version); + xdg_toplevel(struct ::wl_resource *resource); + xdg_toplevel(); + + virtual ~xdg_toplevel(); + + class Resource + { + public: + Resource() : xdg_toplevel_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + xdg_toplevel *xdg_toplevel_object; + xdg_toplevel *object() { return xdg_toplevel_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum resize_edge { + resize_edge_none = 0, + resize_edge_top = 1, + resize_edge_bottom = 2, + resize_edge_left = 4, + resize_edge_top_left = 5, + resize_edge_bottom_left = 6, + resize_edge_right = 8, + resize_edge_top_right = 9, + resize_edge_bottom_right = 10, + }; + + enum state { + state_maximized = 1, // the surface is maximized + state_fullscreen = 2, // the surface is fullscreen + state_resizing = 3, // the surface is being resized + state_activated = 4, // the surface is now activated + state_tiled_left = 5, + state_tiled_right = 6, + state_tiled_top = 7, + state_tiled_bottom = 8, + }; + + void send_configure(int32_t width, int32_t height, const std::string &states); + void send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const std::string &states); + void send_close(); + void send_close(struct ::wl_resource *resource); + + protected: + virtual Resource *xdg_toplevel_allocate(); + + virtual void xdg_toplevel_bind_resource(Resource *resource); + virtual void xdg_toplevel_destroy_resource(Resource *resource); + + virtual void xdg_toplevel_destroy(Resource *resource); + virtual void xdg_toplevel_set_parent(Resource *resource, struct ::wl_resource *parent); + virtual void xdg_toplevel_set_title(Resource *resource, const std::string &title); + virtual void xdg_toplevel_set_app_id(Resource *resource, const std::string &app_id); + virtual void xdg_toplevel_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y); + virtual void xdg_toplevel_move(Resource *resource, struct ::wl_resource *seat, uint32_t serial); + virtual void xdg_toplevel_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges); + virtual void xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height); + virtual void xdg_toplevel_set_min_size(Resource *resource, int32_t width, int32_t height); + virtual void xdg_toplevel_set_maximized(Resource *resource); + virtual void xdg_toplevel_unset_maximized(Resource *resource); + virtual void xdg_toplevel_set_fullscreen(Resource *resource, struct ::wl_resource *output); + virtual void xdg_toplevel_unset_fullscreen(Resource *resource); + virtual void xdg_toplevel_set_minimized(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::xdg_toplevel_interface m_xdg_toplevel_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_set_parent( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *parent); + static void handle_set_title( + ::wl_client *client, + struct wl_resource *resource, + const char *title); + static void handle_set_app_id( + ::wl_client *client, + struct wl_resource *resource, + const char *app_id); + static void handle_show_window_menu( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial, + int32_t x, + int32_t y); + static void handle_move( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial); + static void handle_resize( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial, + uint32_t edges); + static void handle_set_max_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height); + static void handle_set_min_size( + ::wl_client *client, + struct wl_resource *resource, + int32_t width, + int32_t height); + static void handle_set_maximized( + ::wl_client *client, + struct wl_resource *resource); + static void handle_unset_maximized( + ::wl_client *client, + struct wl_resource *resource); + static void handle_set_fullscreen( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *output); + static void handle_unset_fullscreen( + ::wl_client *client, + struct wl_resource *resource); + static void handle_set_minimized( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + xdg_toplevel *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class xdg_popup + { + public: + xdg_popup(struct ::wl_client *client, int id, int version); + xdg_popup(struct ::wl_display *display, int version); + xdg_popup(struct ::wl_resource *resource); + xdg_popup(); + + virtual ~xdg_popup(); + + class Resource + { + public: + Resource() : xdg_popup_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + xdg_popup *xdg_popup_object; + xdg_popup *object() { return xdg_popup_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, int id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, int id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + enum error { + error_invalid_grab = 0, // tried to grab after being mapped + }; + + void send_configure(int32_t x, int32_t y, int32_t width, int32_t height); + void send_configure(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); + void send_popup_done(); + void send_popup_done(struct ::wl_resource *resource); + + protected: + virtual Resource *xdg_popup_allocate(); + + virtual void xdg_popup_bind_resource(Resource *resource); + virtual void xdg_popup_destroy_resource(Resource *resource); + + virtual void xdg_popup_destroy(Resource *resource); + virtual void xdg_popup_grab(Resource *resource, struct ::wl_resource *seat, uint32_t serial); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::xdg_popup_interface m_xdg_popup_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + static void handle_grab( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *seat, + uint32_t serial); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + xdg_popup *parent; + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; +} + +#endif -- 2.7.4 From dd7d5c27460c654780c7ad04789c42bbaf9710d1 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 17 Jun 2020 13:36:41 +0900 Subject: [PATCH 08/16] Revert "include DSPropertyPrivate.h file" This reverts commit 5ac60980cc74f02ae06cde396765d0ed1c595847. Change-Id: I08f3fef79ddc209e16c751685293ea0deddee74c --- src/DSProperty/DSPropertyPrivate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSProperty/DSPropertyPrivate.cpp b/src/DSProperty/DSPropertyPrivate.cpp index d07123d..00dd756 100644 --- a/src/DSProperty/DSPropertyPrivate.cpp +++ b/src/DSProperty/DSPropertyPrivate.cpp @@ -1,4 +1,4 @@ -#include "DSPropertyPrivate.h" +#include "DSProperty.h" namespace display_server { -- 2.7.4 From f77aa8f0d3372d52c23b49edc41e66dc237bc304 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 18 Jun 2020 11:40:38 +0900 Subject: [PATCH 09/16] implement the skeleton methods of DSCompositor At this time, the test case fails. Change-Id: I32835f6c0cba2254a3c747537a6010c491ec7df5 --- src/DSCompositor/DSCompositor.cpp | 7 +++++++ src/DSCompositor/DSCompositor.h | 2 ++ tests/DSCompositor-test.cpp | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/src/DSCompositor/DSCompositor.cpp b/src/DSCompositor/DSCompositor.cpp index c345bfc..81b4dff 100644 --- a/src/DSCompositor/DSCompositor.cpp +++ b/src/DSCompositor/DSCompositor.cpp @@ -2,9 +2,16 @@ namespace display_server { + DSCompositor::DSCompositor() {} DSCompositor::~DSCompositor() {} + +bool DSCompositor::run() +{ + return false; +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSCompositor/DSCompositor.h b/src/DSCompositor/DSCompositor.h index fb3ec50..df25b2a 100644 --- a/src/DSCompositor/DSCompositor.h +++ b/src/DSCompositor/DSCompositor.h @@ -9,6 +9,8 @@ public: DSCompositor(); virtual ~DSCompositor(); + bool run(); + private: /* data */ }; diff --git a/tests/DSCompositor-test.cpp b/tests/DSCompositor-test.cpp index 5b4639f..4e50ed2 100644 --- a/tests/DSCompositor-test.cpp +++ b/tests/DSCompositor-test.cpp @@ -18,3 +18,10 @@ TEST_F(DSComopsitorTest, NewDSCompositor) delete compositor; ASSERT_TRUE(true); } + +TEST_F(DSComopsitorTest, BasicMethods) +{ + DSCompositor compositor; + + EXPECT_TRUE(compositor.run() == true); +} -- 2.7.4 From 0929d015eceba8e87b45aaeca2ee64b35e1477e0 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 18 Jun 2020 11:32:29 +0900 Subject: [PATCH 10/16] implement the skeleton methods of DSSeat At this time, the test case fails. Change-Id: Ib8b2c7a47168be836e5ab5db67ff0ce99e068599 --- src/DSSeat/DSSeat.cpp | 13 +++++++++++++ src/DSSeat/DSSeat.h | 9 ++++++++- tests/DSInput-test.cpp | 7 +++++++ tests/DSSeat-test.cpp | 9 +++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index 559e703..ba66418 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -2,9 +2,22 @@ namespace display_server { + DSSeat::DSSeat() + : __input(nullptr) {} DSSeat::~DSSeat() {} + +bool DSSeat::addInput(DSInput *input) +{ + return false; +} + +bool DSSeat::removeInput(DSInput *input) +{ + return false; +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h index c3e64ab..78f06b4 100644 --- a/src/DSSeat/DSSeat.h +++ b/src/DSSeat/DSSeat.h @@ -1,17 +1,24 @@ #ifndef _DSSEAT_H_ #define _DSSEAT_H_ +#include + namespace display_server { + class DSSeat { public: DSSeat(); virtual ~DSSeat(); + bool addInput(DSInput *input); + bool removeInput(DSInput *input); + private: - /* data */ + DSInput *__input; }; + } #endif \ No newline at end of file diff --git a/tests/DSInput-test.cpp b/tests/DSInput-test.cpp index 657803c..3e4f18c 100644 --- a/tests/DSInput-test.cpp +++ b/tests/DSInput-test.cpp @@ -18,3 +18,10 @@ TEST_F(DSInputTest, NewDSInput) delete input; ASSERT_TRUE(true); } + +TEST_F(DSInputTest, BasicMethods) +{ + DSInput input; + + EXPECT_TRUE(true); +} diff --git a/tests/DSSeat-test.cpp b/tests/DSSeat-test.cpp index 72c53d9..40128cd 100644 --- a/tests/DSSeat-test.cpp +++ b/tests/DSSeat-test.cpp @@ -18,3 +18,12 @@ TEST_F(DSSeatTest, NewDSSeat) delete seat; ASSERT_TRUE(true); } + +TEST_F(DSSeatTest, BasicMethods) +{ + DSSeat seat; + DSInput input; + + EXPECT_TRUE(seat.addInput(&input) == true); + EXPECT_TRUE(seat.removeInput(&input) == true); +} -- 2.7.4 From 11252e4121a0f4e0d0a487a20f8d062c376edc61 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 18 Jun 2020 11:25:19 +0900 Subject: [PATCH 11/16] implement the skeleton methods of DSOutput At this time, the test case fails. Change-Id: I4104111532b51f01e92849d51ee57fdac5e0631a --- src/DSOutput/DSOutput.cpp | 14 +++++++++++--- src/DSOutput/DSOutput.h | 8 ++++++-- tests/DSOutput-test.cpp | 13 +++++-------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/DSOutput/DSOutput.cpp b/src/DSOutput/DSOutput.cpp index db3e5bd..c9a18e7 100644 --- a/src/DSOutput/DSOutput.cpp +++ b/src/DSOutput/DSOutput.cpp @@ -2,7 +2,9 @@ namespace display_server { -DSOutput::DSOutput() : resolutionWidth(1280), resolutionHeight(720) +DSOutput::DSOutput() + : __resolutionWidth(0), + __resolutionHeight(0) {} DSOutput::~DSOutput() @@ -10,11 +12,17 @@ DSOutput::~DSOutput() int DSOutput::getResolutionWidth() { - return resolutionWidth; + return __resolutionWidth; } int DSOutput::getResolutionHeight() { - return resolutionHeight; + return __resolutionHeight; } + +bool DSOutput::applyResolutionAuto() +{ + return false; +} + } // namespace display_server diff --git a/src/DSOutput/DSOutput.h b/src/DSOutput/DSOutput.h index 0227a9a..47d279d 100644 --- a/src/DSOutput/DSOutput.h +++ b/src/DSOutput/DSOutput.h @@ -3,18 +3,22 @@ namespace display_server { + class DSOutput { public: DSOutput(); virtual ~DSOutput(); + int getResolutionWidth(); int getResolutionHeight(); + bool applyResolutionAuto(); private: - int resolutionWidth; - int resolutionHeight; + int __resolutionWidth; + int __resolutionHeight; }; + } #endif diff --git a/tests/DSOutput-test.cpp b/tests/DSOutput-test.cpp index 9c610e8..5b8b046 100644 --- a/tests/DSOutput-test.cpp +++ b/tests/DSOutput-test.cpp @@ -19,14 +19,11 @@ TEST_F(DSOutputTest, NewDSOutput) ASSERT_TRUE(true); } -TEST_F(DSOutputTest, GetResolutionWidthHeight) +TEST_F(DSOutputTest, BasicMethods) { - DSOutput *output = new DSOutput; - - int width = output->getResolutionWidth(); - EXPECT_TRUE(width == 1280); - int height = output->getResolutionHeight(); - EXPECT_TRUE(height == 720); + DSOutput output; - delete output; + EXPECT_TRUE(output.getResolutionWidth() != 0); + EXPECT_TRUE(output.getResolutionHeight() != 0); + EXPECT_TRUE(output.applyResolutionAuto() == true); } -- 2.7.4 From 5f1bb2e8992a5fe6619bb184237151235e013cb7 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 18 Jun 2020 10:35:35 +0900 Subject: [PATCH 12/16] implement the skeleton methods of DSPolicyArea At this time, the test case fails. Change-Id: I843c7a5c0cf9fd5a5de7cfc41919af7902ce8e78 --- src/DSPolicyArea/DSPolicyArea.cpp | 21 +++++++++++++++++++++ src/DSPolicyArea/DSPolicyArea.h | 10 +++++++++- tests/DSPolicyArea-test.cpp | 10 ++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/DSPolicyArea/DSPolicyArea.cpp b/src/DSPolicyArea/DSPolicyArea.cpp index 9ed13e4..d9d1241 100644 --- a/src/DSPolicyArea/DSPolicyArea.cpp +++ b/src/DSPolicyArea/DSPolicyArea.cpp @@ -3,8 +3,29 @@ namespace display_server { DSPolicyArea::DSPolicyArea() + : __x(0), + __y(0), + __width(0), + __height(0), + __seat(nullptr) {} DSPolicyArea::~DSPolicyArea() {} + +bool DSPolicyArea::setPosition(int x, int y) +{ + return false; +} + +bool DSPolicyArea::setSize(int width, int height) +{ + return false; +} + +bool DSPolicyArea::attachSeat(DSSeat *seat) +{ + return false; +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSPolicyArea/DSPolicyArea.h b/src/DSPolicyArea/DSPolicyArea.h index aeaa130..9264548 100644 --- a/src/DSPolicyArea/DSPolicyArea.h +++ b/src/DSPolicyArea/DSPolicyArea.h @@ -1,6 +1,8 @@ #ifndef _DSPOLICYAREA_H_ #define _DSPOLICYAREA_H_ +#include + namespace display_server { class DSPolicyArea @@ -9,8 +11,14 @@ public: DSPolicyArea(); virtual ~DSPolicyArea(); + bool setPosition(int x, int y); + bool setSize(int width, int height); + bool attachSeat(DSSeat *seat); + private: - /* data */ + int __x, __y; + int __width, __height; + DSSeat *__seat; }; } diff --git a/tests/DSPolicyArea-test.cpp b/tests/DSPolicyArea-test.cpp index a1a20e5..ed4e1a4 100644 --- a/tests/DSPolicyArea-test.cpp +++ b/tests/DSPolicyArea-test.cpp @@ -18,3 +18,13 @@ TEST_F(DSPolicyAreaTest, NewDSPolicyArea) delete policyArea; ASSERT_TRUE(true); } + +TEST_F(DSPolicyAreaTest, BasicMethods) +{ + DSPolicyArea policyArea; + DSSeat seat; + + EXPECT_TRUE(policyArea.setPosition(10, 10) == true); + EXPECT_TRUE(policyArea.setSize(100, 100) == true); + EXPECT_TRUE(policyArea.attachSeat(&seat) == true); +} \ No newline at end of file -- 2.7.4 From 88ffd991237ecc557c874ececbacf5227b78fdae Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 18 Jun 2020 10:46:46 +0900 Subject: [PATCH 13/16] implement the skeleton methods of DSCanvas At this time, the test case fails. Change-Id: I117ca29be31411724b8eed4760f102a1cc6ee2dd --- src/DSCanvas/DSCanvas.cpp | 14 ++++++++++++++ src/DSCanvas/DSCanvas.h | 9 ++++++++- tests/DSCanvas-test.cpp | 10 ++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/DSCanvas/DSCanvas.cpp b/src/DSCanvas/DSCanvas.cpp index 3465c5f..1dbb985 100644 --- a/src/DSCanvas/DSCanvas.cpp +++ b/src/DSCanvas/DSCanvas.cpp @@ -2,9 +2,23 @@ namespace display_server { + DSCanvas::DSCanvas() + : __polcyArea(nullptr), + __displayArea(nullptr) {} DSCanvas::~DSCanvas() {} + +bool DSCanvas::attachPolicyArea(DSPolicyArea *polcyArea) +{ + return false; +} + +bool DSCanvas::attachDisplayArea(DSDisplayArea *displayArea) +{ + return false; +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSCanvas/DSCanvas.h b/src/DSCanvas/DSCanvas.h index 47063ab..0d45cad 100644 --- a/src/DSCanvas/DSCanvas.h +++ b/src/DSCanvas/DSCanvas.h @@ -1,6 +1,9 @@ #ifndef _DSCANVAS_H_ #define _DSCANVAS_H_ +#include +#include + namespace display_server { class DSCanvas @@ -9,8 +12,12 @@ public: DSCanvas(); virtual ~DSCanvas(); + bool attachPolicyArea(DSPolicyArea *polcyArea); + bool attachDisplayArea(DSDisplayArea *displayArea); + private: - /* data */ + DSPolicyArea *__polcyArea; + DSDisplayArea *__displayArea; }; } diff --git a/tests/DSCanvas-test.cpp b/tests/DSCanvas-test.cpp index 5efc393..c9138df 100644 --- a/tests/DSCanvas-test.cpp +++ b/tests/DSCanvas-test.cpp @@ -18,3 +18,13 @@ TEST_F(DSCanvasTest, NewDSCanvas) delete canvas; ASSERT_TRUE(true); } + +TEST_F(DSCanvasTest, BasicMethods) +{ + DSCanvas canvas; + DSPolicyArea policyArea; + DSDisplayArea displayArea; + + EXPECT_TRUE(canvas.attachPolicyArea(&policyArea) == true); + EXPECT_TRUE(canvas.attachDisplayArea(&displayArea) == true); +} \ No newline at end of file -- 2.7.4 From db9ff85ea5d7b71cae62962aa62b9d245fbbc9c7 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 18 Jun 2020 11:18:03 +0900 Subject: [PATCH 14/16] implement the skeleton methods of DSDisplayArea At this time, the test case fails. Change-Id: I08d9229f16ede242a3a53154158e154211802e8e --- src/DSDisplayArea/DSDisplayArea.cpp | 35 +++++++++++++++++++++++++++++------ src/DSDisplayArea/DSDisplayArea.h | 9 ++++++++- tests/DSDisplayArea-test.cpp | 17 +++++++---------- 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 34cac5e..a3ab96b 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -2,28 +2,51 @@ namespace display_server { -DSDisplayArea::DSDisplayArea() : mOutput(nullptr) + +DSDisplayArea::DSDisplayArea() + : __output(nullptr), + __x(0), + __y(0), + __width(0), + __height(0) {} -DSDisplayArea::DSDisplayArea(DSOutput *output) : mOutput(output) +DSDisplayArea::DSDisplayArea(DSOutput *output) + : __output(output), + __x(0), + __y(0), + __width(0), + __height(0) {} DSDisplayArea::~DSDisplayArea() {} +bool DSDisplayArea::setPosition(int x, int y) +{ + // position to canvas. + return false; +} + +bool DSDisplayArea::setSize(int width, int height) +{ + return false; +} + int DSDisplayArea::getWidth() { - if (mOutput == nullptr) + if (__output == nullptr) return -1; - return mOutput->getResolutionWidth(); + return __width; } int DSDisplayArea::getHeight() { - if (mOutput == nullptr) + if (__output == nullptr) return -1; - return mOutput->getResolutionHeight(); + return __height; } + } // namespace display_server diff --git a/src/DSDisplayArea/DSDisplayArea.h b/src/DSDisplayArea/DSDisplayArea.h index 1adaf3a..3e3cc99 100644 --- a/src/DSDisplayArea/DSDisplayArea.h +++ b/src/DSDisplayArea/DSDisplayArea.h @@ -7,16 +7,23 @@ namespace display_server { class DSDisplayArea { + public: DSDisplayArea(); DSDisplayArea(DSOutput *output); virtual ~DSDisplayArea(); + + bool setPosition(int x, int y); + bool setSize(int width, int height); int getWidth(); int getHeight(); private: - DSOutput *mOutput; + DSOutput *__output; + int __x, __y; + int __width, __height; }; + } #endif diff --git a/tests/DSDisplayArea-test.cpp b/tests/DSDisplayArea-test.cpp index c967a60..a8de0ad 100644 --- a/tests/DSDisplayArea-test.cpp +++ b/tests/DSDisplayArea-test.cpp @@ -25,16 +25,13 @@ TEST_F(DSDisplayAreaTest, NewDSDisplayArea) ASSERT_TRUE(true); } -TEST_F(DSDisplayAreaTest, GetWidthHeight) +TEST_F(DSDisplayAreaTest, BasicMethods) { - DSOutput *output = new DSOutput; - DSDisplayArea *displayArea = new DSDisplayArea(output); - - int width = displayArea->getWidth(); - EXPECT_TRUE(width == 1280); + DSOutput output; + DSDisplayArea displayArea(&output); - int height = displayArea->getHeight(); - EXPECT_TRUE(height == 720); - - delete displayArea; + EXPECT_TRUE(displayArea.setPosition(0, 0) != 0); + EXPECT_TRUE(displayArea.setSize(100, 100) != 0); + EXPECT_TRUE(displayArea.getHeight() != 0); + EXPECT_TRUE(displayArea.getWidth() != 0); } -- 2.7.4 From dcf7dbe3788c1ad2eba5eda695ac8b2eeca699c8 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 22 Jun 2020 10:47:12 +0900 Subject: [PATCH 15/16] DSSignal: use std::function as the paremeter of the connect method. use std::function instead of the raw function pointer. Change-Id: I02e368c09e6f673fc8881842694296d171ff9369 --- src/DSObject/IDSObjectObserver.h | 2 +- src/DSSignal/DSSignal.h | 42 +++++++++++------------ tests/DSSignal-test.cpp | 74 ++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 4 files changed, 97 insertions(+), 22 deletions(-) create mode 100644 tests/DSSignal-test.cpp diff --git a/src/DSObject/IDSObjectObserver.h b/src/DSObject/IDSObjectObserver.h index 494633a..6f36717 100644 --- a/src/DSObject/IDSObjectObserver.h +++ b/src/DSObject/IDSObjectObserver.h @@ -10,7 +10,7 @@ class IDSObjectObserver { public: virtual ~IDSObjectObserver() = default; - virtual void destroyed(DSObject *obj) = 0; + virtual void destroyed(DSObject *slot) = 0; }; } diff --git a/src/DSSignal/DSSignal.h b/src/DSSignal/DSSignal.h index fd40342..eedf0a7 100644 --- a/src/DSSignal/DSSignal.h +++ b/src/DSSignal/DSSignal.h @@ -2,10 +2,11 @@ #define __DS_SIGNAL_H_ #include "DSObject.h" -#include -#include #include #include +#include +#include +#include namespace display_server { @@ -13,10 +14,10 @@ namespace display_server class DSSlotsObserver : public IDSObjectObserver { public: - DSSlotsObserver() {} - ~DSSlotsObserver() {} + DSSlotsObserver() = default; + ~DSSlotsObserver() = default; - virtual void destroyed(DSObject *obj); + virtual void destroyed(DSObject *slot); virtual void addSlot(DSObject *slot); protected: @@ -28,14 +29,14 @@ class DSSlotConnection : public DSSlotsObserver { public: DSSlotConnection() - {} - - DSSlotConnection(DSObject *slot, void (*func)(Args...)) - : __callback(func) + : __func(nullptr) + {}; + DSSlotConnection(DSObject *slot, std::function func) + : __func(std::move(func)) { //TODO: make callback as callback iface //std::unique_ptr ptr(new DSCallbackIface(func)); - //__callback = std::move(ptr); + //__func = std::move(ptr); addSlot(slot); } @@ -49,8 +50,9 @@ public: void addSlot(DSObject *slot) override { - _slotList.push_back(slot); slot->attachDestroyObserver(this); + + _slotList.push_back(slot); } void destroyed(DSObject *slot) override @@ -64,13 +66,13 @@ public: void invoke(Args... args) { if (!_slotList.empty()) - __callback(args...); + std::invoke(__func, args...); } private: //TODO: make callback as callback iface - //std::unique_ptr __callback; - void (*__callback)(Args...); + //std::unique_ptr __func; + std::function __func; template friend class DSSignal; }; @@ -79,10 +81,8 @@ template class DSSignal { public: - DSSignal() - {} - virtual ~DSSignal() - {} + DSSignal() = default; + virtual ~DSSignal() = default; // functor DSSignal &operator()(void) @@ -90,7 +90,7 @@ public: return *this; } - void connect(DSObject *slot, void (*func)(Args...)) + void connect(DSObject *slot, std::function func) { if ((!slot) || (!func)) return; @@ -108,10 +108,10 @@ public: } private: - DSSlotConnection *__findConnection(void (*func)(Args...)) + DSSlotConnection *__findConnection(std::function func) { for (auto &&connection : __connectionList) { - if (connection->__callback == func) + if (&connection->__func == &func) return connection.get(); } diff --git a/tests/DSSignal-test.cpp b/tests/DSSignal-test.cpp new file mode 100644 index 0000000..7348b3f --- /dev/null +++ b/tests/DSSignal-test.cpp @@ -0,0 +1,74 @@ +#include "libds-tests.h" +#include "DSSignal.h" +#include "DSDebugLog.h" + +using namespace display_server; + +class DSSignalTest : public ::testing::Test +{ +public: + void SetUp(void) override + {} + void TearDown(void) override + {} +}; + +class SenderMock : public DSObject +{ +public: + SenderMock() + : signalA(std::make_unique>()), + signalB(std::make_unique>()) + {} + ~SenderMock() = default; + + void emitSignalA(int value) { + signalA->emit(value); + } + + void emitSignalB(double value) { + signalB->emit(value); + } + + std::unique_ptr> signalA; + std::unique_ptr> signalB; +}; + +class ReceiverMock : public DSObject +{ +public: + ReceiverMock(std::shared_ptr sender) + : __sender(sender) + { + sender->signalA->connect(this, std::bind(&ReceiverMock::slotA, this, std::placeholders::_1)); + sender->signalB->connect(this, std::bind(&ReceiverMock::slotB, this, std::placeholders::_1)); + } + ~ReceiverMock() = default; + + void slotA(int value) { + DSLOG_INF("DSTEST", "%s is invoked! : value, %d\n", __func__, value); + } + + void slotB(double value) { + DSLOG_INF("DSTEST", "%s is invoked! : value, %lf\n", __func__, value); + } + +private: + std::shared_ptr __sender; +}; + +TEST_F(DSSignalTest, CreateSignal) +{ + DSSignal *signal = new DSSignal(); + delete signal; + ASSERT_TRUE(true); +} + +TEST_F(DSSignalTest, ConnectSignal) +{ + auto sender1 = std::make_shared(); + auto receiver = std::make_unique(sender1); + + sender1->emitSignalA(30); + sender1->emitSignalB(3.0); +} diff --git a/tests/meson.build b/tests/meson.build index 03e11ea..e181ae3 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -14,6 +14,7 @@ libds_tests_srcs = [ 'DSDisplayArea-test.cpp', 'DSDebugLog-test.cpp', 'DSDisplayDeviceTDMImpl-test.cpp', + 'DSSignal-test.cpp', ] gmock_dep = dependency('gmock', method : 'pkg-config') -- 2.7.4 From 5c031f3d3c1eff6a509eb2d49e94abfda105c41a Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 23 Jun 2020 15:45:57 +0900 Subject: [PATCH 16/16] DSDisplayDeviceOutput: implement the output callback of the OutputTDM implements There are five callback functions for the DeviceOuput. IDSDisplayDevice class has OutputAdded and OutputRemoved callbacks. virtual void registerCallbackOutputAdded(DSObject *slot, std::function func) = 0; virtual void registerCallbackOutputRemoved(DSObject *slot, std::function func) = 0; IDSDisplayDeviceOutput class has OutputConnected, OutputDisconnected and OutputResolutionSet callbacks. virtual void registerCallbackOutputConnected(DSObject *slot, std::function func) = 0; virtual void registerCallbackOutputDisconnected(DSObject *slot, std::function func) = 0; virtual void registerCallbackOutputResolutionSet(DSObject *slot, std::function func) = 0; DSDisplayDeviceTDMImpl and DSDisplayDeviceOutputTDMImpl override these functions and implement them. Change-Id: If76a02aa5348d5e1b5827960e86c2de55729792f --- .../DSDisplayDeviceOutputTDMImpl.cpp | 45 +++++++++ src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h | 23 +++-- src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp | 25 +++++ src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h | 13 +++ src/DSDisplayDevice/IDSDisplayDevice.h | 7 +- src/DSDisplayDevice/IDSDisplayDeviceOutput.h | 16 ++-- tests/DSDisplayDeviceTDMImpl-test.cpp | 105 +++++++++++++++++++++ 7 files changed, 218 insertions(+), 16 deletions(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp index 6032cc5..9941820 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp @@ -5,6 +5,21 @@ namespace display_server { + +DSDisplayDeviceOutputTDMImpl::DSDisplayDeviceOutputTDMImpl() + : __toutput(nullptr), + __resolutionWidth(0), + __resolutionHeight(0), + __physicalMMWidth(0), + __physicalMMHeight(0), + __mode(nullptr), + __dpmsMode(IDSDisplayDeviceOutput::DPMS_OFF), + __displayDeviceHWC(nullptr) +{ + __initializeConnectorType(); + __updateConnectState(); +} + DSDisplayDeviceOutputTDMImpl::DSDisplayDeviceOutputTDMImpl(tdm_output *toutput) : __toutput(toutput), __resolutionWidth(0), @@ -234,4 +249,34 @@ void DSDisplayDeviceOutputTDMImpl::__updateAvailableModeList() } } +void DSDisplayDeviceOutputTDMImpl::registerCallbackOutputConnected(DSObject *slot, std::function func) +{ + this->__connectedSignal.connect(slot, func); +} + +void DSDisplayDeviceOutputTDMImpl::registerCallbackOutputDisconnected(DSObject *slot, std::function func) +{ + this->__disconnectedSignal.connect(slot, func); +} + +void DSDisplayDeviceOutputTDMImpl::registerCallbackOutputResolutionSet(DSObject *slot, std::function func) +{ + this->__resolutionSetSignal.connect(slot, func); +} + +void DSDisplayDeviceOutputTDMImpl::callCallbackOutputConnected() +{ + this->__connectedSignal.emit(this); +} + +void DSDisplayDeviceOutputTDMImpl::callCallbackOutputDisconnected() +{ + this->__disconnectedSignal.emit(this); +} + +void DSDisplayDeviceOutputTDMImpl::callCallbackOutputResolutionSet() +{ + this->__resolutionSetSignal.emit(this); +} + } // namespace display_server diff --git a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h index ba3041a..82dba0d 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h @@ -3,6 +3,7 @@ #include "IDSDisplayDeviceOutput.h" #include "IDSDisplayDeviceHWC.h" +#include "DSSignal.h" #include namespace display_server @@ -10,6 +11,7 @@ namespace display_server class DSDisplayDeviceOutputTDMImpl : public IDSDisplayDeviceOutput { public: + DSDisplayDeviceOutputTDMImpl(); DSDisplayDeviceOutputTDMImpl(tdm_output *toutput); ~DSDisplayDeviceOutputTDMImpl(); @@ -26,12 +28,16 @@ public: DPMSMode getDPMSMode() override; IDSDisplayDeviceHWC *getHWC() override; - //TODO: int CallbackOutputAdded() override; - //TODO: int CallbackOutputRemoved() override; - //TODO: int CallbackOutputConnected() override; - //TODO: int CallbackOutputDisconnected() override; - //TODO: int CallbackOutputResolutionSet() override; - //TODO: int CallbackOutputVBlankTriggered() override; + // register callback functions + void registerCallbackOutputConnected(DSObject *slot, std::function func) override; + void registerCallbackOutputDisconnected(DSObject *slot, std::function func) override; + void registerCallbackOutputResolutionSet(DSObject *slot, std::function func) override; + + // emit functions + void callCallbackOutputConnected(); + void callCallbackOutputDisconnected(); + void callCallbackOutputResolutionSet(); + private: void __initializeConnectorType(); void __updateConnectState(); @@ -50,6 +56,11 @@ private: IDSDisplayDeviceOutput::DPMSMode __dpmsMode; IDSDisplayDeviceHWC *__displayDeviceHWC; + + // signals + DSSignal __connectedSignal; + DSSignal __disconnectedSignal; + DSSignal __resolutionSetSignal; }; } diff --git a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp index f79af90..66e35e5 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp @@ -41,9 +41,34 @@ std::list DSDisplayDeviceTDMImpl::getOutputList() } deviceOutput = new DSDisplayDeviceOutputTDMImpl(toutput); __outputList.emplace_back(deviceOutput); + + // emit the output added signal + this->__outputAddedSignal.emit(deviceOutput); } return __outputList; } +void DSDisplayDeviceTDMImpl::registerCallbackOutputAdded(DSObject *slot, std::function func) +{ + this->__outputAddedSignal.connect(slot, func); +} + +void DSDisplayDeviceTDMImpl::registerCallbackOutputRemoved(DSObject *slot, std::function func) +{ + this->__outputRemovedSignal.connect(slot, func); +} + +void DSDisplayDeviceTDMImpl::callCallbackOutputAdded() +{ + //TODO: create the new IDSDisplayDeviceOutput instance and put the parameter of the emit function. + this->__outputAddedSignal.emit(nullptr); +} + +void DSDisplayDeviceTDMImpl::callCallbackOutputRemoved() +{ + //TODO: create the new IDSDisplayDeviceOutput instance and put the parameter of the emit function. + this->__outputRemovedSignal.emit(nullptr); +} + } // namespace display_server diff --git a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h index 8585152..013d1e4 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h @@ -2,6 +2,7 @@ #define _DS_DISPLAY_DEVICE_TDM_IMPL_H_ #include "IDSDisplayDevice.h" +#include "DSSignal.h" #include namespace display_server @@ -14,10 +15,22 @@ public: std::list getOutputList() override; + // register callback functions + void registerCallbackOutputAdded(DSObject *slot, std::function func) override; + void registerCallbackOutputRemoved(DSObject *slot, std::function func) override; + + // emit functions + void callCallbackOutputAdded(); + void callCallbackOutputRemoved(); + private: tdm_display *__tdisplay; int __numOutputs; std::list __outputList; + + // signals + DSSignal __outputAddedSignal; + DSSignal __outputRemovedSignal; }; } diff --git a/src/DSDisplayDevice/IDSDisplayDevice.h b/src/DSDisplayDevice/IDSDisplayDevice.h index cccc9f0..ea03a3e 100644 --- a/src/DSDisplayDevice/IDSDisplayDevice.h +++ b/src/DSDisplayDevice/IDSDisplayDevice.h @@ -1,17 +1,20 @@ #ifndef _I_DS_DISPLAY_DEVICE_H_ #define _I_DS_DISPLAY_DEVICE_H_ +#include "DSObject.h" +#include "IDSDisplayDeviceOutput.h" #include -#include namespace display_server { -class IDSDisplayDevice +class IDSDisplayDevice : public DSObject { public: virtual ~IDSDisplayDevice() = default; virtual std::list getOutputList() = 0; + virtual void registerCallbackOutputAdded(DSObject *slot, std::function func) = 0; + virtual void registerCallbackOutputRemoved(DSObject *slot, std::function func) = 0; }; } diff --git a/src/DSDisplayDevice/IDSDisplayDeviceOutput.h b/src/DSDisplayDevice/IDSDisplayDeviceOutput.h index 4492c1a..9f0df9f 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceOutput.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceOutput.h @@ -1,9 +1,11 @@ #ifndef _I_DS_DISPLAY_DEVICE_OUTPUT_H_ #define _I_DS_DISPLAY_DEVICE_OUTPUT_H_ +#include "DSObject.h" +#include "IDSDisplayDeviceHWC.h" #include #include -#include "IDSDisplayDeviceHWC.h" +#include #define NAME_LEN 64 @@ -21,7 +23,7 @@ typedef struct _DSDisplayDeviceOutputMode { const void *private_mode; } DSDisplayDeviceOutputMode; -class IDSDisplayDeviceOutput +class IDSDisplayDeviceOutput : public DSObject { public: enum ConnectState { @@ -73,12 +75,10 @@ public: virtual DPMSMode getDPMSMode() = 0; virtual IDSDisplayDeviceHWC *getHWC() = 0; - //TODO: virtual int CallbackOutputAdded() = 0; - //TODO: virtual int CallbackOutputRemoved() = 0; - //TODO: virtual int CallbackOutputConnected() = 0; - //TODO: virtual int CallbackOutputDisconnected() = 0; - //TODO: virtual int CallbackOutputResolutionSet() = 0; - //TODO: virtual int CallbackOutputVBlankTriggered() = 0; + // Callback methods + virtual void registerCallbackOutputConnected(DSObject *slot, std::function func) = 0; + virtual void registerCallbackOutputDisconnected(DSObject *slot, std::function func) = 0; + virtual void registerCallbackOutputResolutionSet(DSObject *slot, std::function func) = 0; }; } diff --git a/tests/DSDisplayDeviceTDMImpl-test.cpp b/tests/DSDisplayDeviceTDMImpl-test.cpp index 286282a..4255d9d 100644 --- a/tests/DSDisplayDeviceTDMImpl-test.cpp +++ b/tests/DSDisplayDeviceTDMImpl-test.cpp @@ -1,5 +1,6 @@ #include "libds-tests.h" #include "DSDisplayDeviceTDMImpl.h" +#include "DSDisplayDeviceOutputTDMImpl.h" using namespace display_server; @@ -18,6 +19,27 @@ public: }; // DSDisplayDeviceTDMImpl +class MockDisplayDevice : public DSObject +{ +public: + MockDisplayDevice() + : flagOutputAdded(false), + flagOutputRemoved(false) + {} + ~MockDisplayDevice() + {} + + void outputAdded(IDSDisplayDeviceOutput *output) { + flagOutputAdded = true; + } + + void outputRemoved(IDSDisplayDeviceOutput *output) { + flagOutputRemoved = true; + } + + bool flagOutputAdded; + bool flagOutputRemoved; +}; TEST_F(DSDisplayDeviceTDMImplTest, Device_New) { @@ -36,6 +58,29 @@ TEST_F(DSDisplayDeviceTDMImplTest, Device_getOutputList) delete dispayDevice; } +TEST_F(DSDisplayDeviceTDMImplTest, Device_OutputAdded) +{ + std::shared_ptr mockDisplayDevice = std::make_shared(); + std::unique_ptr displayDevice = std::make_unique(); + + displayDevice->registerCallbackOutputAdded(mockDisplayDevice.get(), std::bind(&MockDisplayDevice::outputAdded, mockDisplayDevice, std::placeholders::_1)); + displayDevice->callCallbackOutputAdded(); + + EXPECT_TRUE(mockDisplayDevice->flagOutputAdded); +} + +TEST_F(DSDisplayDeviceTDMImplTest, Device_OutputRemoved) +{ + //MockDisplayDevice *mockDisplayDevice = new MockDisplayDevice; + std::shared_ptr mockDisplayDevice = std::make_shared(); + std::unique_ptr displayDevice = std::make_unique(); + + displayDevice->registerCallbackOutputRemoved(mockDisplayDevice.get(), std::bind(&MockDisplayDevice::outputRemoved, mockDisplayDevice, std::placeholders::_1)); + displayDevice->callCallbackOutputRemoved(); + + EXPECT_TRUE(mockDisplayDevice->flagOutputRemoved); +} + // DSDisplayDeviceTDMOutputImpl TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_getInitialValues) @@ -115,6 +160,66 @@ TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_setModeBestResolution) delete dispayDevice; } +class MockDisplayDeviceOutput : public DSObject +{ +public: + MockDisplayDeviceOutput() + : flagOutputConnected(false), + flagOutputDisconnected(false), + flagOutputResolutionSet(false) + {} + ~MockDisplayDeviceOutput() = default; + + void outputConnected(IDSDisplayDeviceOutput *deviceOuptut) { + flagOutputConnected = true; + } + + void outputDisconnected(IDSDisplayDeviceOutput *deviceOuptut) { + flagOutputDisconnected = true; + } + + void outputResolutionSet(IDSDisplayDeviceOutput *deviceOuptut) { + flagOutputResolutionSet = true; + } + + bool flagOutputConnected; + bool flagOutputDisconnected; + bool flagOutputResolutionSet; +}; + +TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_registerCallbackOutputConnected) +{ + std::shared_ptr mockDisplayDeviceOutput = std::make_shared(); + std::unique_ptr displayDeviceOutput = std::make_unique(); + + displayDeviceOutput->registerCallbackOutputConnected(mockDisplayDeviceOutput.get(), std::bind(&MockDisplayDeviceOutput::outputConnected, mockDisplayDeviceOutput, std::placeholders::_1)); + displayDeviceOutput->callCallbackOutputConnected(); + + EXPECT_TRUE(mockDisplayDeviceOutput->flagOutputConnected); +} + +TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_registerCallbackOutputDisconnected) +{ + std::shared_ptr mockDisplayDeviceOutput = std::make_shared(); + std::unique_ptr displayDeviceOutput = std::make_unique(); + + displayDeviceOutput->registerCallbackOutputDisconnected(mockDisplayDeviceOutput.get(), std::bind(&MockDisplayDeviceOutput::outputDisconnected, mockDisplayDeviceOutput, std::placeholders::_1)); + displayDeviceOutput->callCallbackOutputDisconnected(); + + EXPECT_TRUE(mockDisplayDeviceOutput->flagOutputDisconnected); +} + +TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_registerCallbackOutputResolutionSet) +{ + std::shared_ptr mockDisplayDeviceOutput = std::make_shared(); + std::unique_ptr displayDeviceOutput = std::make_unique(); + + displayDeviceOutput->registerCallbackOutputResolutionSet(mockDisplayDeviceOutput.get(), std::bind(&MockDisplayDeviceOutput::outputResolutionSet, mockDisplayDeviceOutput, std::placeholders::_1)); + displayDeviceOutput->callCallbackOutputResolutionSet(); + + EXPECT_TRUE(mockDisplayDeviceOutput->flagOutputResolutionSet); +} + // DSDisplayDeviceTDMHWC TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_createHWCWindow) -- 2.7.4