diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/IconButton.cc | 74 | ||||
-rw-r--r-- | src/IconButton.hh | 7 | ||||
-rw-r--r-- | src/IconbarTool.cc | 91 | ||||
-rw-r--r-- | src/IconbarTool.hh | 23 |
4 files changed, 177 insertions, 18 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); |
diff --git a/src/IconButton.hh b/src/IconButton.hh index 69fbf46..80310b4 100644 --- a/src/IconButton.hh +++ b/src/IconButton.hh | |||
@@ -20,7 +20,7 @@ | |||
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.hh,v 1.4 2003/11/27 14:27:48 fluxgen Exp $ | 23 | // $Id: IconButton.hh,v 1.5 2004/10/22 00:35:28 akir Exp $ |
24 | 24 | ||
25 | #ifndef ICONBUTTON_HH | 25 | #ifndef ICONBUTTON_HH |
26 | #define ICONBUTTON_HH | 26 | #define ICONBUTTON_HH |
@@ -30,11 +30,12 @@ | |||
30 | #include "FbTk/TextButton.hh" | 30 | #include "FbTk/TextButton.hh" |
31 | 31 | ||
32 | class FluxboxWindow; | 32 | class FluxboxWindow; |
33 | class IconbarTool; | ||
33 | 34 | ||
34 | class IconButton: public FbTk::TextButton, public FbTk::Observer { | 35 | class IconButton: public FbTk::TextButton, public FbTk::Observer { |
35 | public: | 36 | public: |
36 | IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, | 37 | IconButton(const IconbarTool& tool, const FbTk::FbWindow &parent, |
37 | FluxboxWindow &window); | 38 | const FbTk::Font &font, FluxboxWindow &window); |
38 | virtual ~IconButton(); | 39 | virtual ~IconButton(); |
39 | 40 | ||
40 | void exposeEvent(XExposeEvent &event); | 41 | void exposeEvent(XExposeEvent &event); |
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 066b87d..e6cc22b 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc | |||
@@ -20,7 +20,7 @@ | |||
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: IconbarTool.cc,v 1.48 2004/10/10 16:11:25 akir Exp $ | 23 | // $Id: IconbarTool.cc,v 1.49 2004/10/22 00:35:28 akir Exp $ |
24 | 24 | ||
25 | #include "IconbarTool.hh" | 25 | #include "IconbarTool.hh" |
26 | 26 | ||
@@ -66,6 +66,68 @@ void FbTk::Resource<IconbarTool::Mode>::setFromString(const char *strval) { | |||
66 | } | 66 | } |
67 | 67 | ||
68 | template<> | 68 | template<> |
69 | void FbTk::Resource<IconbarTool::DeiconifyMode>::setDefaultValue() { | ||
70 | m_value = IconbarTool::CURRENT; | ||
71 | } | ||
72 | |||
73 | template<> | ||
74 | void FbTk::Resource<IconbarTool::DeiconifyMode>::setFromString(const char* strval) { | ||
75 | if (strncasecmp(strval, "Current", strlen("Current")) == 0) | ||
76 | m_value = IconbarTool::CURRENT; | ||
77 | else if (strncasecmp(strval, "Follow", strlen("Follow")) == 0) | ||
78 | m_value = IconbarTool::FOLLOW; | ||
79 | else if (strncasecmp(strval, "SemiFollow", strlen("SemiFollow")) == 0) | ||
80 | m_value = IconbarTool::SEMIFOLLOW; | ||
81 | else | ||
82 | setDefaultValue(); | ||
83 | } | ||
84 | |||
85 | template<> | ||
86 | std::string FbTk::Resource<IconbarTool::DeiconifyMode>::getString() { | ||
87 | switch (m_value) { | ||
88 | case IconbarTool::SEMIFOLLOW: | ||
89 | return std::string("SemiFollow"); | ||
90 | break; | ||
91 | case IconbarTool::FOLLOW: | ||
92 | return std::string("Follow"); | ||
93 | break; | ||
94 | }; | ||
95 | return std::string("Current"); | ||
96 | } | ||
97 | |||
98 | template<> | ||
99 | void FbTk::Resource<IconbarTool::WheelMode>::setDefaultValue() { | ||
100 | m_value = IconbarTool::SCREEN; | ||
101 | } | ||
102 | |||
103 | |||
104 | template<> | ||
105 | void FbTk::Resource<IconbarTool::WheelMode>::setFromString(const char* strval) { | ||
106 | if (strncasecmp(strval, "off", strlen("off")) == 0) | ||
107 | m_value = IconbarTool::OFF; | ||
108 | else if (strncasecmp(strval, "on", strlen("on")) == 0) | ||
109 | m_value = IconbarTool::ON; | ||
110 | else if (strncasecmp(strval, "screen", strlen("screen")) == 0) | ||
111 | m_value = IconbarTool::SCREEN; | ||
112 | else | ||
113 | setDefaultValue(); | ||
114 | } | ||
115 | |||
116 | |||
117 | template<> | ||
118 | std::string FbTk::Resource<IconbarTool::WheelMode>::getString() { | ||
119 | switch(m_value) { | ||
120 | case IconbarTool::ON: | ||
121 | return std::string("On"); | ||
122 | break; | ||
123 | case IconbarTool::SCREEN: | ||
124 | return std::string("Screen"); | ||
125 | break; | ||
126 | }; | ||
127 | return std::string("Off"); | ||
128 | } | ||
129 | |||
130 | template<> | ||
69 | void FbTk::Resource<Container::Alignment>::setDefaultValue() { | 131 | void FbTk::Resource<Container::Alignment>::setDefaultValue() { |
70 | m_value = Container::RELATIVE; | 132 | m_value = Container::RELATIVE; |
71 | } | 133 | } |
@@ -275,6 +337,12 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr | |||
275 | m_empty_pm(0), | 337 | m_empty_pm(0), |
276 | m_rc_mode(screen.resourceManager(), WORKSPACE, | 338 | m_rc_mode(screen.resourceManager(), WORKSPACE, |
277 | screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), | 339 | screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), |
340 | m_deiconify_mode(screen.resourceManager(), CURRENT, | ||
341 | screen.name() + ".iconbar.deiconifyMode", | ||
342 | screen.name() + ".iconbar.DeiconifyMode"), | ||
343 | m_wheel_mode(screen.resourceManager(), OFF, | ||
344 | screen.name() + ".iconbar.wheelMode", | ||
345 | screen.name() + ".iconbar.WheelMode"), | ||
278 | m_rc_alignment(screen.resourceManager(), Container::LEFT, | 346 | m_rc_alignment(screen.resourceManager(), Container::LEFT, |
279 | screen.name() + ".iconbar.alignment", screen.altName() + ".Iconbar.Alignment"), | 347 | screen.name() + ".iconbar.alignment", screen.altName() + ".Iconbar.Alignment"), |
280 | m_rc_client_width(screen.resourceManager(), 70, | 348 | m_rc_client_width(screen.resourceManager(), 70, |
@@ -404,6 +472,20 @@ void IconbarTool::setMode(Mode mode) { | |||
404 | renderTheme(); | 472 | renderTheme(); |
405 | } | 473 | } |
406 | 474 | ||
475 | void IconbarTool::setDeiconifyMode(DeiconifyMode mode) { | ||
476 | if (mode == *m_deiconify_mode) | ||
477 | return; | ||
478 | |||
479 | *m_deiconify_mode = mode; | ||
480 | } | ||
481 | |||
482 | void IconbarTool::setWheelMode(WheelMode mode) { | ||
483 | if (mode == *m_wheel_mode) | ||
484 | return; | ||
485 | *m_wheel_mode = mode; | ||
486 | } | ||
487 | |||
488 | |||
407 | unsigned int IconbarTool::width() const { | 489 | unsigned int IconbarTool::width() const { |
408 | return m_icon_container.width(); | 490 | return m_icon_container.width(); |
409 | } | 491 | } |
@@ -735,7 +817,12 @@ void IconbarTool::addWindow(FluxboxWindow &win) { | |||
735 | #ifdef DEBUG | 817 | #ifdef DEBUG |
736 | cerr<<"IconbarTool::addWindow(0x"<<&win<<" title = "<<win.title()<<")"<<endl; | 818 | cerr<<"IconbarTool::addWindow(0x"<<&win<<" title = "<<win.title()<<")"<<endl; |
737 | #endif // DEBUG | 819 | #endif // DEBUG |
738 | IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), win); | 820 | IconButton *button = new IconButton(*this, |
821 | m_icon_container, | ||
822 | m_theme.focusedText().font(), | ||
823 | win); | ||
824 | |||
825 | |||
739 | button->setTextPadding(*m_rc_client_padding); | 826 | button->setTextPadding(*m_rc_client_padding); |
740 | 827 | ||
741 | renderButton(*button, false); // update the attributes, but don't clear it | 828 | renderButton(*button, false); // update the attributes, but don't clear it |
diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index af1ba37..278bf21 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh | |||
@@ -20,7 +20,7 @@ | |||
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: IconbarTool.hh,v 1.17 2004/10/10 16:11:25 akir Exp $ | 23 | // $Id: IconbarTool.hh,v 1.18 2004/10/22 00:35:29 akir Exp $ |
24 | 24 | ||
25 | #ifndef ICONBARTOOL_HH | 25 | #ifndef ICONBARTOOL_HH |
26 | #define ICONBARTOOL_HH | 26 | #define ICONBARTOOL_HH |
@@ -54,6 +54,20 @@ public: | |||
54 | ALLWINDOWS ///< all windows and all icons from all workspaces | 54 | ALLWINDOWS ///< all windows and all icons from all workspaces |
55 | }; | 55 | }; |
56 | 56 | ||
57 | /// deiconfiy mode for iconbuttons | ||
58 | enum DeiconifyMode { | ||
59 | CURRENT, ///< raise the window on the current workspace | ||
60 | FOLLOW, ///< raise the window on the workspace it was iconified from | ||
61 | SEMIFOLLOW, ///< like current for iconified windows, and like follow for others | ||
62 | }; | ||
63 | |||
64 | /// wheeling on iconbutton | ||
65 | enum WheelMode { | ||
66 | OFF, ///< no wheeling, default mode | ||
67 | ON, ///< enabled wheeling | ||
68 | SCREEN ///< in perfect harmony with desktopwheeling-value | ||
69 | }; | ||
70 | |||
57 | IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, | 71 | IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, |
58 | BScreen &screen, FbTk::Menu &menu); | 72 | BScreen &screen, FbTk::Menu &menu); |
59 | ~IconbarTool(); | 73 | ~IconbarTool(); |
@@ -68,12 +82,17 @@ public: | |||
68 | void hide(); | 82 | void hide(); |
69 | void setAlignment(Container::Alignment a); | 83 | void setAlignment(Container::Alignment a); |
70 | void setMode(Mode mode); | 84 | void setMode(Mode mode); |
85 | void setDeiconifyMode(DeiconifyMode mode); | ||
86 | void setWheelMode(WheelMode mode); | ||
71 | 87 | ||
72 | unsigned int width() const; | 88 | unsigned int width() const; |
73 | unsigned int height() const; | 89 | unsigned int height() const; |
74 | unsigned int borderWidth() const; | 90 | unsigned int borderWidth() const; |
75 | 91 | ||
76 | Mode mode() const { return *m_rc_mode; } | 92 | Mode mode() const { return *m_rc_mode; } |
93 | DeiconifyMode deiconifyMode() const { return *m_deiconify_mode; } | ||
94 | WheelMode wheelMode() const { return *m_wheel_mode; } | ||
95 | |||
77 | Container::Alignment alignment() const { return m_icon_container.alignment(); } | 96 | Container::Alignment alignment() const { return m_icon_container.alignment(); } |
78 | private: | 97 | private: |
79 | /// @return button associated with window | 98 | /// @return button associated with window |
@@ -117,6 +136,8 @@ private: | |||
117 | 136 | ||
118 | IconList m_icon_list; | 137 | IconList m_icon_list; |
119 | FbTk::Resource<Mode> m_rc_mode; | 138 | FbTk::Resource<Mode> m_rc_mode; |
139 | FbTk::Resource<DeiconifyMode> m_deiconify_mode; | ||
140 | FbTk::Resource<WheelMode> m_wheel_mode; | ||
120 | FbTk::Resource<Container::Alignment> m_rc_alignment; ///< alignment of buttons | 141 | FbTk::Resource<Container::Alignment> m_rc_alignment; ///< alignment of buttons |
121 | FbTk::Resource<int> m_rc_client_width; ///< size of client button in LEFT/RIGHT mode | 142 | FbTk::Resource<int> m_rc_client_width; ///< size of client button in LEFT/RIGHT mode |
122 | FbTk::Resource<unsigned int> m_rc_client_padding; ///< padding of the text | 143 | FbTk::Resource<unsigned int> m_rc_client_padding; ///< padding of the text |