moved all focus handling to class FocusControl

This commit is contained in:
fluxgen 2006-02-18 11:40:52 +00:00
parent 330c8c0b09
commit f53c93e5e0
2 changed files with 33 additions and 27 deletions

View file

@ -25,48 +25,54 @@
#ifndef FOCUSMODELMENUITEM_HH #ifndef FOCUSMODELMENUITEM_HH
#define FOCUSMODELMENUITEM_HH #define FOCUSMODELMENUITEM_HH
#include "Screen.hh"
#include "FbTk/MenuItem.hh" #include "FbTk/MenuItem.hh"
#include "FbTk/RefCount.hh" #include "FbTk/RefCount.hh"
#include "FbTk/Command.hh" #include "FbTk/Command.hh"
#include "FocusControl.hh"
class FocusModelMenuItem : public FbTk::MenuItem { class FocusModelMenuItem : public FbTk::MenuItem {
public: public:
FocusModelMenuItem(const char *label, BScreen &screen, FocusModelMenuItem(const char *label, FocusControl &focus_control,
BScreen::FocusModel model, FocusControl::FocusModel model,
FbTk::RefCount<FbTk::Command> &cmd): FbTk::RefCount<FbTk::Command> &cmd):
FbTk::MenuItem(label, cmd), m_screen(screen), m_focusmodel(model) { FbTk::MenuItem(label, cmd),
} m_focus_control(focus_control),
bool isEnabled() const { return m_screen.getFocusModel() != m_focusmodel; } m_focusmodel(model) { }
bool isEnabled() const { return m_focus_control.focusModel() != m_focusmodel; }
void click(int button, int time) { void click(int button, int time) {
m_screen.saveFocusModel(m_focusmodel); m_focus_control.setFocusModel(m_focusmodel);
FbTk::MenuItem::click(button, time); FbTk::MenuItem::click(button, time);
} }
private: private:
BScreen &m_screen; FocusControl &m_focus_control;
BScreen::FocusModel m_focusmodel; FocusControl::FocusModel m_focusmodel;
}; };
class TabFocusModelMenuItem : public FbTk::MenuItem { class TabFocusModelMenuItem : public FbTk::MenuItem {
public: public:
TabFocusModelMenuItem(const char *label, BScreen &screen, TabFocusModelMenuItem(const char *label,
BScreen::TabFocusModel model, FocusControl &focus_control,
FocusControl::TabFocusModel model,
FbTk::RefCount<FbTk::Command> &cmd): FbTk::RefCount<FbTk::Command> &cmd):
FbTk::MenuItem(label, cmd), m_screen(screen), m_tabfocusmodel(model) { FbTk::MenuItem(label, cmd),
} m_focus_control(focus_control),
bool isEnabled() const { return m_screen.getTabFocusModel() != m_tabfocusmodel; } m_tabfocusmodel(model) { }
bool isEnabled() const { return m_focus_control.tabFocusModel() != m_tabfocusmodel; }
void click(int button, int time) { void click(int button, int time) {
m_screen.saveTabFocusModel(m_tabfocusmodel); m_focus_control.setTabFocusModel(m_tabfocusmodel);
FbTk::MenuItem::click(button, time); FbTk::MenuItem::click(button, time);
} }
private: private:
BScreen &m_screen; FocusControl &m_focus_control;
BScreen::TabFocusModel m_tabfocusmodel; FocusControl::TabFocusModel m_tabfocusmodel;
}; };

View file

@ -50,17 +50,17 @@ void NextWindowCmd::execute() {
unsigned int mods = FbTk::KeyUtil::instance().cleanMods(fb->lastEvent().xkey.state); unsigned int mods = FbTk::KeyUtil::instance().cleanMods(fb->lastEvent().xkey.state);
mods = FbTk::KeyUtil::instance().isolateModifierMask(mods); mods = FbTk::KeyUtil::instance().isolateModifierMask(mods);
if (mods == 0) // can't stacked cycle unless there is a mod to grab if (mods == 0) // can't stacked cycle unless there is a mod to grab
screen->nextFocus(m_option | BScreen::CYCLELINEAR); screen->focusControl().nextFocus(m_option | FocusControl::CYCLELINEAR);
else { else {
// if stacked cycling, then set a watch for // if stacked cycling, then set a watch for
// the release of exactly these modifiers // the release of exactly these modifiers
if (!fb->watchingScreen() && if (!fb->watchingScreen() &&
!(m_option & BScreen::CYCLELINEAR)) !(m_option & FocusControl::CYCLELINEAR))
Fluxbox::instance()->watchKeyRelease(*screen, mods); Fluxbox::instance()->watchKeyRelease(*screen, mods);
screen->nextFocus(m_option); screen->focusControl().nextFocus(m_option);
} }
} else } else
screen->nextFocus(m_option); screen->focusControl().nextFocus(m_option);
} }
} }
@ -73,17 +73,17 @@ void PrevWindowCmd::execute() {
unsigned int mods = FbTk::KeyUtil::instance().cleanMods(fb->lastEvent().xkey.state); unsigned int mods = FbTk::KeyUtil::instance().cleanMods(fb->lastEvent().xkey.state);
mods = FbTk::KeyUtil::instance().isolateModifierMask(mods); mods = FbTk::KeyUtil::instance().isolateModifierMask(mods);
if (mods == 0) // can't stacked cycle unless there is a mod to grab if (mods == 0) // can't stacked cycle unless there is a mod to grab
screen->prevFocus(m_option | BScreen::CYCLELINEAR); screen->focusControl().prevFocus(m_option | FocusControl::CYCLELINEAR);
else { else {
// if stacked cycling, then set a watch for // if stacked cycling, then set a watch for
// the release of exactly these modifiers // the release of exactly these modifiers
if (!fb->watchingScreen() if (!fb->watchingScreen()
&& !(m_option & BScreen::CYCLELINEAR)) && !(m_option & FocusControl::CYCLELINEAR))
Fluxbox::instance()->watchKeyRelease(*screen, mods); Fluxbox::instance()->watchKeyRelease(*screen, mods);
screen->prevFocus(m_option); screen->focusControl().prevFocus(m_option);
} }
} else } else
screen->nextFocus(m_option); screen->focusControl().nextFocus(m_option);
} }
} }
@ -96,7 +96,7 @@ void DirFocusCmd::execute() {
if (client == 0 || client->fbwindow() == 0) if (client == 0 || client->fbwindow() == 0)
return; return;
screen->dirFocus(*client->fbwindow(), m_dir); screen->focusControl().dirFocus(*client->fbwindow(), m_dir);
} }
void NextWorkspaceCmd::execute() { void NextWorkspaceCmd::execute() {