2 * Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #include <DSCompositor.h>
25 #include <IDSOutput.h>
29 #include <DSPolicyArea.h>
30 #include <DSDisplayArea.h>
31 #include <DSTextInput.h>
32 #include "DSDebugLog.h"
34 using namespace display_server;
36 // MyCompositor has to inherit DSCompositor.
37 class MyCompositor : public DSCompositor
43 __policyArea{nullptr},
44 __displayArea{nullptr}
47 virtual ~MyCompositor()
50 // The _onInitialized is called when the DSCompositor is ready to run.
51 // Make a seat and a policy area. Attach the seat to the policy area.
52 // Attach the policy area and the display area to canvas and return it.
53 std::shared_ptr<DSCanvas> _onInitialized() override
55 int width = __displayArea->getWidth();
56 int height = __displayArea->getHeight();
59 __seat = std::make_shared<DSSeat>(this, "default");
61 __policyArea = std::make_shared<DSPolicyArea>();
62 __policyArea->setPosition(0, 0);
63 __policyArea->setSize(width, height);
64 __policyArea->attachSeat(__seat);
66 __canvas = std::make_shared<DSCanvas>();
68 __canvas->attachPolicyArea(__policyArea);
69 __canvas->attachDisplayArea(__displayArea);
71 __textInput = std::make_shared<DSTextInput>();
76 // The _onOutputAdded is called when the IDSOutput is added.
77 void _onOutputAdded(std::shared_ptr<IDSOutput> output) override
79 // set the resolution.
80 output->applyResolutionAuto();
82 // make a display area.
83 __displayArea = std::make_shared<DSDisplayArea>(output);
86 // The _onOutputAdded is called when the IDSOutput is removed.
87 void _onOutputRemoved(std::shared_ptr<IDSOutput> output) override
89 __displayArea.reset(); // delete shared_ptr
93 void _onInputAdded(std::shared_ptr<DSInput> input) override
97 void _onInputRemoved(std::shared_ptr<DSInput> input) override
101 std::shared_ptr<DSCanvas> __canvas;
102 std::shared_ptr<DSSeat> __seat;
103 std::shared_ptr<DSPolicyArea> __policyArea;
104 std::shared_ptr<DSDisplayArea> __displayArea;
105 std::shared_ptr<DSTextInput> __textInput;
109 DSCompositor *compositor = new MyCompositor();