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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
// -*- mode: C++; indent-tabs-mode: nil; -*- // BaseDisplay.hh for Blackbox - an X11 Window manager // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org> // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #ifndef __BaseDisplay_hh #define __BaseDisplay_hh extern "C" { #include <X11/Xlib.h> #include <X11/Xatom.h> } #include <vector> #include <string> // forward declaration class BaseDisplay; class BGCCache; #include "Timer.hh" #include "Util.hh" class ScreenInfo { private: BaseDisplay *basedisplay; Visual *visual; Window root_window; Colormap colormap; int depth; unsigned int screen_number; std::string display_string; Rect rect; public: ScreenInfo(BaseDisplay *d, unsigned int num); inline BaseDisplay *getBaseDisplay(void) const { return basedisplay; } inline Visual *getVisual(void) const { return visual; } inline Window getRootWindow(void) const { return root_window; } inline Colormap getColormap(void) const { return colormap; } inline int getDepth(void) const { return depth; } inline unsigned int getScreenNumber(void) const { return screen_number; } inline const Rect& getRect(void) const { return rect; } inline unsigned int getWidth(void) const { return rect.width(); } inline unsigned int getHeight(void) const { return rect.height(); } inline const std::string& displayString(void) const { return display_string; } }; class BaseDisplay: public TimerQueueManager { private: struct BShape { bool extensions; int event_basep, error_basep; }; BShape shape; #ifndef NOCLOBBER unsigned int MaskList[8]; size_t MaskListLength; #endif // NOCLOBBER 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; } 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; } 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) 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 |