add SetLayer key command

This commit is contained in:
Mark Tiefenbruck 2008-08-05 00:05:21 -07:00
parent 9d71ad9c14
commit 24bea22035
7 changed files with 53 additions and 23 deletions

View file

@ -1,6 +1,8 @@
(Format: Year/Month/Day)
Changes for 1.1
*08/08/05:
* Added new SetLayer key command (Mark)
CurrentWindowCmd.cc/hh
* Make ShowDesktop command toggle between showing windows and desktop (Mark)
WorkspaceCmd.cc
* Created new `fluxbox-keys' man page (thanks Jim Ramsay)

View file

@ -186,6 +186,11 @@ These commands affect only the currently focused window.
Raise the window up to the layer above, or lower it to the layer
below. See 'fluxbox(1)' for a discussion of layers.
*SetLayer* 'layer'::
Move the window to the specified layer. 'layer' should be one of
*AboveDock*, *Dock*, *Top*, *Normal*, *Bottom*, *Desktop*. See
'fluxbox(1)' for a discussion of layers.
*Close*::
Close the current window, equivalent to the window button.
@ -599,7 +604,7 @@ The following values are accepted for 'propertyname':::
head where the mouse pointer currently resides.
*Layer*;;
The string name of the window's layer, which is one of
*Above Dock*, *Dock*, *Top*, *Normal*, *Bottom*, *Desktop*
*AboveDock*, *Dock*, *Top*, *Normal*, *Bottom*, *Desktop*
.Matches any windows with the CLASSNAME of "xterm"
..........

View file

@ -1,11 +1,11 @@
.\" Title: fluxbox-keys
.\" Author:
.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
.\" Date: 08/04/2008
.\" Date: 08/05/2008
.\" Manual:
.\" Source:
.\"
.TH "FLUXBOX\-KEYS" "5" "08/04/2008" "" ""
.TH "FLUXBOX\-KEYS" "5" "08/05/2008" "" ""
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
@ -201,6 +201,21 @@ Raise the window up to the layer above, or lower it to the layer below\. See
for a discussion of layers\.
.RE
.PP
\fBSetLayer\fR \fIlayer\fR
.RS 4
Move the window to the specified layer\.
\fIlayer\fR
should be one of
\fBAboveDock\fR,
\fBDock\fR,
\fBTop\fR,
\fBNormal\fR,
\fBBottom\fR,
\fBDesktop\fR\. See
\fIfluxbox(1)\fR
for a discussion of layers\.
.RE
.PP
\fBClose\fR
.RS 4
Close the current window, equivalent to the window button\.
@ -863,7 +878,7 @@ which refers to the head where the mouse pointer currently resides\.
\fBLayer\fR
.RS 4
The string name of the window\'s layer, which is one of
\fBAbove Dock\fR,
\fBAboveDock\fR,
\fBDock\fR,
\fBTop\fR,
\fBNormal\fR,

View file

@ -23,6 +23,7 @@
#include "CurrentWindowCmd.hh"
#include "fluxbox.hh"
#include "Layer.hh"
#include "Window.hh"
#include "WindowCmd.hh"
#include "Screen.hh"
@ -479,6 +480,18 @@ void FullscreenCmd::real_execute() {
fbwindow().setFullscreen(!fbwindow().isFullscreen());
}
FbTk::Command<void> *SetLayerCmd::parse(const string &command,
const string &args, bool trusted) {
int l = Layer::getNumFromString(args);
return (l == -1) ? 0 : new SetLayerCmd(l);
}
REGISTER_COMMAND_PARSER(setlayer, SetLayerCmd::parse, void);
void SetLayerCmd::real_execute() {
fbwindow().moveToLayer(m_layer);
}
FbTk::Command<void> *SetAlphaCmd::parse(const string &command, const string &args,
bool trusted) {
typedef std::vector<string> StringTokens;

View file

@ -247,6 +247,17 @@ private:
int m_relative, m_un_relative;
};
class SetLayerCmd: public WindowHelperCmd {
public:
explicit SetLayerCmd(int layer): m_layer(layer) { }
static FbTk::Command<void> *parse(const std::string &command,
const std::string &args, bool trusted);
protected:
void real_execute();
private:
int m_layer;
};
class MatchCmd: public WindowHelperBoolCmd {
public:
MatchCmd(const std::string &pat): m_pat(pat.c_str()) { };

View file

@ -54,7 +54,7 @@ public:
explicit Layer(int i) : m_num(i) {};
static int getNumFromString(string &str) {
static int getNumFromString(const string &str) {
int tempnum = 0;
if (sscanf(str.c_str(), "%d", &tempnum) == 1)
return tempnum;

View file

@ -411,24 +411,8 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) {
else
had_error = true;
} else if (strcasecmp(str_key.c_str(), "Layer") == 0) {
unsigned int l;
if (strcasecmp(str_label.c_str(), "DESKTOP") == 0) {
l = Layer::DESKTOP;
} else if (strcasecmp(str_label.c_str(), "BOTTOM") == 0) {
l = Layer::BOTTOM;
} else if (strcasecmp(str_label.c_str(), "NORMAL") == 0) {
l = Layer::NORMAL;
} else if (strcasecmp(str_label.c_str(), "TOP") == 0) {
l = Layer::TOP;
} else if (strcasecmp(str_label.c_str(), "DOCK") == 0) {
l = Layer::DOCK;
} else if (strcasecmp(str_label.c_str(), "ABOVEDOCK") == 0) {
l = Layer::ABOVE_DOCK;
} else if (strcasecmp(str_label.c_str(), "MENU") == 0) {
l = Layer::MENU;
} else if (!getuint(str_label.c_str(), l)) {
had_error = true;
}
int l = Layer::getNumFromString(str_label);
had_error = (l == -1);
if (!had_error)
app.rememberLayer(l);
} else if (strcasecmp(str_key.c_str(), "Dimensions") == 0) {