all repos — openbox @ ace8c8896aa13a6fc4e489277cf9c96f49175322

openbox fork - make it a bit more like ryudo

src/basedisplay.hh (raw)

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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// -*- mode: C++; indent-tabs-mode: nil; -*-
#ifndef   __BaseDisplay_hh
#define   __BaseDisplay_hh

#include "screeninfo.hh"
#include "timer.hh"

extern "C" {
#include <X11/Xlib.h>
#include <X11/Xatom.h>
}

#include <vector>

// forward declaration
class BGCCache;

class BaseDisplay: public TimerQueueManager {
private:
  struct BShape {
    bool extensions;
    int event_basep, error_basep;
  };
  BShape shape;

#ifdef    XINERAMA
  struct BXinerama {
    bool extensions;
    int event_basep, error_basep;
    int major, minor; // version
  };
  BXinerama xinerama;
#endif // XINERAMA

  unsigned int MaskList[8];
  size_t MaskListLength;

  enum RunState { STARTUP, RUNNING, SHUTDOWN };
  RunState run_state;

  Display *display;
  mutable BGCCache *gccache;

  typedef std::vector<ScreenInfo> ScreenInfoList;
  ScreenInfoList screenInfoList;
  TimerQueue timerList;

  const char *display_name, *application_name;

  // no copying!
  BaseDisplay(const BaseDisplay &);
  BaseDisplay& operator=(const BaseDisplay&);

protected:
  // pure virtual function... you must override this
  virtual void process_event(XEvent *e) = 0;

  // the masks of the modifiers which are ignored in button events.
  int NumLockMask, ScrollLockMask;


public:
  BaseDisplay(const char *app_name, const char *dpy_name = 0);
  virtual ~BaseDisplay(void);

  const ScreenInfo* getScreenInfo(const unsigned int s) const;

  BGCCache *gcCache(void) const;

  inline bool hasShapeExtensions(void) const
    { return shape.extensions; }
#ifdef    XINERAMA
  inline bool hasXineramaExtensions(void) const
    { return xinerama.extensions; }
#endif // XINERAMA
  inline bool doShutdown(void) const
    { return run_state == SHUTDOWN; }
  inline bool isStartup(void) const
    { return run_state == STARTUP; }

  inline Display *getXDisplay(void) const { return display; }

  inline const char *getXDisplayName(void) const
    { return display_name; }
  inline const char *getApplicationName(void) const
    { return application_name; }

  inline unsigned int getNumberOfScreens(void) const
    { return screenInfoList.size(); }
  inline int getShapeEventBase(void) const
    { return shape.event_basep; }
#ifdef    XINERAMA
  inline int getXineramaMajorVersion(void) const
    { return xinerama.major; }
#endif // XINERAMA

  inline void shutdown(void) { run_state = SHUTDOWN; }
  inline void run(void) { run_state = RUNNING; }

  void grabButton(unsigned int button, unsigned int modifiers,
                  Window grab_window, bool owner_events,
                  unsigned int event_mask, int pointer_mode,
                  int keyboard_mode, Window confine_to, Cursor cursor,
                  bool allow_scroll_lock) const;
  void ungrabButton(unsigned int button, unsigned int modifiers,
                    Window grab_window) const;

  void eventLoop(void);

  // from TimerQueueManager interface
  virtual void addTimer(BTimer *timer);
  virtual void removeTimer(BTimer *timer);

  // another pure virtual... this is used to handle signals that BaseDisplay
  // doesn't understand itself
  virtual bool handleSignal(int sig) = 0;
};


#endif // __BaseDisplay_hh