example : add mycompositor example. 08/241508/1
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 5 Jun 2020 07:22:34 +0000 (16:22 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 09:44:14 +0000 (18:44 +0900)
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 [new file with mode: 0644]

diff --git a/src/bin/example/exampleCompositor.cpp b/src/bin/example/exampleCompositor.cpp
new file mode 100644 (file)
index 0000000..1ade054
--- /dev/null
@@ -0,0 +1,107 @@
+#include <DSCompositor.h>
+#include <DSOutput.h>
+#include <DSInput.h>
+#include <DSCanvas.h>
+#include <DSSeat.h>
+#include <DSPolicyArea.h>
+#include <DSDisplayArea.h>
+
+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;
+}