]> Dogcows Code - chaz/openbox/blob - src/basedisplay.hh
new code for bindings/callbacks. much sexier. now passes python classes back to the...
[chaz/openbox] / src / basedisplay.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef __BaseDisplay_hh
3 #define __BaseDisplay_hh
4
5 #include "screeninfo.hh"
6 #include "timer.hh"
7
8 extern "C" {
9 #include <X11/Xlib.h>
10 #include <X11/Xatom.h>
11 }
12
13 #include <vector>
14
15 // forward declaration
16 class BGCCache;
17
18 class BaseDisplay: public TimerQueueManager {
19 private:
20 struct BShape {
21 bool extensions;
22 int event_basep, error_basep;
23 };
24 BShape shape;
25
26 #ifdef XINERAMA
27 struct BXinerama {
28 bool extensions;
29 int event_basep, error_basep;
30 int major, minor; // version
31 };
32 BXinerama xinerama;
33 #endif // XINERAMA
34
35 unsigned int MaskList[8];
36 size_t MaskListLength;
37
38 enum RunState { STARTUP, RUNNING, SHUTDOWN };
39 RunState run_state;
40
41 Display *display;
42 mutable BGCCache *gccache;
43
44 typedef std::vector<ScreenInfo> ScreenInfoList;
45 ScreenInfoList screenInfoList;
46 TimerQueue timerList;
47
48 const char *display_name, *application_name;
49
50 // no copying!
51 BaseDisplay(const BaseDisplay &);
52 BaseDisplay& operator=(const BaseDisplay&);
53
54 protected:
55 // pure virtual function... you must override this
56 virtual void process_event(XEvent *e) = 0;
57
58 // the masks of the modifiers which are ignored in button events.
59 int NumLockMask, ScrollLockMask;
60
61
62 public:
63 BaseDisplay(const char *app_name, const char *dpy_name = 0);
64 virtual ~BaseDisplay(void);
65
66 const ScreenInfo* getScreenInfo(const unsigned int s) const;
67
68 BGCCache *gcCache(void) const;
69
70 inline bool hasShapeExtensions(void) const
71 { return shape.extensions; }
72 #ifdef XINERAMA
73 inline bool hasXineramaExtensions(void) const
74 { return xinerama.extensions; }
75 #endif // XINERAMA
76 inline bool doShutdown(void) const
77 { return run_state == SHUTDOWN; }
78 inline bool isStartup(void) const
79 { return run_state == STARTUP; }
80
81 inline Display *getXDisplay(void) const { return display; }
82
83 inline const char *getXDisplayName(void) const
84 { return display_name; }
85 inline const char *getApplicationName(void) const
86 { return application_name; }
87
88 inline unsigned int getNumberOfScreens(void) const
89 { return screenInfoList.size(); }
90 inline int getShapeEventBase(void) const
91 { return shape.event_basep; }
92 #ifdef XINERAMA
93 inline int getXineramaMajorVersion(void) const
94 { return xinerama.major; }
95 #endif // XINERAMA
96
97 inline void shutdown(void) { run_state = SHUTDOWN; }
98 inline void run(void) { run_state = RUNNING; }
99
100 void grabButton(unsigned int button, unsigned int modifiers,
101 Window grab_window, bool owner_events,
102 unsigned int event_mask, int pointer_mode,
103 int keyboard_mode, Window confine_to, Cursor cursor,
104 bool allow_scroll_lock) const;
105 void ungrabButton(unsigned int button, unsigned int modifiers,
106 Window grab_window) const;
107
108 void eventLoop(void);
109
110 // from TimerQueueManager interface
111 virtual void addTimer(BTimer *timer);
112 virtual void removeTimer(BTimer *timer);
113
114 // another pure virtual... this is used to handle signals that BaseDisplay
115 // doesn't understand itself
116 virtual bool handleSignal(int sig) = 0;
117 };
118
119
120 #endif // __BaseDisplay_hh
This page took 0.037131 seconds and 4 git commands to generate.