all repos — fluxbox @ 22aa93c56de131b80dfb161615650c4fb6cf6832

custom fork of the fluxbox windowmanager

fix the Focus key command
Mark Tiefenbruck mark@fluxbox.org
commit

22aa93c56de131b80dfb161615650c4fb6cf6832

parent

24bea22035e79c17fa6b6fdcd60f88e4eac467d8

M ChangeLogChangeLog

@@ -1,6 +1,8 @@

(Format: Year/Month/Day) Changes for 1.1 *08/08/05: + * Fixed Focus key command (Mark) + CurrentWindowCmd.cc/hh FocusableList.cc/hh * Added new SetLayer key command (Mark) CurrentWindowCmd.cc/hh * Make ShowDesktop command toggle between showing windows and desktop (Mark)
M doc/asciidoc/fluxbox-keys.txtdoc/asciidoc/fluxbox-keys.txt

@@ -163,10 +163,13 @@ Start dragging to add this window to another's tabgroup.

Window Commands ~~~~~~~~~~~~~~~ -These commands affect only the currently focused window. +These commands ordinarily affect only the currently focused window. The +*OnWindow* modifier and *ForEach* command may affect the window that is used. -*Activate* | *Focus*:: - Set the focus to the window matching the argument, and raise it. +*Activate* ['pattern'] | *Focus* ['pattern']:: + Set the focus to the window matching the argument. If 'pattern' is + omitted, this may be used with the *OnWindow* modifier to set the + focus. See *CLIENT PATTERNS* for more about the 'pattern' arguments. *Minimize* | *MinimizeWindow* | *Iconify*:: Minimize the current window, equivalent to the window button.
M doc/fluxbox-keys.5doc/fluxbox-keys.5

@@ -165,11 +165,19 @@ .RS 4

Start dragging to add this window to another\'s tabgroup\. .RE .SS "Window Commands" -These commands affect only the currently focused window\. +These commands ordinarily affect only the currently focused window\. The \fBOnWindow\fR modifier and \fBForEach\fR command may affect the window that is used\. .PP -\fBActivate\fR | \fBFocus\fR +\fBActivate\fR [\fIpattern\fR] | \fBFocus\fR [\fIpattern\fR] .RS 4 -Set the focus to the window matching the argument, and raise it\. +Set the focus to the window matching the argument\. If +\fIpattern\fR +is omitted, this may be used with the +\fBOnWindow\fR +modifier to set the focus\. See +\fBCLIENT PATTERNS\fR +for more about the +\fIpattern\fR +arguments\. .RE .PP \fBMinimize\fR | \fBMinimizeWindow\fR | \fBIconify\fR
M src/CurrentWindowCmd.ccsrc/CurrentWindowCmd.cc

@@ -56,8 +56,6 @@ else if (command == "lower")

return new CurrentWindowCmd(&FluxboxWindow::lower); else if (command == "lowerlayer") return new CurrentWindowCmd(&FluxboxWindow::lowerLayer); - else if (command == "activate" || command == "focus") - return new CurrentWindowCmd((void (FluxboxWindow::*)())&FluxboxWindow::focus); else if (command == "close") return new CurrentWindowCmd(&FluxboxWindow::close); else if (command == "killwindow" || command == "kill")

@@ -98,8 +96,6 @@ REGISTER_COMMAND_PARSER(raise, createCurrentWindowCmd, void);

REGISTER_COMMAND_PARSER(raiselayer, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(lower, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(lowerlayer, createCurrentWindowCmd, void); -REGISTER_COMMAND_PARSER(activate, createCurrentWindowCmd, void); -REGISTER_COMMAND_PARSER(focus, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(close, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(killwindow, createCurrentWindowCmd, void); REGISTER_COMMAND_PARSER(kill, createCurrentWindowCmd, void);

@@ -250,6 +246,18 @@

while (--num > 0) ++it; (*it)->focus(); +} + +REGISTER_COMMAND_WITH_ARGS(activate, FocusCmd, void); +REGISTER_COMMAND_WITH_ARGS(focus, FocusCmd, void); + +void FocusCmd::real_execute() { + Focusable *win = 0; + if (!m_pat.error()) + win = fbwindow().screen().focusControl().focusedOrderWinList().find(m_pat); + if (!win) + win = &fbwindow(); + win->focus(); } REGISTER_COMMAND(startmoving, StartMovingCmd, void);
M src/CurrentWindowCmd.hhsrc/CurrentWindowCmd.hh

@@ -137,6 +137,16 @@ private:

const int m_tab_num; }; +// focus the window +class FocusCmd: public WindowHelperCmd { +public: + explicit FocusCmd(const std::string &pat): m_pat(pat.c_str()) { } +protected: + void real_execute(); +private: + const ClientPattern m_pat; +}; + // begin moving with mouse class StartMovingCmd: public WindowHelperCmd { public:
M src/FocusableList.ccsrc/FocusableList.cc

@@ -286,8 +286,17 @@ }

bool FocusableList::contains(const Focusable &win) const { Focusables::const_iterator it = m_list.begin(), it_end = m_list.end(); - it = find(it, it_end, &win); + it = std::find(it, it_end, &win); return (it != it_end); +} + +Focusable *FocusableList::find(const ClientPattern &pat) const { + Focusables::const_iterator it = m_list.begin(), it_end = m_list.end(); + for (; it != it_end; ++it) { + if (pat.match(**it)) + return *it; + } + return 0; } void FocusableList::attachChild(FocusableList &child) const {
M src/FocusableList.hhsrc/FocusableList.hh

@@ -70,6 +70,8 @@ /// does the list contain any windows?

bool empty() const { return m_list.empty(); } /// does the list contain the given window? bool contains(const Focusable &win) const; + /// find the first window matching the pattern + Focusable *find(const ClientPattern &pattern) const; /** @name signals