Add code for toolbar modes

This commit is contained in:
rathnor 2003-03-03 21:51:13 +00:00
parent 824fd0db7a
commit 19875e5a5b
17 changed files with 657 additions and 156 deletions

View file

@ -1,7 +1,12 @@
(Format: Year/Month/Day) (Format: Year/Month/Day)
Changes for 0.9.1: Changes for 0.9.1:
*03/03/03:
------------------------------------------- * Add code for Toolbar modes (Simon)
AtomHandler.hh EventManager.cc Ewmh.hh/cc Gnome.hh/cc
IconBar.hh/cc Screen.hh/cc Toolbar.hh/cc ToolbarHandler.hh/cc
Window.cc fluxbox.cc
-------------------------------------------
Changes for 0.9.0: Changes for 0.9.0:
*03/02/23: *03/02/23:
* Fixed auto hide option for toolbar menu (Henrik) * Fixed auto hide option for toolbar menu (Henrik)

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: AtomHandler.hh,v 1.6 2003/02/02 16:32:37 rathnor Exp $ // $Id: AtomHandler.hh,v 1.7 2003/03/03 21:51:00 rathnor Exp $
#ifndef ATOMHANDLER_HH #ifndef ATOMHANDLER_HH
#define ATOMHANDLER_HH #define ATOMHANDLER_HH
@ -32,23 +32,24 @@ class BScreen;
class AtomHandler { class AtomHandler {
public: public:
virtual ~AtomHandler() { } virtual ~AtomHandler() { }
virtual void initForScreen(const BScreen &screen) = 0; virtual void initForScreen(BScreen &screen) = 0;
virtual void setupWindow(FluxboxWindow &win) = 0; virtual void setupWindow(FluxboxWindow &win) = 0;
virtual void updateClientList(const BScreen &screen) = 0; virtual void updateClientList(BScreen &screen) = 0;
virtual void updateWorkspaceNames(const BScreen &screen) = 0; virtual void updateWorkspaceNames(BScreen &screen) = 0;
virtual void updateCurrentWorkspace(const BScreen &screen) = 0; virtual void updateCurrentWorkspace(BScreen &screen) = 0;
virtual void updateWorkspaceCount(const BScreen &screen) = 0; virtual void updateWorkspaceCount(BScreen &screen) = 0;
virtual void updateWindowClose(FluxboxWindow &win) = 0;
virtual void updateWorkspace(FluxboxWindow &win) = 0; virtual void updateWorkspace(FluxboxWindow &win) = 0;
virtual void updateState(FluxboxWindow &win) = 0; virtual void updateState(FluxboxWindow &win) = 0;
virtual void updateHints(FluxboxWindow &win) = 0; virtual void updateHints(FluxboxWindow &win) = 0;
virtual void updateLayer(FluxboxWindow &win) = 0; virtual void updateLayer(FluxboxWindow &win) = 0;
virtual bool checkClientMessage(const XClientMessageEvent &ce, virtual bool checkClientMessage(const XClientMessageEvent &ce,
BScreen * const screen, FluxboxWindow * const win) = 0; BScreen * screen, FluxboxWindow * const win) = 0;
/// should this object be updated or not? /// should this object be updated or not?
bool update() const { return m_update; } bool update() const { return m_update; }
protected: protected:

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Ewmh.cc,v 1.10 2003/02/02 16:32:37 rathnor Exp $ // $Id: Ewmh.cc,v 1.11 2003/03/03 21:51:00 rathnor Exp $
#include "Ewmh.hh" #include "Ewmh.hh"
@ -42,7 +42,7 @@ Ewmh::~Ewmh() {
} }
} }
void Ewmh::initForScreen(const BScreen &screen) { void Ewmh::initForScreen(BScreen &screen) {
Display *disp = BaseDisplay::getXDisplay(); Display *disp = BaseDisplay::getXDisplay();
Window wincheck = XCreateSimpleWindow(disp, Window wincheck = XCreateSimpleWindow(disp,
@ -119,7 +119,7 @@ void Ewmh::setupWindow(FluxboxWindow &win) {
} }
} }
void Ewmh::updateClientList(const BScreen &screen) { void Ewmh::updateClientList(BScreen &screen) {
size_t num=0; size_t num=0;
BScreen::Workspaces::const_iterator workspace_it = screen.getWorkspacesList().begin(); BScreen::Workspaces::const_iterator workspace_it = screen.getWorkspacesList().begin();
@ -165,7 +165,7 @@ void Ewmh::updateClientList(const BScreen &screen) {
delete [] wl; delete [] wl;
} }
void Ewmh::updateWorkspaceNames(const BScreen &screen) { void Ewmh::updateWorkspaceNames(BScreen &screen) {
XTextProperty text; XTextProperty text;
const size_t number_of_desks = screen.getWorkspaceNames().size(); const size_t number_of_desks = screen.getWorkspaceNames().size();
@ -186,7 +186,7 @@ void Ewmh::updateWorkspaceNames(const BScreen &screen) {
delete [] names[i]; delete [] names[i];
} }
void Ewmh::updateCurrentWorkspace(const BScreen &screen) { void Ewmh::updateCurrentWorkspace(BScreen &screen) {
size_t workspace = screen.getCurrentWorkspaceID(); size_t workspace = screen.getCurrentWorkspaceID();
XChangeProperty(BaseDisplay::getXDisplay(), XChangeProperty(BaseDisplay::getXDisplay(),
screen.getRootWindow(), screen.getRootWindow(),
@ -195,7 +195,7 @@ void Ewmh::updateCurrentWorkspace(const BScreen &screen) {
} }
void Ewmh::updateWorkspaceCount(const BScreen &screen) { void Ewmh::updateWorkspaceCount(BScreen &screen) {
size_t numworkspaces = screen.getCount(); size_t numworkspaces = screen.getCount();
XChangeProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), XChangeProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(),
m_net_number_of_desktops, XA_CARDINAL, 32, PropModeReplace, m_net_number_of_desktops, XA_CARDINAL, 32, PropModeReplace,
@ -225,7 +225,7 @@ void Ewmh::updateWorkspace(FluxboxWindow &win) {
} }
// return true if we did handle the atom here // return true if we did handle the atom here
bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, BScreen * const screen, FluxboxWindow * const win) { bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, FluxboxWindow * const win) {
if (ce.message_type == m_net_wm_desktop) { if (ce.message_type == m_net_wm_desktop) {
if (screen == 0) if (screen == 0)

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Ewmh.hh,v 1.5 2003/02/02 16:32:37 rathnor Exp $ // $Id: Ewmh.hh,v 1.6 2003/03/03 21:51:00 rathnor Exp $
#include "AtomHandler.hh" #include "AtomHandler.hh"
@ -31,13 +31,13 @@ public:
Ewmh(); Ewmh();
~Ewmh(); ~Ewmh();
void initForScreen(const BScreen &screen); void initForScreen(BScreen &screen);
void setupWindow(FluxboxWindow &win); void setupWindow(FluxboxWindow &win);
void updateClientList(const BScreen &screen); void updateClientList(BScreen &screen);
void updateWorkspaceNames(const BScreen &screen); void updateWorkspaceNames(BScreen &screen);
void updateCurrentWorkspace(const BScreen &screen); void updateCurrentWorkspace(BScreen &screen);
void updateWorkspaceCount(const BScreen &screen); void updateWorkspaceCount(BScreen &screen);
void updateState(FluxboxWindow &win); void updateState(FluxboxWindow &win);
void updateLayer(FluxboxWindow &win); void updateLayer(FluxboxWindow &win);
@ -46,7 +46,11 @@ public:
bool checkClientMessage(const XClientMessageEvent &ce, bool checkClientMessage(const XClientMessageEvent &ce,
BScreen * const screen, FluxboxWindow * const win); BScreen * screen, FluxboxWindow * const win);
//ignore these ones
void updateWindowClose(FluxboxWindow &win) {}
private: private:
enum { STATE_REMOVE = 0, STATE_ADD = 1, STATE_TOGGLE = 2}; enum { STATE_REMOVE = 0, STATE_ADD = 1, STATE_TOGGLE = 2};

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: EventManager.cc,v 1.4 2003/02/23 14:30:18 fluxgen Exp $ // $Id: EventManager.cc,v 1.5 2003/03/03 21:51:13 rathnor Exp $
#include "EventManager.hh" #include "EventManager.hh"
#include "FbWindow.hh" #include "FbWindow.hh"
@ -95,7 +95,8 @@ void EventManager::registerEventHandler(EventHandler &ev, Window win) {
} }
void EventManager::unregisterEventHandler(Window win) { void EventManager::unregisterEventHandler(Window win) {
m_eventhandlers.erase(win); if (win != None)
m_eventhandlers.erase(win);
} }
}; };

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Gnome.cc,v 1.11 2003/02/18 15:11:07 rathnor Exp $ // $Id: Gnome.cc,v 1.12 2003/03/03 21:51:01 rathnor Exp $
#include "Gnome.hh" #include "Gnome.hh"
@ -43,7 +43,7 @@ Gnome::~Gnome() {
} }
} }
void Gnome::initForScreen(const BScreen &screen) { void Gnome::initForScreen(BScreen &screen) {
Display *disp = BaseDisplay::getXDisplay(); Display *disp = BaseDisplay::getXDisplay();
// create the GNOME window // create the GNOME window
Window gnome_win = XCreateSimpleWindow(disp, Window gnome_win = XCreateSimpleWindow(disp,
@ -120,7 +120,7 @@ void Gnome::setupWindow(FluxboxWindow &win) {
} }
void Gnome::updateClientList(const BScreen &screen) { void Gnome::updateClientList(BScreen &screen) {
size_t num=0; size_t num=0;
BScreen::Workspaces::const_iterator workspace_it = screen.getWorkspacesList().begin(); BScreen::Workspaces::const_iterator workspace_it = screen.getWorkspacesList().begin();
@ -162,7 +162,7 @@ void Gnome::updateClientList(const BScreen &screen) {
delete wl; delete wl;
} }
void Gnome::updateWorkspaceNames(const BScreen &screen) { void Gnome::updateWorkspaceNames(BScreen &screen) {
XTextProperty text; XTextProperty text;
int number_of_desks = screen.getWorkspaceNames().size(); int number_of_desks = screen.getWorkspaceNames().size();
@ -185,7 +185,7 @@ void Gnome::updateWorkspaceNames(const BScreen &screen) {
delete [] names[i]; delete [] names[i];
} }
void Gnome::updateCurrentWorkspace(const BScreen &screen) { void Gnome::updateCurrentWorkspace(BScreen &screen) {
int workspace = screen.getCurrentWorkspaceID(); int workspace = screen.getCurrentWorkspaceID();
XChangeProperty(BaseDisplay::getXDisplay(), XChangeProperty(BaseDisplay::getXDisplay(),
screen.getRootWindow(), screen.getRootWindow(),
@ -195,7 +195,7 @@ void Gnome::updateCurrentWorkspace(const BScreen &screen) {
updateClientList(screen); // make sure the client list is updated too updateClientList(screen); // make sure the client list is updated too
} }
void Gnome::updateWorkspaceCount(const BScreen &screen) { void Gnome::updateWorkspaceCount(BScreen &screen) {
int numworkspaces = screen.getCount(); int numworkspaces = screen.getCount();
XChangeProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), XChangeProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(),
m_gnome_wm_win_workspace_count, XA_CARDINAL, 32, PropModeReplace, m_gnome_wm_win_workspace_count, XA_CARDINAL, 32, PropModeReplace,
@ -242,7 +242,7 @@ void Gnome::updateHints(FluxboxWindow &win) {
} }
bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * const screen, FluxboxWindow * const win) { bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, FluxboxWindow * const win) {
if (ce.message_type == m_gnome_wm_win_workspace) { if (ce.message_type == m_gnome_wm_win_workspace) {
#ifdef DEBUG #ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<"): Got workspace atom="<<ce.data.l[0]<<endl; cerr<<__FILE__<<"("<<__LINE__<<"): Got workspace atom="<<ce.data.l[0]<<endl;

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Gnome.hh,v 1.5 2003/02/02 16:32:37 rathnor Exp $ // $Id: Gnome.hh,v 1.6 2003/03/03 21:51:01 rathnor Exp $
#ifndef GNOME_HH #ifndef GNOME_HH
#define GNOME_HH #define GNOME_HH
@ -64,22 +64,24 @@ public:
Gnome(); Gnome();
~Gnome(); ~Gnome();
void initForScreen(const BScreen &screen); void initForScreen(BScreen &screen);
void setupWindow(FluxboxWindow &win); void setupWindow(FluxboxWindow &win);
void updateClientList(const BScreen &screen); void updateClientList(BScreen &screen);
void updateWorkspaceNames(const BScreen &screen); void updateWorkspaceNames(BScreen &screen);
void updateCurrentWorkspace(const BScreen &screen); void updateCurrentWorkspace(BScreen &screen);
void updateWorkspaceCount(const BScreen &screen); void updateWorkspaceCount(BScreen &screen);
void updateState(FluxboxWindow &win); void updateState(FluxboxWindow &win);
void updateLayer(FluxboxWindow &win); void updateLayer(FluxboxWindow &win);
void updateHints(FluxboxWindow &win); void updateHints(FluxboxWindow &win);
void updateWorkspace(FluxboxWindow &win); void updateWorkspace(FluxboxWindow &win);
bool checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, FluxboxWindow * const win);
bool checkClientMessage(const XClientMessageEvent &ce, BScreen * const screen, FluxboxWindow * const win);
// ignore these ones
void updateWindowClose(FluxboxWindow &win) {}
private: private:
void setLayer(FluxboxWindow *win, int layer); void setLayer(FluxboxWindow *win, int layer);
void setState(FluxboxWindow *win, int state); void setState(FluxboxWindow *win, int state);

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: IconBar.cc,v 1.25 2003/02/23 14:29:08 fluxgen Exp $ // $Id: IconBar.cc,v 1.26 2003/03/03 21:51:01 rathnor Exp $
#include "IconBar.hh" #include "IconBar.hh"
#include "i18n.hh" #include "i18n.hh"
@ -120,9 +120,9 @@ Window IconBar::delIcon(FluxboxWindow *fluxboxwin) {
IconList::iterator it = IconList::iterator it =
std::find(m_iconlist.begin(), m_iconlist.end(), obj); std::find(m_iconlist.begin(), m_iconlist.end(), obj);
if (it != m_iconlist.end()) { if (it != m_iconlist.end()) {
m_iconlist.erase(it); m_iconlist.erase(it);
retwin = obj->getIconWin(); retwin = obj->getIconWin();
delete obj; delete obj;
XDestroyWindow(m_display, retwin); XDestroyWindow(m_display, retwin);
repositionIcons(); repositionIcons();
} }
@ -130,6 +130,25 @@ Window IconBar::delIcon(FluxboxWindow *fluxboxwin) {
return retwin; return retwin;
} }
/**
* Removes all icons from list
* Return X Windows of the removed iconobjs
*/
IconBar::WindowList *IconBar::delAllIcons() {
Window retwin = None;
WindowList *ret = new WindowList();
while (!m_iconlist.empty()) {
IconBarObj *obj = m_iconlist.back();
m_iconlist.pop_back();
retwin = obj->getIconWin();
ret->push_back(retwin);
delete obj;
XDestroyWindow(m_display, retwin);
}
repositionIcons();
return ret;
}
/** /**
renders theme to m_focus_pm renders theme to m_focus_pm
with the size width * height with the size width * height

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: IconBar.hh,v 1.10 2003/02/23 00:50:53 fluxgen Exp $ // $Id: IconBar.hh,v 1.11 2003/03/03 21:51:03 rathnor Exp $
#ifndef ICONBAR_HH #ifndef ICONBAR_HH
#define ICONBAR_HH #define ICONBAR_HH
@ -52,12 +52,14 @@ private:
class IconBar class IconBar
{ {
public: public:
typedef std::list<Window> WindowList;
IconBar(BScreen *scrn, Window parent, FbTk::Font &font); IconBar(BScreen *scrn, Window parent, FbTk::Font &font);
~IconBar(); ~IconBar();
void draw(); //TODO void draw(); //TODO
void reconfigure(); void reconfigure();
Window addIcon(FluxboxWindow *fluxboxwin); Window addIcon(FluxboxWindow *fluxboxwin);
Window delIcon(FluxboxWindow *fluxboxwin); Window delIcon(FluxboxWindow *fluxboxwin);
WindowList *delAllIcons();
void buttonPressEvent(XButtonEvent *be); void buttonPressEvent(XButtonEvent *be);
FluxboxWindow *findWindow(Window w); FluxboxWindow *findWindow(Window w);
IconBarObj *findIcon(FluxboxWindow * const fluxboxwin); IconBarObj *findIcon(FluxboxWindow * const fluxboxwin);

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Screen.cc,v 1.116 2003/02/23 12:02:30 fluxgen Exp $ // $Id: Screen.cc,v 1.117 2003/03/03 21:51:04 rathnor Exp $
#include "Screen.hh" #include "Screen.hh"
@ -202,6 +202,26 @@ setFromString(const char *strval) {
setDefaultValue(); setDefaultValue();
} }
template<>
void Resource<ToolbarHandler::ToolbarMode>::
setFromString(const char *strval) {
if (strcasecmp(strval, "Off") == 0)
m_value = ToolbarHandler::OFF;
else if (strcasecmp(strval, "None") == 0)
m_value = ToolbarHandler::NONE;
else if (strcasecmp(strval, "Icons") == 0)
m_value = ToolbarHandler::ICONS;
else if (strcasecmp(strval, "WorkspaceIcons") == 0)
m_value = ToolbarHandler::WORKSPACEICONS;
else if (strcasecmp(strval, "Workspace") == 0)
m_value = ToolbarHandler::WORKSPACE;
else if (strcasecmp(strval, "AllWindows") == 0)
m_value = ToolbarHandler::ALLWINDOWS;
else
setDefaultValue();
}
//--------- resource accessors -------------- //--------- resource accessors --------------
template<> template<>
string Resource<Tab::Alignment>:: string Resource<Tab::Alignment>::
@ -260,6 +280,34 @@ getString() {
return string("BottomCenter"); return string("BottomCenter");
} }
template<>
string Resource<ToolbarHandler::ToolbarMode>::
getString() {
switch (m_value) {
case ToolbarHandler::OFF:
return string("Off");
break;
case ToolbarHandler::NONE:
return string("None");
break;
case ToolbarHandler::LASTMODE:
case ToolbarHandler::ICONS:
return string("Icons");
break;
case ToolbarHandler::WORKSPACEICONS:
return string("Workspace");
break;
case ToolbarHandler::WORKSPACE:
return string("Workspace");
break;
case ToolbarHandler::ALLWINDOWS:
return string("AllWindows");
break;
}
// default string
return string("Icons");
}
namespace { namespace {
class AddWorkspaceCmd:public FbTk::Command { class AddWorkspaceCmd:public FbTk::Command {
@ -373,6 +421,7 @@ BScreen::ScreenResource::ScreenResource(ResourceManager &rm,
toolbar_layernum(rm, Fluxbox::instance()->getDesktopLayer(), scrname+".toolbar.layer", altscrname+".Toolbar.Layer"), toolbar_layernum(rm, Fluxbox::instance()->getDesktopLayer(), scrname+".toolbar.layer", altscrname+".Toolbar.Layer"),
tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"), tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"),
tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"), tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"),
toolbar_mode(rm, ToolbarHandler::ICONS, scrname+".toolbar.mode", altscrname+".Toolbar.Mode"),
toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"),
toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement") toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement")
{ {
@ -390,7 +439,8 @@ BScreen::BScreen(ResourceManager &rm,
theme(0), m_windowtheme(scrn), theme(0), m_windowtheme(scrn),
m_menutheme(new FbTk::MenuTheme(scrn)), m_menutheme(new FbTk::MenuTheme(scrn)),
resource(rm, screenname, altscreenname), resource(rm, screenname, altscreenname),
m_root_theme(new RootTheme(*this)) m_root_theme(new RootTheme(*this)),
m_toolbarhandler(0)
{ {
Display *disp = FbTk::App::instance()->display(); Display *disp = FbTk::App::instance()->display();
@ -524,31 +574,11 @@ BScreen::BScreen(ResourceManager &rm,
m_slit.reset(new Slit(*this, *layerManager().getLayer(getSlitLayerNum()))); m_slit.reset(new Slit(*this, *layerManager().getLayer(getSlitLayerNum())));
#endif // SLIT #endif // SLIT
m_toolbar.reset(new Toolbar(*this, *layerManager().getLayer(getToolbarLayerNum()))); m_toolbarhandler = new ToolbarHandler(*this, getToolbarMode());
m_toolbar->setPlacement(*resource.toolbar_placement);
// setup toolbar width menu item
FbTk::MenuItem *toolbar_menuitem = new IntResMenuItem("Toolbar width percent",
resource.toolbar_width_percent,
0, 100); // min/max value
FbTk::RefCount<FbTk::Command> reconfig_toolbar(new FbTk::
SimpleCommand<Toolbar>
(*(m_toolbar.get()), &Toolbar::reconfigure));
FbTk::RefCount<FbTk::Command> save_resources(new FbTk::
SimpleCommand<Fluxbox>
(*Fluxbox::instance(), &Fluxbox::save_rc));
FbTk::MacroCommand *toolbar_menuitem_macro = new FbTk::MacroCommand();
toolbar_menuitem_macro->add(reconfig_toolbar);
toolbar_menuitem_macro->add(save_resources);
FbTk::RefCount<FbTk::Command> reconfig_toolbar_and_save_resource(toolbar_menuitem_macro); if (getToolbar())
getToolbar()->setPlacement(*resource.toolbar_placement);
toolbar_menuitem->setCommand(reconfig_toolbar_and_save_resource);
m_toolbar->menu().insert(toolbar_menuitem, 0);
m_toolbar->menu().insert(new BoolMenuItem("Auto hide", *resource.toolbar_auto_hide, reconfig_toolbar), 0);
setupWorkspacemenu(*this, *workspacemenu); setupWorkspacemenu(*this, *workspacemenu);
m_configmenu.reset(createMenuFromScreen(*this)); m_configmenu.reset(createMenuFromScreen(*this));
@ -556,7 +586,8 @@ BScreen::BScreen(ResourceManager &rm,
workspacemenu->setItemSelected(2, true); workspacemenu->setItemSelected(2, true);
m_toolbar->reconfigure(); if (getToolbar() != 0)
getToolbar()->reconfigure();
initMenu(); // create and initiate rootmenu initMenu(); // create and initiate rootmenu
@ -622,11 +653,13 @@ BScreen::BScreen(ResourceManager &rm,
} }
} }
if (! isSloppyFocus()) { if (! isSloppyFocus() && getToolbar() != 0) {
XSetInputFocus(disp, m_toolbar->getWindowID(), XSetInputFocus(disp, getToolbar()->getWindowID(),
RevertToParent, CurrentTime); RevertToParent, CurrentTime);
} }
// set the toolbarhandler after the windows are setup, so it catches their state properly
XFree(children); XFree(children);
XFlush(disp); XFlush(disp);
} }
@ -668,6 +701,14 @@ BScreen::~BScreen() {
} }
const FbTk::Menu &BScreen::getToolbarModemenu() const {
return m_toolbarhandler->getModeMenu();
}
FbTk::Menu &BScreen::getToolbarModemenu() {
return m_toolbarhandler->getModeMenu();
}
/// TODO /// TODO
unsigned int BScreen::getMaxLeft() const { unsigned int BScreen::getMaxLeft() const {
return 0; return 0;
@ -702,8 +743,8 @@ void BScreen::reconfigure() {
FbTk::ThemeManager::instance().load(filename.c_str()); // new theme engine FbTk::ThemeManager::instance().load(filename.c_str()); // new theme engine
if (m_toolbar.get()) if (getToolbar())
m_toolbar->theme().font().setAntialias(*resource.antialias); getToolbar()->theme().font().setAntialias(*resource.antialias);
theme->reconfigure(*resource.antialias); theme->reconfigure(*resource.antialias);
@ -758,10 +799,11 @@ void BScreen::reconfigure() {
// m_toolbar->setPlacement(*resource.toolbar_placement); // m_toolbar->setPlacement(*resource.toolbar_placement);
m_toolbar->reconfigure(); if (getToolbar() != 0) {
if (m_toolbar->theme().font().isAntialias() != *resource.antialias) getToolbar()->reconfigure();
m_toolbar->theme().font().setAntialias(*resource.antialias); if (getToolbar()->theme().font().isAntialias() != *resource.antialias)
getToolbar()->theme().font().setAntialias(*resource.antialias);
}
#ifdef SLIT #ifdef SLIT
if (m_slit.get()) { if (m_slit.get()) {
m_slit->setPlacement(static_cast<Slit::Placement>(getSlitPlacement())); m_slit->setPlacement(static_cast<Slit::Placement>(getSlitPlacement()));
@ -808,12 +850,9 @@ void BScreen::updateWorkspaceNamesAtom() {
void BScreen::addIcon(FluxboxWindow *w) { void BScreen::addIcon(FluxboxWindow *w) {
if (! w) return; if (! w) return;
w->setWorkspace(-1);
w->setWindowNumber(iconList.size()); w->setWindowNumber(iconList.size());
iconList.push_back(w); iconList.push_back(w);
m_toolbar->addIcon(w);
} }
@ -829,11 +868,9 @@ void BScreen::removeIcon(FluxboxWindow *w) {
iconList.erase(it); iconList.erase(it);
break; break;
} }
} }
} }
m_toolbar->delIcon(w);
Icons::iterator it = iconList.begin(); Icons::iterator it = iconList.begin();
Icons::iterator it_end = iconList.end(); Icons::iterator it_end = iconList.end();
for (int i = 0; it != it_end; ++it, ++i) { for (int i = 0; it != it_end; ++it, ++i) {
@ -873,8 +910,9 @@ int BScreen::addWorkspace() {
workspacemenu->update(); workspacemenu->update();
saveWorkspaces(workspacesList.size()); saveWorkspaces(workspacesList.size());
m_toolbar->reconfigure(); if (getToolbar() != 0)
getToolbar()->reconfigure();
updateNetizenWorkspaceCount(); updateNetizenWorkspaceCount();
@ -901,7 +939,8 @@ int BScreen::removeLastWorkspace() {
workspacesList.pop_back(); workspacesList.pop_back();
delete wkspc; delete wkspc;
m_toolbar->reconfigure(); if (getToolbar() != 0)
getToolbar()->reconfigure();
updateNetizenWorkspaceCount(); updateNetizenWorkspaceCount();
saveWorkspaces(workspacesList.size()); saveWorkspaces(workspacesList.size());
@ -949,7 +988,8 @@ void BScreen::changeWorkspaceID(unsigned int id) {
current_workspace = getWorkspace(id); current_workspace = getWorkspace(id);
workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true); workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true);
m_toolbar->redrawWorkspaceLabel(true); if (getToolbar() != 0)
getToolbar()->redrawWorkspaceLabel(true);
current_workspace->showAll(); current_workspace->showAll();
@ -1309,7 +1349,7 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ig
#endif // DEBUG #endif // DEBUG
} }
if (w->getWorkspaceNumber() == wkspc_id) if (!w->isIconic() && w->getWorkspaceNumber() == wkspc_id)
return; return;
@ -1781,11 +1821,9 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
if (getSlit() != 0) if (getSlit() != 0)
menu.insert("Slit", &getSlit()->menu()); menu.insert("Slit", &getSlit()->menu());
#endif // SLIT #endif // SLIT
menu.insert(i18n->getMessage( menu.insert(i18n->getMessage(
ToolbarSet, ToolbarToolbarTitle, ToolbarSet, ToolbarToolbarTitle,
"Toolbar"), &m_toolbar->menu()); "Toolbar"), &m_toolbarhandler->getToolbarMenu());
menu.insert(new menu.insert(new
BoolMenuItem(i18n->getMessage( BoolMenuItem(i18n->getMessage(
ConfigmenuSet, ConfigmenuImageDithering, ConfigmenuSet, ConfigmenuImageDithering,

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Screen.hh,v 1.72 2003/02/23 00:55:07 fluxgen Exp $ // $Id: Screen.hh,v 1.73 2003/03/03 21:51:06 rathnor Exp $
#ifndef SCREEN_HH #ifndef SCREEN_HH
#define SCREEN_HH #define SCREEN_HH
@ -36,6 +36,7 @@
#include "FbWinFrameTheme.hh" #include "FbWinFrameTheme.hh"
#include "MultLayers.hh" #include "MultLayers.hh"
#include "XLayerItem.hh" #include "XLayerItem.hh"
#include "ToolbarHandler.hh"
#include "fluxbox.hh" #include "fluxbox.hh"
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -78,7 +79,7 @@ public:
int scrn, int number_of_layers); int scrn, int number_of_layers);
~BScreen(); ~BScreen();
inline bool doToolbarAutoHide() const { return *resource.toolbar_auto_hide; } inline bool &doToolbarAutoHide() { return *resource.toolbar_auto_hide; }
inline Toolbar::Placement toolbarPlacement() const { return *resource.toolbar_placement; } inline Toolbar::Placement toolbarPlacement() const { return *resource.toolbar_placement; }
inline bool isSloppyFocus() const { return (*resource.focus_model == Fluxbox::SLOPPYFOCUS); } inline bool isSloppyFocus() const { return (*resource.focus_model == Fluxbox::SLOPPYFOCUS); }
inline bool isSemiSloppyFocus() const { return (*resource.focus_model == Fluxbox::SEMISLOPPYFOCUS); } inline bool isSemiSloppyFocus() const { return (*resource.focus_model == Fluxbox::SEMISLOPPYFOCUS); }
@ -103,6 +104,8 @@ public:
inline FbTk::ImageControl *getImageControl() { return image_control; } inline FbTk::ImageControl *getImageControl() { return image_control; }
const FbTk::Menu * const getRootmenu() const { return m_rootmenu.get(); } const FbTk::Menu * const getRootmenu() const { return m_rootmenu.get(); }
FbTk::Menu * const getRootmenu() { return m_rootmenu.get(); } FbTk::Menu * const getRootmenu() { return m_rootmenu.get(); }
const FbTk::Menu &getToolbarModemenu() const ;
FbTk::Menu &getToolbarModemenu() ;
inline const std::string &getRootCommand() const { return *resource.rootcommand; } inline const std::string &getRootCommand() const { return *resource.rootcommand; }
inline Fluxbox::FocusModel getFocusModel() const { return *resource.focus_model; } inline Fluxbox::FocusModel getFocusModel() const { return *resource.focus_model; }
@ -121,8 +124,11 @@ public:
inline unsigned int getSlitOnHead() const { return resource.slit_on_head; } inline unsigned int getSlitOnHead() const { return resource.slit_on_head; }
inline void saveSlitOnHead(unsigned int h) { resource.slit_on_head = h; } inline void saveSlitOnHead(unsigned int h) { resource.slit_on_head = h; }
inline const Toolbar *getToolbar() const { return m_toolbar.get(); } inline const Toolbar *getToolbar() const { return m_toolbarhandler->getToolbar(); }
inline Toolbar *getToolbar() { return m_toolbar.get(); } inline Toolbar *getToolbar() { return m_toolbarhandler->getToolbar(); }
inline const ToolbarHandler &getToolbarHandler() const { return *m_toolbarhandler; }
inline ToolbarHandler &getToolbarHandler() { return *m_toolbarhandler; }
inline Workspace *getWorkspace(unsigned int w) { return ( w < workspacesList.size() ? workspacesList[w] : 0); } inline Workspace *getWorkspace(unsigned int w) { return ( w < workspacesList.size() ? workspacesList[w] : 0); }
inline Workspace *getCurrentWorkspace() { return current_workspace; } inline Workspace *getCurrentWorkspace() { return current_workspace; }
@ -175,6 +181,9 @@ public:
inline int getToolbarOnHead() { return *resource.toolbar_on_head; } inline int getToolbarOnHead() { return *resource.toolbar_on_head; }
inline int getToolbarWidthPercent() const { return *resource.toolbar_width_percent; } inline int getToolbarWidthPercent() const { return *resource.toolbar_width_percent; }
inline Resource<int> &getToolbarWidthPercentResource() { return resource.toolbar_width_percent; }
inline const Resource<int> &getToolbarWidthPercentResource() const { return resource.toolbar_width_percent; }
inline ToolbarHandler::ToolbarMode getToolbarMode() const { return *resource.toolbar_mode; }
inline int getPlacementPolicy() const { return resource.placement_policy; } inline int getPlacementPolicy() const { return resource.placement_policy; }
inline int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; } inline int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; }
inline int getRowPlacementDirection() const { return resource.row_direction; } inline int getRowPlacementDirection() const { return resource.row_direction; }
@ -191,16 +200,14 @@ public:
inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; } inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; } inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; }
inline void saveFocusModel(Fluxbox::FocusModel model) { resource.focus_model = model; } inline void saveFocusModel(Fluxbox::FocusModel model) { resource.focus_model = model; }
//DEL inline void saveSloppyFocus(bool s) { resource.sloppy_focus = s; }
//DEL inline void saveSemiSloppyFocus(bool s) { resource.semi_sloppy_focus = s; }
//DEL inline void saveAutoRaise(bool a) { resource.auto_raise = a; }
inline void saveWorkspaces(int w) { *resource.workspaces = w; } inline void saveWorkspaces(int w) { *resource.workspaces = w; }
inline void saveToolbarAutoHide(bool r) { *resource.toolbar_auto_hide = r; } inline void saveToolbarAutoHide(bool r) { *resource.toolbar_auto_hide = r; }
inline void saveToolbarWidthPercent(int w) { *resource.toolbar_width_percent = w; } inline void saveToolbarWidthPercent(int w) { *resource.toolbar_width_percent = w; }
inline void saveToolbarMode(ToolbarHandler::ToolbarMode m) { *resource.toolbar_mode = m; }
inline void saveToolbarPlacement(Toolbar::Placement place) { *resource.toolbar_placement = place; } inline void saveToolbarPlacement(Toolbar::Placement place) { *resource.toolbar_placement = place; }
inline void saveToolbarOnHead(int head) { *resource.toolbar_on_head = head; } inline void saveToolbarOnHead(int head) { *resource.toolbar_on_head = head; }
inline void savePlacementPolicy(int p) { resource.placement_policy = p; } inline void savePlacementPolicy(int p) { resource.placement_policy = p; }
inline void saveRowPlacementDirection(int d) { resource.row_direction = d; } inline void saveRowPlacementDirection(int d) { resource.row_direction = d; }
inline void saveColPlacementDirection(int d) { resource.col_direction = d; } inline void saveColPlacementDirection(int d) { resource.col_direction = d; }
@ -358,7 +365,7 @@ private:
#ifdef SLIT #ifdef SLIT
std::auto_ptr<Slit> m_slit; std::auto_ptr<Slit> m_slit;
#endif // SLIT #endif // SLIT
std::auto_ptr<Toolbar> m_toolbar;
Workspace *current_workspace; Workspace *current_workspace;
std::auto_ptr<FbTk::Menu> workspacemenu; std::auto_ptr<FbTk::Menu> workspacemenu;
@ -394,6 +401,7 @@ private:
Resource<Tab::Placement> tab_placement; Resource<Tab::Placement> tab_placement;
Resource<Tab::Alignment> tab_alignment; Resource<Tab::Alignment> tab_alignment;
Resource<ToolbarHandler::ToolbarMode> toolbar_mode;
Resource<int> toolbar_on_head; Resource<int> toolbar_on_head;
Resource<Toolbar::Placement> toolbar_placement; Resource<Toolbar::Placement> toolbar_placement;
bool slit_auto_hide; bool slit_auto_hide;
@ -410,6 +418,7 @@ private:
} resource; } resource;
std::auto_ptr<RootTheme> m_root_theme; std::auto_ptr<RootTheme> m_root_theme;
ToolbarHandler *m_toolbarhandler;
}; };

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Toolbar.cc,v 1.64 2003/02/23 19:13:22 fluxgen Exp $ // $Id: Toolbar.cc,v 1.65 2003/03/03 21:51:07 rathnor Exp $
#include "Toolbar.hh" #include "Toolbar.hh"
@ -84,6 +84,7 @@ private:
Toolbar::Placement m_place; Toolbar::Placement m_place;
}; };
void setupMenus(Toolbar &tbar) { void setupMenus(Toolbar &tbar) {
I18n *i18n = I18n::instance(); I18n *i18n = I18n::instance();
using namespace FBNLS; using namespace FBNLS;
@ -213,7 +214,7 @@ Toolbar::Frame::~Frame() {
evm.remove(clock); evm.remove(clock);
} }
Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t width):
editing(false), editing(false),
hidden(scrn.doToolbarAutoHide()), hidden(scrn.doToolbarAutoHide()),
do_auto_hide(scrn.doToolbarAutoHide()), do_auto_hide(scrn.doToolbarAutoHide()),
@ -222,8 +223,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width):
image_ctrl(*scrn.getImageControl()), image_ctrl(*scrn.getImageControl()),
clock_timer(this), // get the clock updating every minute clock_timer(this), // get the clock updating every minute
hide_timer(&hide_handler), hide_timer(&hide_handler),
m_toolbarmenu(*scrn.menuTheme(), m_toolbarmenu(menu),
scrn.getScreenNumber(), *scrn.getImageControl()),
m_placementmenu(*scrn.menuTheme(), m_placementmenu(*scrn.menuTheme(),
scrn.getScreenNumber(), *scrn.getImageControl()), scrn.getScreenNumber(), *scrn.getImageControl()),
m_layermenu(*scrn.menuTheme(), m_layermenu(*scrn.menuTheme(),
@ -267,9 +267,9 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width):
frame.base = frame.label = frame.wlabel = frame.clk = frame.button = frame.base = frame.label = frame.wlabel = frame.clk = frame.button =
frame.pbutton = None; frame.pbutton = None;
//DEL/fix -> remove useIconBar resource
if (Fluxbox::instance()->useIconBar()) // if (Fluxbox::instance()->useIconBar())
m_iconbar.reset(new IconBar(&screen(), frame.window_label.window(), m_theme.font())); m_iconbar.reset(new IconBar(&screen(), frame.window_label.window(), m_theme.font()));
XMapSubwindows(display, frame.window.window()); XMapSubwindows(display, frame.window.window());
@ -325,7 +325,43 @@ void Toolbar::delIcon(FluxboxWindow *w) {
if (m_iconbar.get() != 0) if (m_iconbar.get() != 0)
FbTk::EventManager::instance()->remove(m_iconbar->delIcon(w)); FbTk::EventManager::instance()->remove(m_iconbar->delIcon(w));
} }
void Toolbar::delAllIcons() {
if (m_iconbar.get() == 0)
return;
IconBar::WindowList *deleted = m_iconbar->delAllIcons();
IconBar::WindowList::iterator it = deleted->begin();
IconBar::WindowList::iterator it_end = deleted->end();
for (; it != it_end; ++it) {
FbTk::EventManager::instance()->remove(*it);
}
delete deleted;
}
bool Toolbar::containsIcon(FluxboxWindow &win) {
return (m_iconbar->findIcon(&win) != 0);
}
void Toolbar::enableIconBar() {
// already on
if (m_iconbar.get() != 0)
return;
m_iconbar.reset(new IconBar(&screen(), frame.window_label.window(), m_theme.font()));
}
void Toolbar::disableIconBar() {
// already off
if (m_iconbar.get() == 0)
return;
delAllIcons();
m_iconbar.reset(0); // destroy iconbar
}
void Toolbar::reconfigure() { void Toolbar::reconfigure() {
if (do_auto_hide == false && if (do_auto_hide == false &&
@ -592,29 +628,6 @@ void Toolbar::reconfigure() {
m_toolbarmenu.reconfigure(); m_toolbarmenu.reconfigure();
if (Fluxbox::instance()->useIconBar()) {
if (m_iconbar.get() == 0) { // create new iconbar if we don't have one
m_iconbar.reset(new IconBar(&screen(), frame.window_label.window(), m_theme.font()));
if (screen().getIconCount()) {
BScreen::Icons & l = screen().getIconList();
BScreen::Icons::iterator it = l.begin();
BScreen::Icons::iterator it_end = l.end();
for(; it != it_end; ++it) {
addIcon(*it);
}
}
} else
m_iconbar->reconfigure();
} else if (m_iconbar.get() != 0) {
BScreen::Icons & l = screen().getIconList();
BScreen::Icons::iterator it = l.begin();
BScreen::Icons::iterator it_end = l.end();
for(; it != it_end; ++it)
delIcon(*it);
m_iconbar.reset(0); // destroy iconbar
}
} }

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Toolbar.hh,v 1.25 2003/02/23 00:50:02 fluxgen Exp $ // $Id: Toolbar.hh,v 1.26 2003/03/03 21:51:08 rathnor Exp $
#ifndef TOOLBAR_HH #ifndef TOOLBAR_HH
#define TOOLBAR_HH #define TOOLBAR_HH
@ -63,7 +63,7 @@ public:
}; };
/// create a toolbar on the screen with specific width /// create a toolbar on the screen with specific width
explicit Toolbar(BScreen &screen, FbTk::XLayer &layer, size_t width = 200); explicit Toolbar(BScreen &screen, FbTk::XLayer &layer, FbTk::Menu &menu, size_t width = 200);
/// destructor /// destructor
virtual ~Toolbar(); virtual ~Toolbar();
@ -71,7 +71,13 @@ public:
void addIcon(FluxboxWindow *w); void addIcon(FluxboxWindow *w);
/// remove icon from iconbar /// remove icon from iconbar
void delIcon(FluxboxWindow *w); void delIcon(FluxboxWindow *w);
/// remove all icons
void delAllIcons();
bool containsIcon(FluxboxWindow &win);
void enableIconBar();
void disableIconBar();
inline const FbTk::Menu &menu() const { return m_toolbarmenu; } inline const FbTk::Menu &menu() const { return m_toolbarmenu; }
inline FbTk::Menu &menu() { return m_toolbarmenu; } inline FbTk::Menu &menu() { return m_toolbarmenu; }
inline FbTk::Menu &placementMenu() { return m_placementmenu; } inline FbTk::Menu &placementMenu() { return m_placementmenu; }
@ -160,7 +166,7 @@ private:
FbTk::ImageControl &image_ctrl; FbTk::ImageControl &image_ctrl;
FbTk::Timer clock_timer; ///< timer to update clock FbTk::Timer clock_timer; ///< timer to update clock
FbTk::Timer hide_timer; ///< timer to for auto hide toolbar FbTk::Timer hide_timer; ///< timer to for auto hide toolbar
FbTk::Menu m_toolbarmenu; FbTk::Menu &m_toolbarmenu;
FbTk::Menu m_placementmenu; FbTk::Menu m_placementmenu;
LayerMenu<Toolbar> m_layermenu; LayerMenu<Toolbar> m_layermenu;
std::auto_ptr<IconBar> m_iconbar; std::auto_ptr<IconBar> m_iconbar;

295
src/ToolbarHandler.cc Normal file
View file

@ -0,0 +1,295 @@
// ToolbarHandler for fluxbox
// Copyright (c) 2003 Simon Bowden (rathnor at fluxbox.org)
// and Henrik Kinnunen (fluxgen at fluxbox.org)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// 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
// 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.
// $Id: ToolbarHandler.cc,v 1.1 2003/03/03 21:51:09 rathnor Exp $
/**
* The ToolbarHandler class acts as a rough interface to the toolbar.
* It deals with whether it should be there or not, so anything that
* always needs to be accessible must come through the handler.
*/
#include "ToolbarHandler.hh"
#include "Window.hh"
#include "Screen.hh"
#include "Workspace.hh"
#include "MenuItem.hh"
#include "Menu.hh"
#include "FbCommands.hh"
#include "RefCount.hh"
#include "SimpleCommand.hh"
#include "MacroCommand.hh"
#include "IntResMenuItem.hh"
#include "BoolMenuItem.hh"
namespace {
class ToolbarModeMenuItem : public FbTk::MenuItem {
public:
ToolbarModeMenuItem(const char *label, ToolbarHandler &handler, ToolbarHandler::ToolbarMode mode, FbTk::RefCount<FbTk::Command> &cmd):
FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) {
}
bool isEnabled() const { return m_handler.getMode() != m_mode; }
void click(int button, int time) {
m_handler.setMode(m_mode);
FbTk::MenuItem::click(button, time);
}
private:
ToolbarHandler &m_handler;
ToolbarHandler::ToolbarMode m_mode;
};
void setupModeMenu(FbTk::Menu &menu, ToolbarHandler &handler) {
//I18n *i18n = I18n::instance();
//using namespace FBNLS;
using namespace FbTk;
RefCount<Command> saverc_cmd(new SimpleCommand<Fluxbox>(
*Fluxbox::instance(),
&Fluxbox::save_rc));
//TODO: nls
menu.insert(new ToolbarModeMenuItem("Off", handler,
ToolbarHandler::OFF, saverc_cmd));
menu.insert(new ToolbarModeMenuItem("None", handler,
ToolbarHandler::NONE, saverc_cmd));
menu.insert(new ToolbarModeMenuItem("Icons", handler,
ToolbarHandler::ICONS, saverc_cmd));
menu.insert(new ToolbarModeMenuItem("Workspace Icons", handler,
ToolbarHandler::WORKSPACEICONS, saverc_cmd));
menu.insert(new ToolbarModeMenuItem("Workspace", handler,
ToolbarHandler::WORKSPACE, saverc_cmd));
menu.insert(new ToolbarModeMenuItem("All Windows", handler,
ToolbarHandler::ALLWINDOWS, saverc_cmd));
menu.update();
}
}; // end anonymous namespace
ToolbarHandler::ToolbarHandler(BScreen &screen, ToolbarMode mode)
: m_screen(screen), m_mode(mode), m_toolbar(0), m_current_workspace(0),
m_modemenu(*screen.menuTheme(),
screen.getScreenNumber(), *screen.getImageControl()),
m_toolbarmenu(*screen.menuTheme(),
screen.getScreenNumber(), *screen.getImageControl())
{
m_modemenu.setInternalMenu();
setupModeMenu(m_modemenu, *this);
setMode(mode, false); // the atomhandler part will initialise it shortly
}
void ToolbarHandler::setMode(ToolbarMode mode, bool initialise) {
if (mode < 0 || mode >= LASTMODE || (mode == m_mode && initialise)) return;
if (mode == OFF) {
m_toolbarmenu.removeAll();
//TODO: nls
m_toolbarmenu.insert("Mode...", &m_modemenu);
m_toolbar.reset(0);
m_toolbarmenu.update();
return;
} else if (!m_toolbar.get()) {
m_toolbarmenu.removeAll();
m_toolbarmenu.insert("Mode...", &m_modemenu);
m_toolbar.reset(new Toolbar(m_screen,
*m_screen.layerManager().getLayer(m_screen.getToolbarLayerNum()), m_toolbarmenu));
}
if (mode == NONE) {
// disableIconBar will clean up
m_toolbar->disableIconBar();
} else {
// rebuild it
// be sure the iconbar is on
m_toolbar->enableIconBar();
m_toolbar->delAllIcons();
}
// reset Toolbar, and reload it (initForScreen)
m_mode = mode;
if (initialise)
initForScreen(m_screen);
}
void ToolbarHandler::initForScreen(BScreen &screen) {
if (&m_screen != &screen) return;
switch (m_mode) {
case OFF:
break;
case NONE:
break;
case ALLWINDOWS:
{
BScreen::Workspaces::const_iterator workspace_it = m_screen.getWorkspacesList().begin();
BScreen::Workspaces::const_iterator workspace_it_end = m_screen.getWorkspacesList().end();
for (; workspace_it != workspace_it_end; ++workspace_it) {
Workspace::Windows &wins = (*workspace_it)->getWindowList();
Workspace::Windows::iterator wit = wins.begin();
Workspace::Windows::iterator wit_end = wins.end();
for (; wit != wit_end; ++wit) {
m_toolbar->addIcon(*wit);
}
}
}
// fall through and add icons
case LASTMODE:
case ICONS:
{
BScreen::Icons &iconlist = m_screen.getIconList();
BScreen::Icons::iterator iconit = iconlist.begin();
BScreen::Icons::iterator iconit_end = iconlist.end();
for(; iconit != iconit_end; ++iconit) {
m_toolbar->addIcon(*iconit);
}
}
break;
case WORKSPACE:
{
Workspace::Windows &wins = m_screen.getCurrentWorkspace()->getWindowList();
Workspace::Windows::iterator wit = wins.begin();
Workspace::Windows::iterator wit_end = wins.end();
for (; wit != wit_end; ++wit) {
m_toolbar->addIcon(*wit);
}
}
// fall through and add icons for this workspace
case WORKSPACEICONS:
{
m_current_workspace = m_screen.getCurrentWorkspaceID();
BScreen::Icons &wiconlist = m_screen.getIconList();
BScreen::Icons::iterator iconit = wiconlist.begin();
BScreen::Icons::iterator iconit_end = wiconlist.end();
for(; iconit != iconit_end; ++iconit) {
if ((*iconit)->getWorkspaceNumber() == m_current_workspace)
m_toolbar->addIcon(*iconit);
}
}
break;
}
}
void ToolbarHandler::setupWindow(FluxboxWindow &win) {
if (win.getScreen() != &m_screen) return;
switch (m_mode) {
case OFF:
case NONE:
break;
case WORKSPACE:
if (win.getWorkspaceNumber() == m_current_workspace)
m_toolbar->addIcon(&win);
break;
case WORKSPACEICONS:
if (win.getWorkspaceNumber() != m_current_workspace)
break;
// else fall through and add the icon
case LASTMODE:
case ICONS:
if (win.isIconic()) {
m_toolbar->addIcon(&win);
}
break;
case ALLWINDOWS:
m_toolbar->addIcon(&win);
break;
}
}
void ToolbarHandler::updateWindowClose(FluxboxWindow &win) {
if (win.getScreen() != &m_screen) return;
// check status of window (in current workspace, etc) and remove if necessary
switch (m_mode) {
case OFF:
case NONE:
break;
case WORKSPACEICONS:
if (win.getWorkspaceNumber() != m_current_workspace)
break;
// else fall through and remove the icon
case LASTMODE:
case ICONS:
if (win.isIconic()) {
m_toolbar->delIcon(&win);
}
break;
case WORKSPACE:
if (win.getWorkspaceNumber() == m_current_workspace)
m_toolbar->delIcon(&win);
break;
case ALLWINDOWS:
m_toolbar->delIcon(&win);
break;
}
}
void ToolbarHandler::updateState(FluxboxWindow &win) {
if (win.getScreen() != &m_screen) return;
// this function only relevant for icons
switch (m_mode) {
case OFF:
case NONE:
case ALLWINDOWS:
break;
case WORKSPACE:
case WORKSPACEICONS:
if (win.getWorkspaceNumber() != m_current_workspace) break;
// else fall through and do the same as icons (knowing it is the right ws)
case LASTMODE:
case ICONS:
// if the window is iconic (it mustn't have been before), then add it
// else remove it
if (win.isIconic()) {
if (!m_toolbar->containsIcon(win)) {
m_toolbar->addIcon(&win);
}
} else {
m_toolbar->delIcon(&win);
}
break;
}
}
void ToolbarHandler::updateWorkspace(FluxboxWindow &win) {
if (win.getScreen() != &m_screen) return;
// don't care about current workspace except if in workspace mode
if (m_mode != WORKSPACE) return;
if (win.getWorkspaceNumber() == m_current_workspace) {
m_toolbar->addIcon(&win);
} else {
// relies on the fact that this runs but does nothing if window isn't contained.
m_toolbar->delIcon(&win);
}
}
void ToolbarHandler::updateCurrentWorkspace(BScreen &screen) {
if (&screen != &m_screen) return;
// if only displaying current workspace, update list
// otherwise ignore it
if (m_mode != WORKSPACE && m_mode != WORKSPACEICONS) return;
m_toolbar->delAllIcons();
initForScreen(m_screen);
}

93
src/ToolbarHandler.hh Normal file
View file

@ -0,0 +1,93 @@
// ToolbarHandler for fluxbox
// Copyright (c) 2003 Simon Bowden (rathnor at fluxbox.org)
// and Henrik Kinnunen (fluxgen at fluxbox.org)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// 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
// 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.
// $Id: ToolbarHandler.hh,v 1.1 2003/03/03 21:51:09 rathnor Exp $
#ifndef TOOLBARHANDLER_HH
#define TOOLBARHANDLER_HH
#include "AtomHandler.hh"
#include "Menu.hh"
#include "Toolbar.hh"
class FluxboxWindow;
class BScreen;
class ToolbarHandler : public AtomHandler {
public:
enum ToolbarMode {
OFF=0,
NONE,
ICONS,
WORKSPACEICONS,
WORKSPACE,
ALLWINDOWS,
LASTMODE
};
ToolbarHandler(BScreen &screen, ToolbarMode mode);
~ToolbarHandler() { }
void setMode(ToolbarMode mode, bool initialise = true);
ToolbarMode getMode() { return m_mode; };
inline const Toolbar *getToolbar() const { return m_toolbar.get(); }
inline Toolbar *getToolbar() { return m_toolbar.get(); }
void initForScreen(BScreen &screen);
void setupWindow(FluxboxWindow &win);
void updateState(FluxboxWindow &win);
void updateWindowClose(FluxboxWindow &win);
void updateWorkspace(FluxboxWindow &win);
void updateCurrentWorkspace(BScreen &screen);
// these ones don't affect us
void updateWorkspaceNames(BScreen &screen) {}
void updateWorkspaceCount(BScreen &screen) {}
void updateClientList(BScreen &screen) {}
void updateHints(FluxboxWindow &win) {}
void updateLayer(FluxboxWindow &win) {}
bool checkClientMessage(const XClientMessageEvent &ce,
BScreen * screen, FluxboxWindow * const win) { return false; }
inline FbTk::Menu &getModeMenu() { return m_modemenu; }
inline const FbTk::Menu &getModeMenu() const { return m_modemenu; }
inline FbTk::Menu &getToolbarMenu() { return m_toolbarmenu; }
inline const FbTk::Menu &getToolbarMenu() const { return m_toolbarmenu; }
inline BScreen &screen() { return m_screen; }
inline const BScreen &screen() const { return m_screen; }
private:
BScreen &m_screen;
ToolbarMode m_mode;
std::auto_ptr<Toolbar> m_toolbar;
unsigned int m_current_workspace;
FbTk::Menu m_modemenu;
FbTk::Menu m_toolbarmenu;
};
#endif // TOOLBARHANDLER_HH

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Window.cc,v 1.127 2003/02/23 13:58:36 rathnor Exp $ // $Id: Window.cc,v 1.128 2003/03/03 21:51:09 rathnor Exp $
#include "Window.hh" #include "Window.hh"
@ -377,7 +377,7 @@ FluxboxWindow::~FluxboxWindow() {
Workspace *workspace = screen->getWorkspace(workspace_number); Workspace *workspace = screen->getWorkspace(workspace_number);
if (workspace) if (workspace)
workspace->removeWindow(this); workspace->removeWindow(this);
} else //it's iconic } else
screen->removeIcon(this); screen->removeIcon(this);
if (tab != 0) { if (tab != 0) {
@ -1015,25 +1015,25 @@ void FluxboxWindow::iconify() {
m_windowmenu.hide(); m_windowmenu.hide();
setState(IconicState);
XSelectInput(display, client.window, NoEventMask); XSelectInput(display, client.window, NoEventMask);
XUnmapWindow(display, client.window); XUnmapWindow(display, client.window);
XSelectInput(display, client.window, XSelectInput(display, client.window,
PropertyChangeMask | StructureNotifyMask | FocusChangeMask); PropertyChangeMask | StructureNotifyMask | FocusChangeMask);
m_frame.hide();
visible = false; visible = false;
iconic = true; iconic = true;
setState(IconicState);
m_frame.hide();
screen->getWorkspace(workspace_number)->removeWindow(this); screen->getWorkspace(workspace_number)->removeWindow(this);
if (client.transient_for) { if (client.transient_for) {
if (! client.transient_for->iconic) if (! client.transient_for->iconic)
client.transient_for->iconify(); client.transient_for->iconify();
} }
screen->addIcon(this); screen->addIcon(this);
if (tab) //if this window got a tab then iconify it too if (tab) //if this window got a tab then iconify it too
@ -1057,6 +1057,10 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
} else if (workspace_number != screen->getCurrentWorkspace()->workspaceID()) } else if (workspace_number != screen->getCurrentWorkspace()->workspaceID())
return; return;
bool was_iconic = iconic;
iconic = false;
visible = true;
setState(NormalState); setState(NormalState);
XSelectInput(display, client.window, NoEventMask); XSelectInput(display, client.window, NoEventMask);
@ -1066,14 +1070,12 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
m_frame.show(); m_frame.show();
if (iconic && screen->doFocusNew()) if (was_iconic && screen->doFocusNew())
setInputFocus(); setInputFocus();
if (focused != m_frame.focused()) if (focused != m_frame.focused())
m_frame.setFocus(focused); m_frame.setFocus(focused);
visible = true;
iconic = false;
if (reassoc && client.transients.size()) { if (reassoc && client.transients.size()) {
// deiconify all transients // deiconify all transients

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: fluxbox.cc,v 1.102 2003/03/01 07:30:42 fluxgen Exp $ // $Id: fluxbox.cc,v 1.103 2003/03/03 21:51:11 rathnor Exp $
#include "fluxbox.hh" #include "fluxbox.hh"
@ -447,7 +447,9 @@ Fluxbox::Fluxbox(int m_argc, char **m_argv, const char *dpy_name, const char *rc
continue; continue;
} }
screenList.push_back(screen); screenList.push_back(screen);
m_atomhandler.push_back(&screen->getToolbarHandler());
// attach screen signals to this // attach screen signals to this
screen->currentWorkspaceSig().attach(this); screen->currentWorkspaceSig().attach(this);
screen->workspaceCountSig().attach(this); screen->workspaceCountSig().attach(this);
@ -1449,7 +1451,7 @@ void Fluxbox::handleSignal(int signum) {
void Fluxbox::update(FbTk::Subject *changedsub) { void Fluxbox::update(FbTk::Subject *changedsub) {
//TODO: fix signaling, this does not look good //TODO: fix signaling, this does not look good
if (typeid(*changedsub) == typeid(FluxboxWindow)) { if (typeid(*changedsub) == typeid(FluxboxWindow::WinSubject)) {
FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub); FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub);
FluxboxWindow &win = winsub->win(); FluxboxWindow &win = winsub->win();
if ((&(win.hintSig())) == changedsub) { // hint signal if ((&(win.hintSig())) == changedsub) { // hint signal
@ -1476,6 +1478,14 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
if (m_atomhandler[i]->update()) if (m_atomhandler[i]->update())
m_atomhandler[i]->updateLayer(win); m_atomhandler[i]->updateLayer(win);
} }
} else if ((&(win.dieSig())) == changedsub) { // window death signal
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW die signal from "<<&win<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateWindowClose(win);
}
} else if ((&(win.workspaceSig())) == changedsub) { // workspace signal } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal
#ifdef DEBUG #ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW workspace signal from "<<&win<<endl; cerr<<__FILE__<<"("<<__LINE__<<") WINDOW workspace signal from "<<&win<<endl;
@ -1534,6 +1544,7 @@ void Fluxbox::attachSignals(FluxboxWindow &win) {
win.stateSig().attach(this); win.stateSig().attach(this);
win.workspaceSig().attach(this); win.workspaceSig().attach(this);
win.layerSig().attach(this); win.layerSig().attach(this);
win.dieSig().attach(this);
for (size_t i=0; i<m_atomhandler.size(); ++i) { for (size_t i=0; i<m_atomhandler.size(); ++i) {
m_atomhandler[i]->setupWindow(win); m_atomhandler[i]->setupWindow(win);
} }
@ -2073,7 +2084,7 @@ void Fluxbox::load_rc(BScreen *screen) {
if (screen->getToolbarWidthPercent() <= 0 || if (screen->getToolbarWidthPercent() <= 0 ||
screen->getToolbarWidthPercent() > 100) screen->getToolbarWidthPercent() > 100)
screen->saveToolbarWidthPercent(66); screen->saveToolbarWidthPercent(66);
if (screen->getTabWidth()>512) if (screen->getTabWidth()>512)
screen->saveTabWidth(512); screen->saveTabWidth(512);
else if (screen->getTabWidth()<0) else if (screen->getTabWidth()<0)