fix the Focus key command

This commit is contained in:
Mark Tiefenbruck 2008-08-05 05:00:48 -07:00
parent 24bea22035
commit 22aa93c56d
7 changed files with 53 additions and 11 deletions

View file

@ -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)

View file

@ -163,10 +163,13 @@ BottomRight*
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.

View file

@ -165,11 +165,19 @@ By default \fIcorner\fR is \fBBottomRight\fR, but may be overridden with one of:
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

View file

@ -56,8 +56,6 @@ FbTk::Command<void> *createCurrentWindowCmd(const std::string &command,
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);
@ -252,6 +248,18 @@ void GoToTabCmd::real_execute() {
(*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);
void StartMovingCmd::real_execute() {

View file

@ -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:

View file

@ -286,10 +286,19 @@ void FocusableList::reset() {
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_addsig.attach(&child);
m_removesig.attach(&child);

View file

@ -70,6 +70,8 @@ public:
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