From e8c27094ab75a43d171b461fe797e8af77c4cef7 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 5 Jun 2020 16:22:34 +0900 Subject: [PATCH] example : add mycompositor example. This is a compositor example to be implemented with the public api of libds. This is a fist sample example for TDD. This example may be changed through the development of the libds. I think that this example is the fist step to implememnt the public api of libds. I hope that we can communitate with this sample at fist. Change-Id: Id556da71ad7fc32af2129fcb8a0a8369ddc48bfc --- src/bin/example/exampleCompositor.cpp | 107 ++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 src/bin/example/exampleCompositor.cpp diff --git a/src/bin/example/exampleCompositor.cpp b/src/bin/example/exampleCompositor.cpp new file mode 100644 index 0000000..1ade054 --- /dev/null +++ b/src/bin/example/exampleCompositor.cpp @@ -0,0 +1,107 @@ +#include +#include +#include +#include +#include +#include +#include + +using display_server; + +/* + 1. MyCompositor and DSCompositor are created. + 2. DSCompositor probes the InputDevice and the OutputDevice at the creation time. + 3. DSCompositor sends the InputAdd/Remove signals and the OutputAdd/Remove signal. + 4. MyCompositor gets those signals and set up outputs and inputs. + 5. MyCompositor configures the canvases with zones and outputs. + 6. MyCompositor configures the the seats with zones. +*/ + +// DSCompositor () +// initialization/deinitialize TDM +// initialization/deinitialize libinput +// initialization/deinitialize wl_server +// initialization event_loop +// call the output callbacks ( OutputAdd, OutputRemove, OutputResolutionSet) +// call the output callbacks ( InputAdd, InputRemove ) +// plugins loading??? + +// policyArea or screenArea ? +// policyRegion or screenRegion ? +// policyZone or screenZone ? +// displayArea or outputArea ? +// displayRegion or outputRegion ? +// displayZone or outputZone ? + +// DSCompositor listen signals. OutputAdd/Remove/ResolutionSet and InputAdd/Remove. +// compositor->connectSignal(DSOuptut::ADD_SIGNAL, DSCompositor::OutputAdd); +// compositor->connectSignal(DSOutput::REMOVE_SIGNAL, DSCompositor::OutputRemove); +// compositor->connectSignal(DSOutput::RESOLUTION_SET_SIGNAL, DSCompositor::OutputResolutionSet); +// compositor->connectSignal(DSInput::ADD_SIGNAL, DSCompositor::InputAdd); +// compositor->connectSignal(DSInput::REMOVE_SIGNAL, DSCompositor::InputRemove); + +class MyCompositor : public DSCompositor { +public: + MyCompositor() { + int width, height; + + width = displayArea.getWidth(); + height = displayArea.getHeight(); + + canvas = new Canvas(); + + policyArea = new DSPoliyArea(); + //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); + } + + virtual ~MyCompositor() { + delete policyArea; + delete canvas; + } + + 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 OutputRemove(DSOutput *output) { + delete displayArea; + } + + 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); + } + +private: + DSCanvas *canvas; + DSSeat *seat; + DSPolicyArea *policyArea; + DSDisplayArea *displayArea; +} + +int main() { + DSCompositor *compositor = new MyCompositor(); + + compositor->run(); + + delete compositor; +} -- 2.7.4