]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/display.h
Track the currently focused window in Display
[libs/gui.git] / source / graphics / display.h
1 #ifndef MSP_GRAPHICS_DISPLAY_H_
2 #define MSP_GRAPHICS_DISPLAY_H_
3
4 #include <list>
5 #include <stdexcept>
6 #include <string>
7 #include <sigc++/signal.h>
8 #include "errordialog.h"
9 #include "monitor.h"
10 #include "videomode.h"
11
12 namespace Msp {
13 namespace Graphics {
14
15 class Window;
16
17 class Display
18 {
19 public:
20         struct Private;
21
22         sigc::signal<void> signal_got_focus;
23         sigc::signal<void> signal_lost_focus;
24
25 private:
26         std::list<Monitor> monitors;
27         Monitor *primary_monitor;
28         std::list<VideoMode> modes;
29         Private *priv;
30         ErrorDialog *err_dialog;
31         Window *focus_window;
32
33 public:
34         Display(const std::string &disp_name = std::string());
35         ~Display();
36
37         const Private &get_private() const { return *priv; }
38
39         void add_window(Window &);
40         void remove_window(Window &);
41
42         const std::list<Monitor> &get_monitors() const { return monitors; }
43         const std::list<VideoMode> &get_modes() const { return modes; }
44         const VideoMode &get_desktop_mode() const;
45         void set_mode(const VideoMode &, bool = false);
46         void restore_mode();
47         const VideoMode *find_mode(const VideoMode &, float = 0.5f) const;
48         const VideoMode *find_mode(unsigned, unsigned) const;
49
50 private:
51         void window_got_focus(Window &);
52         void window_lost_focus();
53 public:
54         Window *get_focus_window() const { return focus_window; }
55
56 public:
57         void tick();
58 private:
59         bool process_events();
60 public:
61         void check_error();
62 };
63
64 } // namespace Graphics
65 } // namespace Msp
66
67 #endif