From e027cad57de13c089b03df53ecfb2b31edb5d437 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 7 May 2002 14:09:32 +0000 Subject: minor cleaning --- src/Clientmenu.cc | 53 +++++++++++++++++++++++++++------------------------- src/Clientmenu.hh | 26 +++++++++++--------------- src/Workspacemenu.cc | 37 ++++++++++++++++++------------------ src/Workspacemenu.hh | 17 ++++++----------- 4 files changed, 63 insertions(+), 70 deletions(-) diff --git a/src/Clientmenu.cc b/src/Clientmenu.cc index 68b6173..c7fe7a9 100644 --- a/src/Clientmenu.cc +++ b/src/Clientmenu.cc @@ -1,3 +1,5 @@ +// Clientmenu.cc for Fluxbox +// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org) // Clientmenu.cc for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // @@ -19,14 +21,13 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// stupid macros needed to access some functions in version 2 of the GNU C -// library -#ifndef _GNU_SOURCE -#define _GNU_SOURCE +//use GNU extensions +#ifndef _GNU_SOURCE +#define _GNU_SOURCE #endif // _GNU_SOURCE -#ifdef HAVE_CONFIG_H -# include "../config.h" +#ifdef HAVE_CONFIG_H +# include "../config.h" #endif // HAVE_CONFIG_H #include "fluxbox.hh" @@ -37,27 +38,29 @@ #include "Workspacemenu.hh" -Clientmenu::Clientmenu(Workspace *ws) : Basemenu(ws->getScreen()) { - wkspc = ws; - screen = wkspc->getScreen(); - - setInternalMenu(); +Clientmenu::Clientmenu(Workspace *ws) : Basemenu(ws->getScreen()), +m_wkspc(ws) { + setInternalMenu(); } void Clientmenu::itemSelected(int button, unsigned int index) { - if (button > 2) return; - - FluxboxWindow *win = wkspc->getWindow(index); - if (win) { - if (button == 1) { - if (! wkspc->isCurrent()) wkspc->setCurrent(); - } else if (button == 2) { - if (! wkspc->isCurrent()) win->deiconify(True, False); - } - wkspc->raiseWindow(win); - win->setInputFocus(); - } - - if (! (screen->getWorkspacemenu()->isTorn() || isTorn())) hide(); + if (button > 2) + return; + //get the window with index of the item we selected + FluxboxWindow *win = m_wkspc->getWindow(index); + if (win) { + if (button == 1) { + if (! m_wkspc->isCurrent()) + m_wkspc->setCurrent(); + } else if (button == 2) { + if (! m_wkspc->isCurrent()) + win->deiconify(true, false); + } + m_wkspc->raiseWindow(win); + win->setInputFocus(); + } + + if (! (screen()->getWorkspacemenu()->isTorn() || isTorn())) + hide(); } diff --git a/src/Clientmenu.hh b/src/Clientmenu.hh index 19a6d57..f49822a 100644 --- a/src/Clientmenu.hh +++ b/src/Clientmenu.hh @@ -19,29 +19,25 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#ifndef CLIENTMENU_HH -#define CLIENTMENU_HH +#ifndef CLIENTMENU_HH +#define CLIENTMENU_HH -// forward declarations -class Clientmenu; -class Workspace; #include "Basemenu.hh" +// forward declarations +class Workspace; class Clientmenu : public Basemenu { -private: - BScreen *screen; - Workspace *wkspc; - - -protected: - virtual void itemSelected(int button, unsigned int index); - - public: - Clientmenu(Workspace *); + Clientmenu(Workspace *wrksp); + +protected: + virtual void itemSelected(int button, unsigned int index); + +private: + Workspace *m_wkspc; }; diff --git a/src/Workspacemenu.cc b/src/Workspacemenu.cc index a9b0b52..d13621b 100644 --- a/src/Workspacemenu.cc +++ b/src/Workspacemenu.cc @@ -21,28 +21,26 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Workspacemenu.cc,v 1.6 2002/04/09 23:19:17 fluxgen Exp $ +// $Id: Workspacemenu.cc,v 1.7 2002/05/07 14:05:00 fluxgen Exp $ //use GNU extension #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif // _GNU_SOURCE -#ifdef HAVE_CONFIG_H -# include "../config.h" +#ifdef HAVE_CONFIG_H +#include "../config.h" #endif // HAVE_CONFIG_H +#include "Workspacemenu.hh" + #include "i18n.hh" -#include "fluxbox.hh" #include "Screen.hh" -#include "Toolbar.hh" -#include "Workspacemenu.hh" #include "Workspace.hh" #include #include Workspacemenu::Workspacemenu(BScreen *scrn) : Basemenu(scrn) { - screen = scrn; setInternalMenu(); I18n *i18n = I18n::instance(); @@ -60,17 +58,18 @@ Workspacemenu::Workspacemenu(BScreen *scrn) : Basemenu(scrn) { void Workspacemenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - if (index == 0) - screen->addWorkspace(); - else if (index == 1) - screen->removeLastWorkspace(); - else if ((screen->getCurrentWorkspace()->workspaceID() != - (index - 2)) && ((index - 2) < screen->getCount())) - screen->changeWorkspaceID(index - 2); - - if (! (screen->getWorkspacemenu()->isTorn() || isTorn())) - hide(); - } + if (button == 1) { + if (index == 0) + screen()->addWorkspace(); + else if (index == 1) + screen()->removeLastWorkspace(); + else if ((screen()->getCurrentWorkspace()->workspaceID() != + (index - 2)) && ((index - 2) < screen()->getCount())) { + screen()->changeWorkspaceID(index - 2); + } + + if (! (screen()->getWorkspacemenu()->isTorn() || isTorn())) + hide(); + } } diff --git a/src/Workspacemenu.hh b/src/Workspacemenu.hh index 28e1cca..e1b9996 100644 --- a/src/Workspacemenu.hh +++ b/src/Workspacemenu.hh @@ -15,29 +15,24 @@ // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#ifndef WORKSPACEMENU_HH -#define WORKSPACEMENU_HH +#ifndef WORKSPACEMENU_HH +#define WORKSPACEMENU_HH #include "Basemenu.hh" -class Workspace; class Workspacemenu : public Basemenu { -private: - BScreen *screen; +public: + Workspacemenu(BScreen *screen); protected: virtual void itemSelected(int button, unsigned int index); -public: - Workspacemenu(BScreen *); }; - -#endif // _WORKSPACEMENU_HH_ - +#endif // WORKSPACEMENU_HH -- cgit v0.11.2