minor cleaning

This commit is contained in:
fluxgen 2002-05-07 14:09:32 +00:00
parent 0ec9f1a21d
commit e027cad57d
4 changed files with 63 additions and 70 deletions

View file

@ -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;
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();
}
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 (! (screen()->getWorkspacemenu()->isTorn() || isTorn()))
hide();
}

View file

@ -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;
};

View file

@ -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 "i18n.hh"
#include "fluxbox.hh"
#include "Screen.hh"
#include "Toolbar.hh"
#include "Workspacemenu.hh"
#include "i18n.hh"
#include "Screen.hh"
#include "Workspace.hh"
#include <iostream>
#include <cassert>
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();
}
}

View file

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