diff options
author | akir <akir> | 2004-10-22 00:35:29 (GMT) |
---|---|---|
committer | akir <akir> | 2004-10-22 00:35:29 (GMT) |
commit | f5d7833b32f77e936ce9f6e930f0b930519a28a2 (patch) | |
tree | 7e989a8baff2b268f5d1fd09bcb29f7485330aa7 /src/IconButton.cc | |
parent | 33b55697ab8c615badf195d5c54b0136fbe93c54 (diff) | |
download | fluxbox_pavel-f5d7833b32f77e936ce9f6e930f0b930519a28a2.zip fluxbox_pavel-f5d7833b32f77e936ce9f6e930f0b930519a28a2.tar.bz2 |
added iconbar.wheelMode and iconbar.deiconifyMode
Diffstat (limited to 'src/IconButton.cc')
-rw-r--r-- | src/IconButton.cc | 74 |
1 files changed, 62 insertions, 12 deletions
diff --git a/src/IconButton.cc b/src/IconButton.cc index 0c383d1..a4293c6 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc | |||
@@ -20,10 +20,10 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: IconButton.cc,v 1.22 2004/07/15 14:20:19 fluxgen Exp $ | 23 | // $Id: IconButton.cc,v 1.23 2004/10/22 00:35:28 akir Exp $ |
24 | 24 | ||
25 | #include "IconButton.hh" | 25 | #include "IconButton.hh" |
26 | 26 | #include "IconbarTool.hh" | |
27 | 27 | ||
28 | #include "fluxbox.hh" | 28 | #include "fluxbox.hh" |
29 | #include "Screen.hh" | 29 | #include "Screen.hh" |
@@ -49,6 +49,8 @@ | |||
49 | #include <X11/extensions/shape.h> | 49 | #include <X11/extensions/shape.h> |
50 | #endif // SHAPE | 50 | #endif // SHAPE |
51 | 51 | ||
52 | typedef FbTk::RefCount<FbTk::Command> RefCmd; | ||
53 | |||
52 | namespace { | 54 | namespace { |
53 | 55 | ||
54 | class ShowMenu: public FbTk::Command { | 56 | class ShowMenu: public FbTk::Command { |
@@ -69,47 +71,95 @@ private: | |||
69 | 71 | ||
70 | class FocusCommand: public FbTk::Command { | 72 | class FocusCommand: public FbTk::Command { |
71 | public: | 73 | public: |
72 | explicit FocusCommand(FluxboxWindow &win):m_win(win) { } | 74 | explicit FocusCommand(const IconbarTool& tool, FluxboxWindow &win) : |
75 | m_win(win), m_tool(tool) { } | ||
73 | void execute() { | 76 | void execute() { |
74 | if(m_win.isIconic() || !m_win.isFocused()) { | 77 | if(m_win.isIconic() || !m_win.isFocused()) { |
75 | m_win.screen().changeWorkspaceID(m_win.workspaceNumber()); | 78 | switch(m_tool.deiconifyMode()) { |
79 | case IconbarTool::CURRENT: | ||
80 | m_win.screen().sendToWorkspace(m_win.screen().currentWorkspaceID(), &m_win); | ||
81 | break; | ||
82 | case IconbarTool::FOLLOW: | ||
83 | m_win.screen().changeWorkspaceID(m_win.workspaceNumber()); | ||
84 | break; | ||
85 | case IconbarTool::SEMIFOLLOW: | ||
86 | if (m_win.isIconic()) | ||
87 | m_win.screen().sendToWorkspace(m_win.screen().currentWorkspaceID(), &m_win); | ||
88 | else | ||
89 | m_win.screen().changeWorkspaceID(m_win.workspaceNumber()); | ||
90 | break; | ||
91 | }; | ||
92 | |||
76 | m_win.raiseAndFocus(); | 93 | m_win.raiseAndFocus(); |
77 | } else | 94 | } else |
78 | m_win.iconify(); | 95 | m_win.iconify(); |
79 | } | 96 | } |
97 | |||
80 | private: | 98 | private: |
81 | FluxboxWindow &m_win; | 99 | FluxboxWindow &m_win; |
100 | const IconbarTool& m_tool; | ||
82 | }; | 101 | }; |
83 | 102 | ||
103 | // simple forwarding of wheeling, but only | ||
104 | // if desktopwheeling is enabled | ||
105 | class WheelWorkspaceCmd : public FbTk::Command { | ||
106 | public: | ||
107 | explicit WheelWorkspaceCmd(const IconbarTool& tool, FluxboxWindow &win, const char* cmd) : | ||
108 | m_win(win), m_tool(tool), m_cmd(CommandParser::instance().parseLine(cmd)){ } | ||
109 | void execute() { | ||
110 | |||
111 | switch(m_tool.wheelMode()) { | ||
112 | case IconbarTool::ON: | ||
113 | m_cmd->execute(); | ||
114 | break; | ||
115 | case IconbarTool::SCREEN: | ||
116 | if(m_win.screen().isDesktopWheeling()) | ||
117 | m_cmd->execute(); | ||
118 | break; | ||
119 | case IconbarTool::OFF: | ||
120 | default: | ||
121 | break; | ||
122 | }; | ||
123 | } | ||
124 | |||
125 | private: | ||
126 | FluxboxWindow &m_win; | ||
127 | RefCmd m_cmd; | ||
128 | const IconbarTool& m_tool; | ||
129 | }; | ||
84 | 130 | ||
85 | } // end anonymous namespace | 131 | } // end anonymous namespace |
86 | 132 | ||
87 | 133 | ||
88 | 134 | ||
89 | IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, | 135 | IconButton::IconButton(const IconbarTool& tool, const FbTk::FbWindow &parent, |
90 | FluxboxWindow &win): | 136 | const FbTk::Font &font, FluxboxWindow &win): |
91 | FbTk::TextButton(parent, font, win.winClient().title()), | 137 | FbTk::TextButton(parent, font, win.winClient().title()), |
92 | m_win(win), | 138 | m_win(win), |
93 | m_icon_window(*this, 1, 1, 1, 1, | 139 | m_icon_window(*this, 1, 1, 1, 1, |
94 | ExposureMask | ButtonPressMask | ButtonReleaseMask), | 140 | ExposureMask | ButtonPressMask | ButtonReleaseMask), |
95 | m_use_pixmap(true) { | 141 | m_use_pixmap(true) { |
96 | 142 | ||
97 | typedef FbTk::RefCount<FbTk::Command> RefCmd; | 143 | |
98 | RefCmd hidemenus(new FbTk::SimpleCommand<BScreen>(win.screen(), &BScreen::hideMenus)); | 144 | RefCmd next_workspace(new ::WheelWorkspaceCmd(tool, m_win, "nextworkspace")); |
99 | RefCmd next_workspace(CommandParser::instance().parseLine("nextworkspace")); | 145 | RefCmd prev_workspace(new ::WheelWorkspaceCmd(tool, m_win, "prevworkspace")); |
100 | RefCmd prev_workspace(CommandParser::instance().parseLine("prevworkspace")); | 146 | |
101 | //!! TODO: There're some issues with MacroCommand when | 147 | //!! TODO: There're some issues with MacroCommand when |
102 | // this object dies when the last macrocommand is executed (focused cmd) | 148 | // this object dies when the last macrocommand is executed (focused cmd) |
103 | // In iconbar mode Icons | 149 | // In iconbar mode Icons |
150 | // | ||
151 | // RefCmd hidemenus(new FbTk::SimpleCommand<BScreen>(win.screen(), &BScreen::hideMenus)); | ||
104 | // FbTk::MacroCommand *focus_macro = new FbTk::MacroCommand(); | 152 | // FbTk::MacroCommand *focus_macro = new FbTk::MacroCommand(); |
105 | // focus_macro->add(hidemenus); | 153 | // focus_macro->add(hidemenus); |
106 | // focus_macro->add(focus); | 154 | // focus_macro->add(focus); |
107 | FbTk::RefCount<FbTk::Command> focus_cmd(new ::FocusCommand(m_win)); | 155 | |
108 | FbTk::RefCount<FbTk::Command> menu_cmd(new ::ShowMenu(m_win)); | 156 | RefCmd focus_cmd(new ::FocusCommand(tool, m_win)); |
157 | RefCmd menu_cmd(new ::ShowMenu(m_win)); | ||
109 | setOnClick(focus_cmd, 1); | 158 | setOnClick(focus_cmd, 1); |
110 | setOnClick(menu_cmd, 3); | 159 | setOnClick(menu_cmd, 3); |
111 | setOnClick(next_workspace, 4); | 160 | setOnClick(next_workspace, 4); |
112 | setOnClick(prev_workspace, 5); | 161 | setOnClick(prev_workspace, 5); |
162 | |||
113 | m_win.hintSig().attach(this); | 163 | m_win.hintSig().attach(this); |
114 | 164 | ||
115 | FbTk::EventManager::instance()->add(*this, m_icon_window); | 165 | FbTk::EventManager::instance()->add(*this, m_icon_window); |