aboutsummaryrefslogtreecommitdiff
path: root/src/IconbarTool.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/IconbarTool.cc')
-rw-r--r--src/IconbarTool.cc113
1 files changed, 11 insertions, 102 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 2c73dc5..df7990d 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -83,40 +83,6 @@ void FbTk::Resource<IconbarTool::Mode>::setFromString(const char *strval) {
83} 83}
84 84
85template<> 85template<>
86void FbTk::Resource<IconbarTool::WheelMode>::setDefaultValue() {
87 m_value = IconbarTool::SCREEN;
88}
89
90
91template<>
92void FbTk::Resource<IconbarTool::WheelMode>::setFromString(const char* strval) {
93 if (strncasecmp(strval, "off", strlen("off")) == 0)
94 m_value = IconbarTool::OFF;
95 else if (strncasecmp(strval, "on", strlen("on")) == 0)
96 m_value = IconbarTool::ON;
97 else if (strncasecmp(strval, "screen", strlen("screen")) == 0)
98 m_value = IconbarTool::SCREEN;
99 else
100 setDefaultValue();
101}
102
103
104template<>
105string FbTk::Resource<IconbarTool::WheelMode>::getString() const {
106 switch(m_value) {
107 case IconbarTool::ON:
108 return string("On");
109 break;
110 case IconbarTool::SCREEN:
111 return string("Screen");
112 break;
113 case IconbarTool::OFF:
114 default:
115 return string("Off");
116 };
117}
118
119template<>
120void FbTk::Resource<Container::Alignment>::setDefaultValue() { 86void FbTk::Resource<Container::Alignment>::setDefaultValue() {
121 m_value = Container::RELATIVE; 87 m_value = Container::RELATIVE;
122} 88}
@@ -330,67 +296,23 @@ private:
330 296
331class FocusCommand: public FbTk::Command { 297class FocusCommand: public FbTk::Command {
332public: 298public:
333 explicit FocusCommand(const IconbarTool& tool, FluxboxWindow &win) : 299 explicit FocusCommand(Focusable &win): m_win(win) { }
334 m_win(win), m_tool(tool) { }
335 void execute() { 300 void execute() {
336 // this needs to be a local variable, as this object could be destroyed 301 // this needs to be a local variable, as this object could be destroyed
337 // if the workspace is changed. 302 // if the workspace is changed.
338 FluxboxWindow &win = m_win; 303 FluxboxWindow *fbwin = m_win.fbwindow();
339 if(win.isIconic() || !win.isFocused()) { 304 if (!fbwin)
340 switch(win.screen().getUserFollowModel()) { 305 return;
341 case BScreen::SEMIFOLLOW_ACTIVE_WINDOW: 306 if (m_win.isFocused())
342 if (win.isIconic()) { 307 fbwin->iconify();
343 win.screen().sendToWorkspace(win.screen().currentWorkspaceID(), &win); 308 else {
344 } else { 309 m_win.focus();
345 win.screen().changeWorkspaceID(win.workspaceNumber()); 310 fbwin->raise();
346 } 311 }
347 break;
348 case BScreen::FETCH_ACTIVE_WINDOW:
349 win.screen().sendToWorkspace(win.screen().currentWorkspaceID(), &win);
350 break;
351 case BScreen::FOLLOW_ACTIVE_WINDOW:
352 if (!win.isStuck())
353 win.screen().changeWorkspaceID(win.workspaceNumber());
354 default:
355 break;
356 };
357 win.raiseAndFocus();
358 } else
359 win.iconify();
360 }
361
362private:
363 FluxboxWindow &m_win;
364 const IconbarTool& m_tool;
365};
366
367// simple forwarding of wheeling, but only
368// if desktopwheeling is enabled
369class WheelWorkspaceCmd : public FbTk::Command {
370public:
371 explicit WheelWorkspaceCmd(const IconbarTool& tool, Focusable &win,
372 const char* cmd) :
373 m_win(win), m_cmd(CommandParser::instance().parseLine(cmd)), m_tool(tool) { }
374 void execute() {
375
376 switch(m_tool.wheelMode()) {
377 case IconbarTool::ON:
378 m_cmd->execute();
379 break;
380 case IconbarTool::SCREEN:
381 if(m_win.screen().isDesktopWheeling())
382 m_cmd->execute();
383 break;
384 case IconbarTool::OFF:
385 default:
386 break;
387 };
388 } 312 }
389 313
390private: 314private:
391 Focusable &m_win; 315 Focusable &m_win;
392 RefCmd m_cmd;
393 const IconbarTool& m_tool;
394}; 316};
395 317
396}; // end anonymous namespace 318}; // end anonymous namespace
@@ -404,9 +326,6 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr
404 m_empty_pm( screen.imageControl() ), 326 m_empty_pm( screen.imageControl() ),
405 m_rc_mode(screen.resourceManager(), WORKSPACE, 327 m_rc_mode(screen.resourceManager(), WORKSPACE,
406 screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), 328 screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"),
407 m_wheel_mode(screen.resourceManager(), OFF,
408 screen.name() + ".iconbar.wheelMode",
409 screen.name() + ".iconbar.WheelMode"),
410 m_rc_alignment(screen.resourceManager(), Container::LEFT, 329 m_rc_alignment(screen.resourceManager(), Container::LEFT,
411 screen.name() + ".iconbar.alignment", screen.altName() + ".Iconbar.Alignment"), 330 screen.name() + ".iconbar.alignment", screen.altName() + ".Iconbar.Alignment"),
412 m_rc_client_width(screen.resourceManager(), 70, 331 m_rc_client_width(screen.resourceManager(), 70,
@@ -730,20 +649,10 @@ void IconbarTool::addWindow(Focusable &win) {
730#endif // DEBUG 649#endif // DEBUG
731 IconButton *button = new IconButton(m_icon_container, m_theme, win); 650 IconButton *button = new IconButton(m_icon_container, m_theme, win);
732 651
733 RefCmd next_workspace(new ::WheelWorkspaceCmd(*this, win, "nextworkspace")); 652 RefCmd focus_cmd(new ::FocusCommand(win));
734 RefCmd prev_workspace(new ::WheelWorkspaceCmd(*this, win, "prevworkspace"));
735
736 RefCmd focus_cmd(new ::FocusCommand(*this, *fbwin));
737 RefCmd menu_cmd(new ::ShowMenu(*fbwin)); 653 RefCmd menu_cmd(new ::ShowMenu(*fbwin));
738 button->setOnClick(focus_cmd, 1); 654 button->setOnClick(focus_cmd, 1);
739 button->setOnClick(menu_cmd, 3); 655 button->setOnClick(menu_cmd, 3);
740 if(win.screen().isReverseWheeling()) {
741 button->setOnClick(next_workspace, 5);
742 button->setOnClick(prev_workspace, 4);
743 } else {
744 button->setOnClick(next_workspace, 4);
745 button->setOnClick(prev_workspace, 5);
746 }
747 656
748 renderButton(*button, false); // update the attributes, but don't clear it 657 renderButton(*button, false); // update the attributes, but don't clear it
749 m_icon_container.insertItem(button); 658 m_icon_container.insertItem(button);