| 1 |
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- |
| 2 |
// Screen.hh for Blackbox - an X11 Window manager |
| 3 |
// Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <[email protected]> |
| 4 |
// Copyright (c) 1997 - 2000, 2002 - 2005 |
| 5 |
// Bradley T Hughes <bhughes at trolltech.com> |
| 6 |
// |
| 7 |
// Permission is hereby granted, free of charge, to any person obtaining a |
| 8 |
// copy of this software and associated documentation files (the "Software"), |
| 9 |
// to deal in the Software without restriction, including without limitation |
| 10 |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 |
// and/or sell copies of the Software, and to permit persons to whom the |
| 12 |
// Software is furnished to do so, subject to the following conditions: |
| 13 |
// |
| 14 |
// The above copyright notice and this permission notice shall be included in |
| 15 |
// all copies or substantial portions of the Software. |
| 16 |
// |
| 17 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 |
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 |
// DEALINGS IN THE SOFTWARE. |
| 24 |
|
| 25 |
#ifndef __Screen_hh |
| 26 |
#define __Screen_hh |
| 27 |
|
| 28 |
#include "StackingList.hh" |
| 29 |
#include "blackbox.hh" |
| 30 |
|
| 31 |
#include <Display.hh> |
| 32 |
#include <EWMH.hh> |
| 33 |
#include <EventHandler.hh> |
| 34 |
|
| 35 |
#include <stdio.h> |
| 36 |
|
| 37 |
#include <list> |
| 38 |
#include <vector> |
| 39 |
|
| 40 |
// forward declarations |
| 41 |
class BlackboxWindow; |
| 42 |
class Configmenu; |
| 43 |
class Iconmenu; |
| 44 |
class Rootmenu; |
| 45 |
class Slit; |
| 46 |
class Slitmenu; |
| 47 |
class Toolbar; |
| 48 |
class Toolbarmenu; |
| 49 |
class Windowmenu; |
| 50 |
class Workspace; |
| 51 |
class Workspacemenu; |
| 52 |
|
| 53 |
namespace bt { |
| 54 |
class ScreenInfo; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
class BScreen : public bt::NoCopy, public bt::EventHandler { |
| 59 |
private: |
| 60 |
bool managed, geom_visible; |
| 61 |
Pixmap geom_pixmap; |
| 62 |
Window geom_window; |
| 63 |
Window empty_window; |
| 64 |
Window no_focus_window; |
| 65 |
|
| 66 |
const bt::ScreenInfo& screen_info; |
| 67 |
Blackbox *_blackbox; |
| 68 |
Configmenu *configmenu; |
| 69 |
Iconmenu *_iconmenu; |
| 70 |
Rootmenu *_rootmenu; |
| 71 |
Slitmenu *_slitmenu; |
| 72 |
Toolbarmenu *_toolbarmenu; |
| 73 |
Windowmenu *_windowmenu; |
| 74 |
Workspacemenu *_workspacemenu; |
| 75 |
|
| 76 |
BlackboxWindowList windowList; |
| 77 |
StackingList _stackingList; |
| 78 |
unsigned int current_workspace; |
| 79 |
|
| 80 |
Slit *_slit; |
| 81 |
Toolbar *_toolbar; |
| 82 |
|
| 83 |
unsigned int geom_w, geom_h; |
| 84 |
|
| 85 |
bt::Rect usableArea; |
| 86 |
|
| 87 |
typedef std::list<bt::EWMH::Strut*> StrutList; |
| 88 |
StrutList strutList; |
| 89 |
typedef std::vector<Workspace*> WorkspaceList; |
| 90 |
WorkspaceList workspacesList; |
| 91 |
|
| 92 |
ScreenResource& _resource; |
| 93 |
|
| 94 |
void updateGeomWindow(void); |
| 95 |
|
| 96 |
bool parseMenuFile(FILE *file, Rootmenu *menu); |
| 97 |
|
| 98 |
void InitMenu(void); |
| 99 |
void LoadStyle(void); |
| 100 |
|
| 101 |
void manageWindow(Window w); |
| 102 |
void unmanageWindow(BlackboxWindow *win); |
| 103 |
bool focusFallback(const BlackboxWindow *win); |
| 104 |
|
| 105 |
void placeWindow(BlackboxWindow *win); |
| 106 |
bool cascadePlacement(bt::Rect& win, const bt::Rect& avail); |
| 107 |
bool centerPlacement(bt::Rect &win, const bt::Rect &avail); |
| 108 |
bool smartPlacement(unsigned int workspace, bt::Rect& win, |
| 109 |
const bt::Rect& avail); |
| 110 |
unsigned int cascade_x, cascade_y; |
| 111 |
|
| 112 |
void updateAvailableArea(void); |
| 113 |
void updateWorkareaHint(void) const; |
| 114 |
|
| 115 |
public: |
| 116 |
enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure, |
| 117 |
SetStyle }; |
| 118 |
|
| 119 |
BScreen(Blackbox *bb, unsigned int scrn); |
| 120 |
~BScreen(void); |
| 121 |
|
| 122 |
inline bool isScreenManaged(void) const |
| 123 |
{ return managed; } |
| 124 |
|
| 125 |
inline Window noFocusWindow() const |
| 126 |
{ return no_focus_window; } |
| 127 |
|
| 128 |
// information about the screen |
| 129 |
inline const bt::ScreenInfo &screenInfo(void) const |
| 130 |
{ return screen_info; } |
| 131 |
inline unsigned int screenNumber(void) const |
| 132 |
{ return screen_info.screenNumber(); } |
| 133 |
|
| 134 |
inline ScreenResource& resource(void) |
| 135 |
{ return _resource; } |
| 136 |
inline void saveResource(void) |
| 137 |
{ _blackbox->resource().save(*_blackbox); } |
| 138 |
|
| 139 |
inline Blackbox *blackbox(void) const |
| 140 |
{ return _blackbox; } |
| 141 |
|
| 142 |
inline Rootmenu *rootmenu(void) const |
| 143 |
{ return _rootmenu; } |
| 144 |
inline Workspacemenu *workspacemenu(void) const |
| 145 |
{ return _workspacemenu; } |
| 146 |
inline Iconmenu *iconmenu(void) const |
| 147 |
{ return _iconmenu; } |
| 148 |
inline Slitmenu *slitmenu(void) const |
| 149 |
{ return _slitmenu; } |
| 150 |
inline Toolbarmenu *toolbarmenu(void) const |
| 151 |
{ return _toolbarmenu; } |
| 152 |
|
| 153 |
Windowmenu *windowmenu(BlackboxWindow *win); |
| 154 |
|
| 155 |
inline Slit *slit(void) const |
| 156 |
{ return _slit; } |
| 157 |
void createSlit(void); |
| 158 |
void destroySlit(void); |
| 159 |
|
| 160 |
inline Toolbar *toolbar(void) const |
| 161 |
{ return _toolbar; } |
| 162 |
void createToolbar(void); |
| 163 |
void destroyToolbar(void); |
| 164 |
|
| 165 |
Workspace *findWorkspace(unsigned int index) const; |
| 166 |
|
| 167 |
inline unsigned int workspaceCount(void) const |
| 168 |
{ return workspacesList.size(); } |
| 169 |
inline unsigned int currentWorkspace(void) const |
| 170 |
{ return current_workspace; } |
| 171 |
void setCurrentWorkspace(unsigned int id); |
| 172 |
void nextWorkspace(void); |
| 173 |
void prevWorkspace(void); |
| 174 |
|
| 175 |
const bt::Rect& availableArea(void); |
| 176 |
void addStrut(bt::EWMH::Strut *strut); |
| 177 |
void removeStrut(bt::EWMH::Strut *strut); |
| 178 |
void updateStrut(void); |
| 179 |
|
| 180 |
void updateClientListHint(void) const; |
| 181 |
void updateClientListStackingHint(void) const; |
| 182 |
void updateDesktopNamesHint(void) const; |
| 183 |
void readDesktopNames(void); |
| 184 |
|
| 185 |
void addWorkspace(void); |
| 186 |
void removeLastWorkspace(void); |
| 187 |
|
| 188 |
void addWindow(Window w); |
| 189 |
void releaseWindow(BlackboxWindow *win); |
| 190 |
BlackboxWindow* window(unsigned int workspace, unsigned int id); |
| 191 |
|
| 192 |
void raiseWindow(StackEntity *entity); |
| 193 |
void lowerWindow(StackEntity *entity); |
| 194 |
|
| 195 |
inline StackingList &stackingList() |
| 196 |
{ return _stackingList; } |
| 197 |
void restackWindows(void); |
| 198 |
|
| 199 |
void addIcon(BlackboxWindow *win); |
| 200 |
void removeIcon(BlackboxWindow *win); |
| 201 |
BlackboxWindow *icon(unsigned int id); |
| 202 |
|
| 203 |
void nextFocus(void); |
| 204 |
void prevFocus(void); |
| 205 |
void raiseFocus(void); |
| 206 |
|
| 207 |
void propagateWindowName(const BlackboxWindow * const win); |
| 208 |
|
| 209 |
void reconfigure(void); |
| 210 |
void toggleFocusModel(FocusModel model); |
| 211 |
void rereadMenu(void); |
| 212 |
void shutdown(void); |
| 213 |
|
| 214 |
enum GeometryType { Position, Size }; |
| 215 |
void showGeometry(GeometryType type, const bt::Rect &rect); |
| 216 |
void hideGeometry(void); |
| 217 |
|
| 218 |
void clientMessageEvent(const XClientMessageEvent * const event); |
| 219 |
void buttonPressEvent(const XButtonEvent * const event); |
| 220 |
void propertyNotifyEvent(const XPropertyEvent * const event); |
| 221 |
void unmapNotifyEvent(const XUnmapEvent * const event); |
| 222 |
}; |
| 223 |
|
| 224 |
#endif // __Screen_hh |