| 1 |
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- |
| 2 |
// BlackboxResource.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 __BlackboxResource_hh |
| 26 |
#define __BlackboxResource_hh |
| 27 |
|
| 28 |
#include "ScreenResource.hh" |
| 29 |
|
| 30 |
#include <Timer.hh> |
| 31 |
#include <Util.hh> |
| 32 |
|
| 33 |
class Blackbox; |
| 34 |
|
| 35 |
enum FocusModel { |
| 36 |
SloppyFocusModel, |
| 37 |
ClickToFocusModel |
| 38 |
}; |
| 39 |
|
| 40 |
enum WindowPlacementPolicy { |
| 41 |
RowSmartPlacement = 400, |
| 42 |
ColSmartPlacement, |
| 43 |
CenterPlacement, |
| 44 |
CascadePlacement, |
| 45 |
LeftRight, |
| 46 |
RightLeft, |
| 47 |
TopBottom, |
| 48 |
BottomTop |
| 49 |
}; |
| 50 |
|
| 51 |
struct Cursors { |
| 52 |
Cursor pointer; |
| 53 |
Cursor move; |
| 54 |
Cursor resize_top_left; |
| 55 |
Cursor resize_bottom_left; |
| 56 |
Cursor resize_top_right; |
| 57 |
Cursor resize_bottom_right; |
| 58 |
}; |
| 59 |
|
| 60 |
class BlackboxResource: public bt::NoCopy { |
| 61 |
private: |
| 62 |
ScreenResource *screen_resources; |
| 63 |
|
| 64 |
Cursors _cursors; |
| 65 |
|
| 66 |
std::string menu_file, style_file, rc_file; |
| 67 |
Time double_click_interval; |
| 68 |
bt::timeval auto_raise_delay; |
| 69 |
|
| 70 |
FocusModel focus_model; |
| 71 |
int window_placement_policy; |
| 72 |
int row_direction, col_direction; |
| 73 |
bool ignore_shaded; |
| 74 |
bool auto_raise; |
| 75 |
bool click_raise; |
| 76 |
bool opaque_move; |
| 77 |
bool opaque_resize; |
| 78 |
bool full_max; |
| 79 |
bool focus_new_windows; |
| 80 |
bool focus_last_window_on_workspace; |
| 81 |
bool allow_scroll_lock; |
| 82 |
bool change_workspace_with_mouse_wheel; |
| 83 |
bool shade_window_with_mouse_wheel; |
| 84 |
bool toolbar_actions_with_mouse_wheel; |
| 85 |
unsigned int edge_snap_threshold; |
| 86 |
unsigned int window_snap_threshold; |
| 87 |
|
| 88 |
public: |
| 89 |
BlackboxResource(const std::string& rc); |
| 90 |
~BlackboxResource(void); |
| 91 |
|
| 92 |
void load(Blackbox& blackbox); |
| 93 |
void save(Blackbox& blackbox); |
| 94 |
|
| 95 |
inline ScreenResource &screenResource(unsigned int screen) |
| 96 |
{ return screen_resources[screen]; } |
| 97 |
|
| 98 |
inline const Cursors &cursors(void) const |
| 99 |
{ return _cursors; } |
| 100 |
|
| 101 |
inline const char* rcFilename(void) const |
| 102 |
{ return rc_file.c_str(); } |
| 103 |
inline const char* menuFilename(void) const |
| 104 |
{ return menu_file.c_str(); } |
| 105 |
inline const char* styleFilename(void) const |
| 106 |
{ return style_file.c_str(); } |
| 107 |
|
| 108 |
inline void saveStyleFilename(const std::string& name) |
| 109 |
{ style_file = name; } |
| 110 |
|
| 111 |
inline Time doubleClickInterval(void) const |
| 112 |
{ return double_click_interval; } |
| 113 |
inline const bt::timeval& autoRaiseDelay(void) const |
| 114 |
{ return auto_raise_delay; } |
| 115 |
|
| 116 |
// window focus model |
| 117 |
inline FocusModel focusModel(void) const |
| 118 |
{ return focus_model; } |
| 119 |
inline void setFocusModel(FocusModel fm) |
| 120 |
{ focus_model = fm; } |
| 121 |
|
| 122 |
inline bool autoRaise(void) const |
| 123 |
{ return auto_raise; } |
| 124 |
inline void setAutoRaise(bool b = true) |
| 125 |
{ auto_raise = b; } |
| 126 |
|
| 127 |
inline bool clickRaise(void) const |
| 128 |
{ return click_raise; } |
| 129 |
inline void setClickRaise(bool b = true) |
| 130 |
{ click_raise = b; } |
| 131 |
|
| 132 |
// window placement |
| 133 |
inline int windowPlacementPolicy(void) const |
| 134 |
{ return window_placement_policy; } |
| 135 |
inline void setWindowPlacementPolicy(int p) |
| 136 |
{ window_placement_policy = p; } |
| 137 |
|
| 138 |
inline int rowPlacementDirection(void) const |
| 139 |
{ return row_direction; } |
| 140 |
inline void setRowPlacementDirection(int d) |
| 141 |
{ row_direction = d; } |
| 142 |
|
| 143 |
inline int colPlacementDirection(void) const |
| 144 |
{ return col_direction; } |
| 145 |
inline void setColPlacementDirection(int d) |
| 146 |
{ col_direction = d; } |
| 147 |
|
| 148 |
inline bool placementIgnoresShaded(void) const |
| 149 |
{ return ignore_shaded; } |
| 150 |
inline void setPlacementIgnoresShaded(bool f) |
| 151 |
{ ignore_shaded = f; } |
| 152 |
|
| 153 |
// other window options |
| 154 |
inline bool opaqueMove(void) const |
| 155 |
{ return opaque_move; } |
| 156 |
inline void setOpaqueMove(bool b = true) |
| 157 |
{ opaque_move = b; } |
| 158 |
|
| 159 |
inline bool opaqueResize(void) const |
| 160 |
{ return opaque_resize; } |
| 161 |
inline void setOpaqueResize(bool b = true) |
| 162 |
{ opaque_resize = b; } |
| 163 |
|
| 164 |
inline bool fullMaximization(void) const |
| 165 |
{ return full_max; } |
| 166 |
inline void setFullMaximization(bool b = true) |
| 167 |
{ full_max = b; } |
| 168 |
|
| 169 |
inline bool focusNewWindows(void) const |
| 170 |
{ return focus_new_windows; } |
| 171 |
inline void setFocusNewWindows(bool b = true) |
| 172 |
{ focus_new_windows = b; } |
| 173 |
|
| 174 |
inline bool focusLastWindowOnWorkspace(void) const |
| 175 |
{ return focus_last_window_on_workspace; } |
| 176 |
inline void setFocusLastWindowOnWorkspace(bool b = true) |
| 177 |
{ focus_last_window_on_workspace = b; } |
| 178 |
|
| 179 |
inline bool changeWorkspaceWithMouseWheel(void) const |
| 180 |
{ return change_workspace_with_mouse_wheel; } |
| 181 |
inline void setChangeWorkspaceWithMouseWheel(bool b = true) |
| 182 |
{ change_workspace_with_mouse_wheel = b; } |
| 183 |
|
| 184 |
inline bool shadeWindowWithMouseWheel(void) const |
| 185 |
{ return shade_window_with_mouse_wheel; } |
| 186 |
inline void setShadeWindowWithMouseWheel(bool b = true) |
| 187 |
{ shade_window_with_mouse_wheel = b; } |
| 188 |
|
| 189 |
inline bool toolbarActionsWithMouseWheel(void) const |
| 190 |
{ return toolbar_actions_with_mouse_wheel; } |
| 191 |
inline void setToolbarActionsWithMouseWheel(bool b = true) |
| 192 |
{ toolbar_actions_with_mouse_wheel = b; } |
| 193 |
|
| 194 |
inline bool allowScrollLock(void) const |
| 195 |
{ return allow_scroll_lock; } |
| 196 |
inline void setAllowScrollLock(bool a) |
| 197 |
{ allow_scroll_lock = a; } |
| 198 |
|
| 199 |
inline unsigned int edgeSnapThreshold(void) const |
| 200 |
{ return edge_snap_threshold; } |
| 201 |
inline void setEdgeSnapThreshold(unsigned int t) |
| 202 |
{ edge_snap_threshold = t; } |
| 203 |
|
| 204 |
inline unsigned int windowSnapThreshold(void) const |
| 205 |
{ return window_snap_threshold; } |
| 206 |
inline void setWindowSnapThreshold(unsigned int t) |
| 207 |
{ window_snap_threshold = t; } |
| 208 |
}; |
| 209 |
|
| 210 |
#endif |