diff options
author | fluxgen <fluxgen> | 2003-12-19 00:34:23 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-12-19 00:34:23 (GMT) |
commit | 448d9fa7220291df30366b7e1f10e65cbc8a273e (patch) | |
tree | ffc08428bbd65d34bc5df8094d285941202df59e /src/Screen.cc | |
parent | 32edca09d7f9a5d94b433749560959cc9fea3e4c (diff) | |
download | fluxbox_pavel-448d9fa7220291df30366b7e1f10e65cbc8a273e.zip fluxbox_pavel-448d9fa7220291df30366b7e1f10e65cbc8a273e.tar.bz2 |
moved focus enum to BScreen, change window placement resource to FbTk Resource
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 181 |
1 files changed, 150 insertions, 31 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index ec4a395..634e16a 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -22,20 +22,16 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Screen.cc,v 1.252 2003/12/18 21:13:52 fluxgen Exp $ | 25 | // $Id: Screen.cc,v 1.253 2003/12/19 00:34:22 fluxgen Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
29 | 29 | ||
30 | #include "I18n.hh" | 30 | #include "I18n.hh" |
31 | #include "fluxbox.hh" | 31 | #include "fluxbox.hh" |
32 | #include "ImageControl.hh" | ||
33 | #include "Window.hh" | 32 | #include "Window.hh" |
34 | #include "Workspace.hh" | 33 | #include "Workspace.hh" |
35 | #include "StringUtil.hh" | ||
36 | #include "Netizen.hh" | 34 | #include "Netizen.hh" |
37 | #include "Directory.hh" | ||
38 | #include "SimpleCommand.hh" | ||
39 | #include "FbWinFrameTheme.hh" | 35 | #include "FbWinFrameTheme.hh" |
40 | #include "MenuTheme.hh" | 36 | #include "MenuTheme.hh" |
41 | #include "RootTheme.hh" | 37 | #include "RootTheme.hh" |
@@ -43,21 +39,25 @@ | |||
43 | #include "FbCommands.hh" | 39 | #include "FbCommands.hh" |
44 | #include "BoolMenuItem.hh" | 40 | #include "BoolMenuItem.hh" |
45 | #include "IntResMenuItem.hh" | 41 | #include "IntResMenuItem.hh" |
46 | #include "MacroCommand.hh" | ||
47 | #include "XLayerItem.hh" | ||
48 | #include "MultLayers.hh" | ||
49 | #include "FbMenu.hh" | 42 | #include "FbMenu.hh" |
50 | #include "LayerMenu.hh" | 43 | #include "LayerMenu.hh" |
51 | #include "WinClient.hh" | 44 | #include "WinClient.hh" |
52 | #include "Subject.hh" | ||
53 | #include "FbWinFrame.hh" | 45 | #include "FbWinFrame.hh" |
54 | #include "FbWindow.hh" | 46 | #include "FbWindow.hh" |
55 | #include "Strut.hh" | 47 | #include "Strut.hh" |
56 | #include "SlitTheme.hh" | 48 | #include "SlitTheme.hh" |
57 | #include "CommandParser.hh" | 49 | #include "CommandParser.hh" |
58 | #include "MenuTheme.hh" | ||
59 | #include "IconMenuItem.hh" | 50 | #include "IconMenuItem.hh" |
60 | 51 | ||
52 | #include "FbTk/Subject.hh" | ||
53 | #include "FbTk/Directory.hh" | ||
54 | #include "FbTk/SimpleCommand.hh" | ||
55 | #include "FbTk/MultLayers.hh" | ||
56 | #include "FbTk/XLayerItem.hh" | ||
57 | #include "FbTk/MacroCommand.hh" | ||
58 | #include "FbTk/StringUtil.hh" | ||
59 | #include "FbTk/ImageControl.hh" | ||
60 | |||
61 | //use GNU extensions | 61 | //use GNU extensions |
62 | #ifndef _GNU_SOURCE | 62 | #ifndef _GNU_SOURCE |
63 | #define _GNU_SOURCE | 63 | #define _GNU_SOURCE |
@@ -136,7 +136,7 @@ int anotherWMRunning(Display *display, XErrorEvent *) { | |||
136 | class FocusModelMenuItem : public FbTk::MenuItem { | 136 | class FocusModelMenuItem : public FbTk::MenuItem { |
137 | public: | 137 | public: |
138 | FocusModelMenuItem(const char *label, BScreen &screen, | 138 | FocusModelMenuItem(const char *label, BScreen &screen, |
139 | Fluxbox::FocusModel model, | 139 | BScreen::FocusModel model, |
140 | FbTk::RefCount<FbTk::Command> &cmd): | 140 | FbTk::RefCount<FbTk::Command> &cmd): |
141 | FbTk::MenuItem(label, cmd), m_screen(screen), m_focusmodel(model) { | 141 | FbTk::MenuItem(label, cmd), m_screen(screen), m_focusmodel(model) { |
142 | } | 142 | } |
@@ -148,11 +148,101 @@ public: | |||
148 | 148 | ||
149 | private: | 149 | private: |
150 | BScreen &m_screen; | 150 | BScreen &m_screen; |
151 | Fluxbox::FocusModel m_focusmodel; | 151 | BScreen::FocusModel m_focusmodel; |
152 | }; | 152 | }; |
153 | 153 | ||
154 | 154 | ||
155 | }; // End anonymous namespace | 155 | } // End anonymous namespace |
156 | |||
157 | template <> | ||
158 | void FbTk::Resource<BScreen::PlacementPolicy>::setDefaultValue() { | ||
159 | *(*this) = BScreen::ROWSMARTPLACEMENT; | ||
160 | } | ||
161 | |||
162 | template <> | ||
163 | void FbTk::Resource<BScreen::PlacementPolicy>::setFromString(const char *str) { | ||
164 | if (strcasecmp("RowSmartPlacement", str) == 0) | ||
165 | *(*this) = BScreen::ROWSMARTPLACEMENT; | ||
166 | else if (strcasecmp("", str) == 0) | ||
167 | *(*this) = BScreen::COLSMARTPLACEMENT; | ||
168 | else if (strcasecmp("UnderMousePlacement", str) == 0) | ||
169 | *(*this) = BScreen::UNDERMOUSEPLACEMENT; | ||
170 | else if (strcasecmp("CascadePlacement", str) == 0) | ||
171 | *(*this) = BScreen::CASCADEPLACEMENT; | ||
172 | else | ||
173 | setDefaultValue(); | ||
174 | |||
175 | } | ||
176 | |||
177 | string FbTk::Resource<BScreen::PlacementPolicy>::getString() { | ||
178 | switch (*(*this)) { | ||
179 | case BScreen::ROWSMARTPLACEMENT: | ||
180 | return "RowSmartPlacement"; | ||
181 | case BScreen::COLSMARTPLACEMENT: | ||
182 | return "ColSmartPlacement"; | ||
183 | case BScreen::UNDERMOUSEPLACEMENT: | ||
184 | return "UnderMousePlacement"; | ||
185 | case BScreen::CASCADEPLACEMENT: | ||
186 | return "CascadePlacement"; | ||
187 | } | ||
188 | |||
189 | return "RowSmartPlacement"; | ||
190 | } | ||
191 | |||
192 | template <> | ||
193 | void FbTk::Resource<BScreen::RowDirection>::setDefaultValue() { | ||
194 | *(*this) = BScreen::LEFTRIGHT; | ||
195 | } | ||
196 | |||
197 | template <> | ||
198 | void FbTk::Resource<BScreen::RowDirection>::setFromString(const char *str) { | ||
199 | if (strcasecmp("LeftToRight", str) == 0) | ||
200 | *(*this) = BScreen::LEFTRIGHT; | ||
201 | else if (strcasecmp("RightToLeft", str) == 0) | ||
202 | *(*this) = BScreen::RIGHTLEFT; | ||
203 | else | ||
204 | setDefaultValue(); | ||
205 | |||
206 | } | ||
207 | |||
208 | string FbTk::Resource<BScreen::RowDirection>::getString() { | ||
209 | switch (*(*this)) { | ||
210 | case BScreen::LEFTRIGHT: | ||
211 | return "LeftToRight"; | ||
212 | case BScreen::RIGHTLEFT: | ||
213 | return "RightToLeft"; | ||
214 | } | ||
215 | |||
216 | return "LeftToRight"; | ||
217 | } | ||
218 | |||
219 | |||
220 | template <> | ||
221 | void FbTk::Resource<BScreen::ColumnDirection>::setDefaultValue() { | ||
222 | *(*this) = BScreen::TOPBOTTOM; | ||
223 | } | ||
224 | |||
225 | template <> | ||
226 | void FbTk::Resource<BScreen::ColumnDirection>::setFromString(const char *str) { | ||
227 | if (strcasecmp("TopToBottom", str) == 0) | ||
228 | *(*this) = BScreen::TOPBOTTOM; | ||
229 | else if (strcasecmp("BottomToTop", str) == 0) | ||
230 | *(*this) = BScreen::BOTTOMTOP; | ||
231 | else | ||
232 | setDefaultValue(); | ||
233 | |||
234 | } | ||
235 | |||
236 | string FbTk::Resource<BScreen::ColumnDirection>::getString() { | ||
237 | switch (*(*this)) { | ||
238 | case BScreen::TOPBOTTOM: | ||
239 | return "TopToBottom"; | ||
240 | case BScreen::BOTTOMTOP: | ||
241 | return "BottomToTop"; | ||
242 | } | ||
243 | |||
244 | return "TopToBottom"; | ||
245 | } | ||
156 | 246 | ||
157 | template <> | 247 | template <> |
158 | void FbTk::Resource<FbTk::MenuTheme::MenuMode>::setDefaultValue() { | 248 | void FbTk::Resource<FbTk::MenuTheme::MenuMode>::setDefaultValue() { |
@@ -180,13 +270,47 @@ void FbTk::Resource<FbTk::MenuTheme::MenuMode>::setFromString(const char *str) { | |||
180 | setDefaultValue(); | 270 | setDefaultValue(); |
181 | } | 271 | } |
182 | 272 | ||
273 | template<> | ||
274 | std::string FbTk::Resource<BScreen::FocusModel>:: | ||
275 | getString() { | ||
276 | switch (m_value) { | ||
277 | case BScreen::SLOPPYFOCUS: | ||
278 | return string("SloppyFocus"); | ||
279 | case BScreen::SEMISLOPPYFOCUS: | ||
280 | return string("SemiSloppyFocus"); | ||
281 | case BScreen::CLICKTOFOCUS: | ||
282 | return string("ClickToFocus"); | ||
283 | } | ||
284 | // default string | ||
285 | return string("ClickToFocus"); | ||
286 | } | ||
287 | |||
288 | template<> | ||
289 | void FbTk::Resource<BScreen::FocusModel>:: | ||
290 | setFromString(char const *strval) { | ||
291 | // auto raise options here for backwards read compatibility | ||
292 | // they are not supported for saving purposes. Nor does the "AutoRaise" | ||
293 | // part actually do anything | ||
294 | if (strcasecmp(strval, "SloppyFocus") == 0 | ||
295 | || strcasecmp(strval, "AutoRaiseSloppyFocus") == 0) | ||
296 | m_value = BScreen::SLOPPYFOCUS; | ||
297 | else if (strcasecmp(strval, "SemiSloppyFocus") == 0 | ||
298 | || strcasecmp(strval, "AutoRaiseSemiSloppyFocus") == 0) | ||
299 | m_value = BScreen::SEMISLOPPYFOCUS; | ||
300 | else if (strcasecmp(strval, "ClickToFocus") == 0) | ||
301 | m_value = BScreen::CLICKTOFOCUS; | ||
302 | else | ||
303 | setDefaultValue(); | ||
304 | } | ||
305 | |||
183 | namespace { | 306 | namespace { |
184 | 307 | ||
185 | class StyleMenuItem: public FbTk::MenuItem { | 308 | class StyleMenuItem: public FbTk::MenuItem { |
186 | public: | 309 | public: |
187 | StyleMenuItem(const std::string &label, const std::string &filename):FbTk::MenuItem(label.c_str()), | 310 | StyleMenuItem(const std::string &label, const std::string &filename): |
188 | m_filename(FbTk::StringUtil:: | 311 | FbTk::MenuItem(label.c_str()), |
189 | expandFilename(filename)) { | 312 | m_filename(FbTk::StringUtil:: |
313 | expandFilename(filename)) { | ||
190 | // perform shell style ~ home directory expansion | 314 | // perform shell style ~ home directory expansion |
191 | // and insert style | 315 | // and insert style |
192 | FbTk::RefCount<FbTk::Command> | 316 | FbTk::RefCount<FbTk::Command> |
@@ -227,9 +351,8 @@ void setupWorkspacemenu(BScreen &scr, FbTk::Menu &menu) { | |||
227 | BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, | 351 | BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, |
228 | const std::string &scrname, | 352 | const std::string &scrname, |
229 | const std::string &altscrname): | 353 | const std::string &altscrname): |
230 | |||
231 | image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"), | 354 | image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"), |
232 | opaque_move(rm, false, "session.opaqueMove", "Session.OpaqueMove"), | 355 | opaque_move(rm, false, scrname + ".opaqueMove", altscrname+".OpaqueMove"), |
233 | full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"), | 356 | full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"), |
234 | sloppy_window_grouping(rm, true, | 357 | sloppy_window_grouping(rm, true, |
235 | scrname+".sloppywindowgrouping", altscrname+".SloppyWindowGrouping"), | 358 | scrname+".sloppywindowgrouping", altscrname+".SloppyWindowGrouping"), |
@@ -243,15 +366,18 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, | |||
243 | click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), | 366 | click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), |
244 | rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), | 367 | rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), |
245 | resizemode(rm, "", scrname+".resizeMode", altscrname+".ResizeMode"), | 368 | resizemode(rm, "", scrname+".resizeMode", altscrname+".ResizeMode"), |
246 | focus_model(rm, Fluxbox::CLICKTOFOCUS, scrname+".focusModel", altscrname+".FocusModel"), | 369 | focus_model(rm, CLICKTOFOCUS, scrname+".focusModel", altscrname+".FocusModel"), |
247 | workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), | 370 | workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), |
248 | edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), | 371 | edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), |
249 | menu_alpha(rm, 255, scrname+".menuAlpha", altscrname+".MenuAlpha"), | 372 | menu_alpha(rm, 255, scrname+".menuAlpha", altscrname+".MenuAlpha"), |
250 | menu_delay(rm, 0, scrname + ".menuDelay", altscrname+".MenuDelay"), | 373 | menu_delay(rm, 0, scrname + ".menuDelay", altscrname+".MenuDelay"), |
251 | menu_delay_close(rm, 0, scrname + ".menuDelayClose", altscrname+".MenuDelayClose"), | 374 | menu_delay_close(rm, 0, scrname + ".menuDelayClose", altscrname+".MenuDelayClose"), |
252 | menu_mode(rm, FbTk::MenuTheme::DELAY_OPEN, scrname+".menuMode", altscrname+".MenuMode") { | 375 | menu_mode(rm, FbTk::MenuTheme::DELAY_OPEN, scrname+".menuMode", altscrname+".MenuMode"), |
376 | placement_policy(rm, ROWSMARTPLACEMENT, scrname+".windowPlacement", altscrname+".WindowPlacement"), | ||
377 | row_direction(rm, LEFTRIGHT, scrname+".rowPlacementDirection", altscrname+".RowPlacementDirection"), | ||
378 | col_direction(rm, TOPBOTTOM, scrname+".colPlacementDirection", altscrname+".ColPlacementDirection") { | ||
253 | 379 | ||
254 | }; | 380 | } |
255 | 381 | ||
256 | BScreen::BScreen(FbTk::ResourceManager &rm, | 382 | BScreen::BScreen(FbTk::ResourceManager &rm, |
257 | const string &screenname, const string &altscreenname, | 383 | const string &screenname, const string &altscreenname, |
@@ -800,13 +926,6 @@ void BScreen::removeClient(WinClient &client) { | |||
800 | 926 | ||
801 | } | 927 | } |
802 | 928 | ||
803 | FluxboxWindow *BScreen::getIcon(unsigned int index) { | ||
804 | if (index < m_icon_list.size()) | ||
805 | return m_icon_list[index]; | ||
806 | |||
807 | return 0; | ||
808 | } | ||
809 | |||
810 | void BScreen::setAntialias(bool value) { | 929 | void BScreen::setAntialias(bool value) { |
811 | if (*resource.antialias == value) | 930 | if (*resource.antialias == value) |
812 | return; | 931 | return; |
@@ -1935,21 +2054,21 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { | |||
1935 | ConfigmenuClickToFocus, | 2054 | ConfigmenuClickToFocus, |
1936 | "Click To Focus"), | 2055 | "Click To Focus"), |
1937 | *this, | 2056 | *this, |
1938 | Fluxbox::CLICKTOFOCUS, | 2057 | CLICKTOFOCUS, |
1939 | save_and_reconfigure)); | 2058 | save_and_reconfigure)); |
1940 | 2059 | ||
1941 | focus_menu->insert(new FocusModelMenuItem(i18n->getMessage(ConfigmenuSet, | 2060 | focus_menu->insert(new FocusModelMenuItem(i18n->getMessage(ConfigmenuSet, |
1942 | ConfigmenuSloppyFocus, | 2061 | ConfigmenuSloppyFocus, |
1943 | "Sloppy Focus"), | 2062 | "Sloppy Focus"), |
1944 | *this, | 2063 | *this, |
1945 | Fluxbox::SLOPPYFOCUS, | 2064 | SLOPPYFOCUS, |
1946 | save_and_reconfigure)); | 2065 | save_and_reconfigure)); |
1947 | 2066 | ||
1948 | focus_menu->insert(new FocusModelMenuItem(i18n->getMessage(ConfigmenuSet, | 2067 | focus_menu->insert(new FocusModelMenuItem(i18n->getMessage(ConfigmenuSet, |
1949 | ConfigmenuSemiSloppyFocus, | 2068 | ConfigmenuSemiSloppyFocus, |
1950 | "Semi Sloppy Focus"), | 2069 | "Semi Sloppy Focus"), |
1951 | *this, | 2070 | *this, |
1952 | Fluxbox::SEMISLOPPYFOCUS, | 2071 | SEMISLOPPYFOCUS, |
1953 | save_and_reconfigure)); | 2072 | save_and_reconfigure)); |
1954 | 2073 | ||
1955 | focus_menu->insert(new BoolMenuItem(i18n->getMessage(ConfigmenuSet, | 2074 | focus_menu->insert(new BoolMenuItem(i18n->getMessage(ConfigmenuSet, |