File: BaseDisplay.hh

package info (click to toggle)
bbpager 0.1.6-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 460 kB
  • ctags: 543
  • sloc: cpp: 4,335; sh: 327; makefile: 60
file content (128 lines) | stat: -rw-r--r-- 3,547 bytes parent folder | download
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
121
122
123
124
125
126
127
128
// BaseDisplay.hh for Blackbox - an X11 Window manager
// Copyright (c) 1997 - 1999 by Brad Hughes, bhughes@tcac.net
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//  
// (See the included file COPYING / GPL-2.0)
//

#ifndef   __BaseDisplay_hh
#define   __BaseDisplay_hh

#include <X11/Xlib.h>
#include <X11/Xatom.h>

#include "LinkedList.hh"

// forward declaration
class ScreenInfo;


class BaseDisplay {
private:
  struct cursor {
    Cursor session, move;
  } cursor;

  struct shape {
    Bool extensions;
    int event_basep, error_basep;
  } shape;

  Atom xa_wm_colormap_windows, xa_wm_protocols, xa_wm_state,
    xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state,
    motif_wm_hints;
  Bool _startup, _shutdown;
  Display *display;

  LinkedList<ScreenInfo> *screenInfoList;

  char *display_name;
  int number_of_screens, server_grabs, colors_per_channel;


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


public:
  BaseDisplay(char * = 0);
  virtual ~BaseDisplay(void);

  Atom getWMChangeStateAtom(void) { return xa_wm_change_state; }
  Atom getWMStateAtom(void) { return xa_wm_state; }
  Atom getWMDeleteAtom(void) { return xa_wm_delete_window; }
  Atom getWMProtocolsAtom(void) { return xa_wm_protocols; }
  Atom getWMFocusAtom(void) { return xa_wm_take_focus; }
  Atom getWMColormapAtom(void) { return xa_wm_colormap_windows; }
  Atom getMotifWMHintsAtom(void) { return motif_wm_hints; }

  ScreenInfo *getScreenInfo(int s)
    { return (ScreenInfo *) screenInfoList->find(s); }

  Bool hasShapeExtensions(void) { return shape.extensions; }
  Bool doShutdown(void) { return _shutdown; }
  Bool isStartup(void) { return _startup; }
  Bool validateWindow(Window);

  Cursor getSessionCursor(void) { return cursor.session; }
  Cursor getMoveCursor(void) { return cursor.move; }

  Display *getDisplay(void) { return display; }

  const char *getDisplayName(void) const { return (const char *) display_name; }

  int getNumberOfScreens(void) { return number_of_screens; }
  int getShapeEventBase(void) { return shape.event_basep; }

  void shutdown(void) { _shutdown = True; }
  void grab(void);
  void ungrab(void);
  void eventLoop(void);
  void run(void) { _startup = _shutdown = False; }
};


class ScreenInfo {
private:
  BaseDisplay *display;
  Visual *visual;
  Window root_window;

  int depth, screen_number;
  unsigned int width, height;


protected:


public:
  ScreenInfo(BaseDisplay *, int);

  BaseDisplay *getDisplay(void) { return display; }
  Visual *getVisual(void) { return visual; }
  Window getRootWindow(void) { return root_window; }

  int getDepth(void) { return depth; }
  int getScreenNumber(void) { return screen_number; }

  unsigned int getWidth(void) { return width; }
  unsigned int getHeight(void) { return height; }
};


#endif // __BaseDisplay_hh