Wayland cOMPositor written in C++ using Louvre.
1/* ========================================================================
2 *
3 * Filename: WCompositor.cpp
4 * Description: W Compositor class definitions
5 * GitHub Repo: https://github.com/diego-est/womp
6 * Author: Diego A. Estrada Rivera
7 * License: GPL-3.0
8 *
9 * ======================================================================== */
10#include "WCompositor.hpp"
11#include "WOutput.hpp"
12#include "WPointer.hpp"
13#include "WSurface.hpp"
14#include "prelude.hpp"
15#include <LOutput.h>
16#include <LSceneView.h>
17
18WCompositor::WCompositor() noexcept
19 : LCompositor(), scene(), backgroundLayer(scene.mainView()),
20 surfacesLayer(scene.mainView()), overlayLayer(scene.mainView()),
21 fullscreenLayer(scene.mainView()), cursorLayer(scene.mainView()),
22 softwareCursor(nullptr, &cursorLayer)
23{
24 // set black as the scene clear color
25 scene.mainView()->setClearColor(0.f, 0.f, 0.f, 1.f);
26
27 // this allows us to define a custom size to an LTextureView
28 softwareCursor.enableDstSize(true);
29}
30
31void WCompositor::initialized() noexcept
32{
33 // set a keyboard with dvorax layout
34 seat()->keyboard()->setKeymap(nullptr, nullptr, "us", "dvorak");
35
36 var totalWidth = 0;
37
38 // initialize all available outputs
39 for (Handle<LOutput> output : seat()->outputs()) {
40 // set double scale to outputs with DPI >= 200
41 output->setScale(output->dpi() >= 200 ? 2 : 1);
42
43 output->setPos(LPoint(totalWidth, 0));
44 totalWidth += output->size().w();
45
46 addOutput(output);
47 output->repaint();
48 }
49}
50
51fn WCompositor::createOutputRequest() noexcept -> Handle<LOutput>
52{
53 return new WOutput;
54}
55fn WCompositor::createSurfaceRequest(Handle<LSurface::Params> params) noexcept
56 -> Handle<LSurface>
57{
58 return new WSurface(params);
59}
60
61fn WCompositor::createPointerRequest(Handle<LPointer::Params> params) noexcept
62 -> Handle<LPointer>
63{
64 return new WPointer(params);
65}