From 24bea22035e79c17fa6b6fdcd60f88e4eac467d8 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Tue, 5 Aug 2008 00:05:21 -0700 Subject: add SetLayer key command --- ChangeLog | 2 ++ doc/asciidoc/fluxbox-keys.txt | 7 ++++++- doc/fluxbox-keys.5 | 21 ++++++++++++++++++--- src/CurrentWindowCmd.cc | 13 +++++++++++++ src/CurrentWindowCmd.hh | 11 +++++++++++ src/Layer.hh | 2 +- src/Remember.cc | 20 ++------------------ 7 files changed, 53 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a76aea..af47839 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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) diff --git a/doc/asciidoc/fluxbox-keys.txt b/doc/asciidoc/fluxbox-keys.txt index 197e175..70f3b66 100644 --- a/doc/asciidoc/fluxbox-keys.txt +++ b/doc/asciidoc/fluxbox-keys.txt @@ -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" .......... diff --git a/doc/fluxbox-keys.5 b/doc/fluxbox-keys.5 index 01bbd05..aa0523a 100644 --- a/doc/fluxbox-keys.5 +++ b/doc/fluxbox-keys.5 @@ -1,11 +1,11 @@ .\" Title: fluxbox-keys .\" Author: .\" Generator: DocBook XSL Stylesheets v1.73.2 -.\" 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, diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index 4c027d9..42ee69c 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc @@ -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 *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 *SetAlphaCmd::parse(const string &command, const string &args, bool trusted) { typedef std::vector StringTokens; diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index 157855c..5d381a2 100644 --- a/src/CurrentWindowCmd.hh +++ b/src/CurrentWindowCmd.hh @@ -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 *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()) { }; diff --git a/src/Layer.hh b/src/Layer.hh index 58fb5b6..da8f04c 100644 --- a/src/Layer.hh +++ b/src/Layer.hh @@ -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; diff --git a/src/Remember.cc b/src/Remember.cc index ff0094c..f76fe9b 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -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) { -- cgit v0.11.2