diff options
author | Mathias Gumz <akira@fluxbox.org> | 2015-01-15 17:49:35 (GMT) |
---|---|---|
committer | Mathias Gumz <akira@fluxbox.org> | 2015-01-15 17:49:45 (GMT) |
commit | bd9afcafb93382b5b7f32c222594699214581596 (patch) | |
tree | 418583c08c6e5ebdfcd172f5aba96d465c27d47b /src/ScreenResource.cc | |
parent | 8387742c8860694777f7c2c62da0a90c9e836988 (diff) | |
download | fluxbox-bd9afcafb93382b5b7f32c222594699214581596.zip fluxbox-bd9afcafb93382b5b7f32c222594699214581596.tar.bz2 |
Refactor: split out menu generation from BScreen
Again, it's easier to read the code when the whole menu-generation is out of
the way.
Diffstat (limited to 'src/ScreenResource.cc')
-rw-r--r-- | src/ScreenResource.cc | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/src/ScreenResource.cc b/src/ScreenResource.cc new file mode 100644 index 0000000..ade8416 --- /dev/null +++ b/src/ScreenResource.cc | |||
@@ -0,0 +1,112 @@ | |||
1 | // ScreenResource.cc for Fluxbox Window Manager | ||
2 | // Copyright (c) 2015 - Mathias Gumz <akira@fluxbox.org> | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | #include "ScreenResource.hh" | ||
23 | #include "fluxbox.hh" | ||
24 | #include "FbTk/Util.hh" | ||
25 | #include <cstring> | ||
26 | |||
27 | namespace { | ||
28 | |||
29 | struct TabPlacementString { | ||
30 | FbWinFrame::TabPlacement placement; | ||
31 | const char* str; | ||
32 | }; | ||
33 | |||
34 | const TabPlacementString _PLACEMENT_STRINGS[] = { | ||
35 | { FbWinFrame::TOPLEFT, "TopLeft" }, | ||
36 | { FbWinFrame::TOP, "Top" }, | ||
37 | { FbWinFrame::TOPRIGHT, "TopRight" }, | ||
38 | { FbWinFrame::BOTTOMLEFT, "BottomLeft" }, | ||
39 | { FbWinFrame::BOTTOM, "Bottom" }, | ||
40 | { FbWinFrame::BOTTOMRIGHT, "BottomRight" }, | ||
41 | { FbWinFrame::LEFTBOTTOM, "LeftBottom" }, | ||
42 | { FbWinFrame::LEFT, "Left" }, | ||
43 | { FbWinFrame::LEFTTOP, "LeftTop" }, | ||
44 | { FbWinFrame::RIGHTBOTTOM, "RightBottom" }, | ||
45 | { FbWinFrame::RIGHT, "Right" }, | ||
46 | { FbWinFrame::RIGHTTOP, "RightTop" } | ||
47 | }; | ||
48 | |||
49 | } | ||
50 | |||
51 | namespace FbTk { | ||
52 | |||
53 | template<> | ||
54 | std::string FbTk::Resource<FbWinFrame::TabPlacement>:: | ||
55 | getString() const { | ||
56 | |||
57 | size_t i = (m_value == FbTk::Util::clamp(m_value, FbWinFrame::TOPLEFT, FbWinFrame::RIGHTTOP) | ||
58 | ? m_value | ||
59 | : FbWinFrame::DEFAULT) - 1; | ||
60 | return _PLACEMENT_STRINGS[i].str; | ||
61 | } | ||
62 | |||
63 | template<> | ||
64 | void FbTk::Resource<FbWinFrame::TabPlacement>:: | ||
65 | setFromString(const char *strval) { | ||
66 | |||
67 | size_t i; | ||
68 | for (i = 0; i < sizeof(_PLACEMENT_STRINGS)/sizeof(_PLACEMENT_STRINGS[0]); ++i) { | ||
69 | if (strcasecmp(strval, _PLACEMENT_STRINGS[i].str) == 0) { | ||
70 | m_value = _PLACEMENT_STRINGS[i].placement; | ||
71 | return; | ||
72 | } | ||
73 | } | ||
74 | setDefaultValue(); | ||
75 | } | ||
76 | |||
77 | } // end namespace FbTk | ||
78 | |||
79 | |||
80 | |||
81 | |||
82 | ScreenResource::ScreenResource(FbTk::ResourceManager &rm, | ||
83 | const std::string &scrname, | ||
84 | const std::string &altscrname): | ||
85 | opaque_move(rm, true, scrname + ".opaqueMove", altscrname+".OpaqueMove"), | ||
86 | full_max(rm, false, scrname+".fullMaximization", altscrname+".FullMaximization"), | ||
87 | max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement", altscrname+".MaxIgnoreIncrement"), | ||
88 | max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"), | ||
89 | max_disable_resize(rm, false, scrname+".maxDisableResize", altscrname+".MaxDisableResize"), | ||
90 | workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"), | ||
91 | show_window_pos(rm, false, scrname+".showwindowposition", altscrname+".ShowWindowPosition"), | ||
92 | auto_raise(rm, true, scrname+".autoRaise", altscrname+".AutoRaise"), | ||
93 | click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), | ||
94 | default_deco(rm, "NORMAL", scrname+".defaultDeco", altscrname+".DefaultDeco"), | ||
95 | tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"), | ||
96 | windowmenufile(rm, Fluxbox::instance()->getDefaultDataFilename("windowmenu"), scrname+".windowMenu", altscrname+".WindowMenu"), | ||
97 | typing_delay(rm, 0, scrname+".noFocusWhileTypingDelay", altscrname+".NoFocusWhileTypingDelay"), | ||
98 | workspaces(rm, 4, scrname+".workspaces", altscrname+".Workspaces"), | ||
99 | edge_snap_threshold(rm, 10, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), | ||
100 | focused_alpha(rm, 255, scrname+".window.focus.alpha", altscrname+".Window.Focus.Alpha"), | ||
101 | unfocused_alpha(rm, 255, scrname+".window.unfocus.alpha", altscrname+".Window.Unfocus.Alpha"), | ||
102 | menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"), | ||
103 | menu_delay(rm, 200, scrname + ".menuDelay", altscrname+".MenuDelay"), | ||
104 | tab_width(rm, 64, scrname + ".tab.width", altscrname+".Tab.Width"), | ||
105 | tooltip_delay(rm, 500, scrname + ".tooltipDelay", altscrname+".TooltipDelay"), | ||
106 | allow_remote_actions(rm, false, scrname+".allowRemoteActions", altscrname+".AllowRemoteActions"), | ||
107 | clientmenu_use_pixmap(rm, true, scrname+".clientMenu.usePixmap", altscrname+".ClientMenu.UsePixmap"), | ||
108 | tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"), | ||
109 | max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"), | ||
110 | default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { | ||
111 | |||
112 | } | ||