-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathwf-shell-app.hpp
More file actions
100 lines (84 loc) · 2.86 KB
/
wf-shell-app.hpp
File metadata and controls
100 lines (84 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#pragma once
#include <memory>
#include <string>
#include <wayfire/config/config-manager.hpp>
#include <gtkmm/application.h>
#include <gdkmm/monitor.h>
#include <gtkmm/cssprovider.h>
#include "wayfire-shell-unstable-v2-client-protocol.h"
using GMonitor = Glib::RefPtr<Gdk::Monitor>;
/**
* Represents a single output
*/
struct WayfireOutput
{
GMonitor monitor;
wl_output *wo;
zwf_output_v2 *output;
sigc::signal<void()> toggle_menu_signal();
sigc::signal<void()> m_toggle_menu_signal;
WayfireOutput(const GMonitor& monitor, zwf_shell_manager_v2 *zwf_manager);
~WayfireOutput();
};
/**
* A basic shell application.
*
* It is suitable for applications that need to show one or more windows
* per monitor.
*/
class WayfireShellApp
{
private:
std::vector<std::unique_ptr<WayfireOutput>> monitors;
std::vector<Glib::RefPtr<Gtk::CssProvider>> css_rules;
protected:
/** This should be initialized by the subclass in each program which uses
* wf-shell-app */
bool alternative_monitors = false; /* Used to skip monitor management in lockscreen */
static std::unique_ptr<WayfireShellApp> instance;
std::optional<std::string> cmdline_config;
std::optional<std::string> cmdline_css;
Glib::RefPtr<Gtk::Application> app;
bool activated = false;
void output_list_updated(int pos, int rem, int add);
virtual void add_output(GMonitor monitor);
virtual void rem_output(GMonitor monitor);
/* The following functions can be overridden in the shell implementation to
* handle the events */
virtual void on_activate();
virtual bool parse_cfgfile(const Glib::ustring & option_name,
const Glib::ustring & value, bool has_value);
virtual bool parse_cssfile(const Glib::ustring & option_name,
const Glib::ustring & value, bool has_value);
virtual void handle_new_output(WayfireOutput *output)
{}
virtual void handle_output_removed(WayfireOutput *output)
{}
public:
int inotify_fd;
int inotify_css_fd;
wf::config::config_manager_t config;
zwf_shell_manager_v2 *wf_shell_manager = nullptr;
WayfireShellApp();
virtual ~WayfireShellApp();
void init_app();
virtual std::string get_config_file();
virtual std::string get_css_config_dir();
virtual void run(int argc, char **argv);
virtual void command_line()
{}
virtual void on_config_reload()
{}
void on_css_reload();
void clear_css_rules();
void add_css_file(std::string file, int priority);
virtual Gio::Application::Flags get_extra_application_flags();
virtual std::string get_application_name() = 0;
std::vector<std::unique_ptr<WayfireOutput>> *get_wayfire_outputs();
/**
* WayfireShellApp is a singleton class.
* Using this function, any part of the application can get access to the
* shell app.
*/
static WayfireShellApp& get();
};