1/*
2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors.
3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com>
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#pragma once
10#include "../../Components/Base/BaseWindow.h"
11#include "../../Components/MenuBar/MenuItem.h"
12#include "../../IPC/Connection.h"
13#include "WindowFrame.h"
14#include <libfoundation/SharedBuffer.h>
15#include <libg/PixelBitmap.h>
16#include <libg/Rect.h>
17#include <sys/types.h>
18#include <utility>
19
20namespace WinServer::Desktop {
21
22class Window : public BaseWindow {
23public:
24 Window(int connection_id, int id, CreateWindowMessage& msg);
25 Window(Window&& win);
26
27 inline WindowFrame& frame() { return m_frame; }
28 inline const WindowFrame& frame() const { return m_frame; }
29
30 inline const LG::CornerMask& corner_mask() const { return m_corner_mask; }
31
32 inline std::vector<MenuDir>& menubar_content() { return m_menubar_content; }
33 inline const std::vector<MenuDir>& menubar_content() const { return m_menubar_content; }
34
35 void on_menubar_change();
36
37 virtual void did_app_title_change() override { m_frame.on_set_app_title(); }
38 virtual void did_icon_path_change() override { m_frame.on_set_icon(); }
39 virtual void did_size_change(const LG::Size& size) override;
40
41 inline void set_style(StatusBarStyle style) { m_frame.set_style(style), on_style_change(); }
42
43 void make_frame();
44 void make_frameless();
45
46private:
47 void recalc_bounds(const LG::Size& size);
48 void on_style_change();
49
50 WindowFrame m_frame;
51 LG::CornerMask m_corner_mask { LG::CornerMask::SystemRadius, LG::CornerMask::NonMasked, LG::CornerMask::Masked };
52 std::vector<MenuDir> m_menubar_content;
53};
54
55} // namespace WinServer