Wayland cOMPositor written in C++ using Louvre.
1/* ========================================================================
2 *
3 * Filename: WTopBar.cpp
4 * Description: W Compositor top bar 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 "WTopBar.hpp"
11#include "WCompositor.hpp"
12#include "WOutput.hpp"
13#include "WTopBarItem.hpp"
14#include "global.hpp"
15
16WTopBar::WTopBar(Handle<WOutput> output) noexcept
17 : output(output), view(0.f, 0.f, 0.f, 0.8f, &G::compositor()->overlayLayer)
18{
19 // copy thumbnails from an already initialized output
20 for (let o : G::outputs()) {
21 if (o == output)
22 continue;
23
24 for (let item : Ref<std::list<Handle<WTopBarItem>>>(
25 o->topBar->view.children()))
26 new WTopBarItem(this, item->surface);
27
28 break;
29 }
30 update();
31}
32
33WTopBar::~WTopBar() noexcept
34{
35 while (not view.children().empty())
36 delete view.children().back();
37}
38
39void WTopBar::update() noexcept
40{
41 view.setSize(output->size().w(), TOPBAR_HEIGHT);
42 view.setPos(output->pos());
43
44 // update thumbnails
45 for (var x = TOPBAR_PADDING;
46 let item : Ref<std::list<Handle<WTopBarItem>>>(view.children())) {
47 item->setPos(x, TOPBAR_PADDING);
48 x += item->size().w() + THUMBNAIL_MARGIN;
49 }
50
51 output->repaint();
52}