From 9ebfea7944a1455a74cb70781373d83f50ad196c Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 27 Mar 2007 08:43:09 +0000 Subject: lots and lots of code cleanup, plus introduced new ClientMenu class --- ChangeLog | 6 +++ src/CascadePlacement.cc | 2 +- src/CascadePlacement.hh | 2 +- src/ClientMenu.cc | 127 +++++++++++++++++++++++++++++++++++++++++++++ src/ClientMenu.hh | 50 ++++++++++++++++++ src/ColSmartPlacement.cc | 6 +-- src/ColSmartPlacement.hh | 2 +- src/FbTk/Makefile.am | 1 - src/FbTk/Menu.hh | 5 +- src/FbTk/MenuIcon.cc | 96 ---------------------------------- src/FbTk/MenuIcon.hh | 54 ------------------- src/FbTk/MenuItem.cc | 21 +++++--- src/FbTk/MenuItem.hh | 3 ++ src/Focusable.hh | 16 +++--- src/IconButton.cc | 11 ++-- src/IconMenu.cc | 66 ----------------------- src/IconMenu.hh | 38 -------------- src/IconMenuItem.hh | 44 ---------------- src/Makefile.am | 3 +- src/MenuCreator.cc | 7 ++- src/PlacementStrategy.hh | 4 +- src/RowSmartPlacement.cc | 6 +-- src/RowSmartPlacement.hh | 2 +- src/Screen.cc | 6 ++- src/Screen.hh | 5 +- src/ScreenPlacement.cc | 2 +- src/ScreenPlacement.hh | 2 +- src/UnderMousePlacement.cc | 2 +- src/UnderMousePlacement.hh | 2 +- src/WinButton.cc | 8 +-- src/WinClient.cc | 18 +++++-- src/WinClient.hh | 3 +- src/Window.cc | 20 +++---- src/Window.hh | 4 +- src/Workspace.cc | 118 +++-------------------------------------- src/Workspace.hh | 19 +++---- 36 files changed, 281 insertions(+), 500 deletions(-) create mode 100644 src/ClientMenu.cc create mode 100644 src/ClientMenu.hh delete mode 100644 src/FbTk/MenuIcon.cc delete mode 100644 src/FbTk/MenuIcon.hh delete mode 100644 src/IconMenu.cc delete mode 100644 src/IconMenu.hh delete mode 100644 src/IconMenuItem.hh diff --git a/ChangeLog b/ChangeLog index 1c52fda..603f3bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ (Format: Year/Month/Day) Changes for 1.1: +*07/03/27: + * Added new resource session.screen.clientMenu.usePixmap that puts the + window's icon in the workspace and icons menus: default true. (Mark) + - For some reason, it doesn't work with shaped icons yet, but I've spent + way too many hours already trying to figure out why + * Use IconTitle in iconbar for minimized windows (Mark) *07/03/25: * Added new resource session.screen.tabs.usePixmap that puts the window's icon in the tab, if available. This is on by default. (Mark) diff --git a/src/CascadePlacement.cc b/src/CascadePlacement.cc index e2993d2..3d4eeef 100644 --- a/src/CascadePlacement.cc +++ b/src/CascadePlacement.cc @@ -42,7 +42,7 @@ CascadePlacement::~CascadePlacement() { delete [] m_cascade_y; } -bool CascadePlacement::placeWindow(const std::vector &windowlist, +bool CascadePlacement::placeWindow(const std::list &windowlist, const FluxboxWindow &win, int &place_x, int &place_y) { diff --git a/src/CascadePlacement.hh b/src/CascadePlacement.hh index 6fde194..8fa39a0 100644 --- a/src/CascadePlacement.hh +++ b/src/CascadePlacement.hh @@ -34,7 +34,7 @@ class CascadePlacement: public PlacementStrategy, public: explicit CascadePlacement(const BScreen &screen); ~CascadePlacement(); - bool placeWindow(const std::vector &windowlist, + bool placeWindow(const std::list &windowlist, const FluxboxWindow &window, int &place_x, int &place_y); private: diff --git a/src/ClientMenu.cc b/src/ClientMenu.cc new file mode 100644 index 0000000..08acd40 --- /dev/null +++ b/src/ClientMenu.cc @@ -0,0 +1,127 @@ +// ClientMenu.hh +// Copyright (c) 2007 Fluxbox Team (fluxgen at fluxbox dot 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$ + +#include "ClientMenu.hh" + +#include "Layer.hh" +#include "Screen.hh" +#include "Window.hh" +#include "WindowCmd.hh" + +#include "FbTk/MenuItem.hh" + +namespace { // anonymous + +class ClientMenuItem: public FbTk::MenuItem { +public: + ClientMenuItem(Focusable &client, ClientMenu &menu): + FbTk::MenuItem(client.title().c_str(), menu), + m_client(client) { client.titleSig().attach(&menu); } + ~ClientMenuItem() { m_client.titleSig().detach(menu()); } + + void click(int button, int time) { + if (m_client.fbwindow() == 0) + return; + FluxboxWindow &win = *m_client.fbwindow(); + + if (win.screen().currentWorkspaceID() != win.workspaceNumber() && + !win.isStuck()) { + win.menu().hide(); + BScreen::FollowModel model = win.screen().getUserFollowModel(); + if (model == BScreen::IGNORE_OTHER_WORKSPACES) + return; + // fetch the window to the current workspace + else if ((button == 3) ^ (model == BScreen::FETCH_ACTIVE_WINDOW || + win.isIconic() && model == BScreen::SEMIFOLLOW_ACTIVE_WINDOW)) { + win.screen().sendToWorkspace(win.screen().currentWorkspaceID(), &win, true); + return; + } + // warp to the workspace of the window + win.screen().changeWorkspaceID(win.workspaceNumber()); + } + m_client.focus(); + win.raise(); + } + + const std::string &label() const { return m_client.title(); } + const FbTk::PixmapWithMask *icon() const { + return m_client.screen().clientMenuUsePixmap() ? &m_client.icon() : 0; + } + + bool isSelected() const { + if (m_client.fbwindow() == 0) + return false; + if (m_client.fbwindow()->isFocused() == false) + return false; + return (&(m_client.fbwindow()->winClient()) == &m_client); + } + +private: + Focusable &m_client; +}; + +}; // end anonymous namespace + +ClientMenu::ClientMenu(BScreen &screen, Focusables &clients, + FbTk::Subject *refresh): + FbMenu(screen.menuTheme(), screen.imageControl(), + *screen.layerManager().getLayer(Layer::MENU)), + m_list(clients), + m_refresh_sig(refresh) { + + if (refresh) + refresh->attach(this); + refreshMenu(); + +} + +void ClientMenu::refreshMenu() { + // remove all items and then add them again + removeAll(); + + // for each fluxboxwindow add every client in them to our clientlist + Focusables::iterator win_it = m_list.begin(); + Focusables::iterator win_it_end = m_list.end(); + for (; win_it != win_it_end; ++win_it) { + // add every client in this fluxboxwindow to menu + if (typeid(*win_it) == typeid(FluxboxWindow *)) { + FluxboxWindow *win = static_cast(*win_it); + FluxboxWindow::ClientList::iterator client_it = + win->clientList().begin(); + FluxboxWindow::ClientList::iterator client_it_end = + win->clientList().end(); + for (; client_it != client_it_end; ++client_it) + insert(new ClientMenuItem(**client_it, *this)); + } else + insert(new ClientMenuItem(**win_it, *this)); + } + + updateMenu(); +} + +void ClientMenu::update(FbTk::Subject *subj) { + if (subj == m_refresh_sig) + refreshMenu(); + else + FbTk::Menu::update(subj); +} diff --git a/src/ClientMenu.hh b/src/ClientMenu.hh new file mode 100644 index 0000000..ca01e43 --- /dev/null +++ b/src/ClientMenu.hh @@ -0,0 +1,50 @@ +// ClientMenu.hh +// Copyright (c) 2007 Fluxbox Team (fluxgen at fluxbox dot 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$ + +#ifndef CLIENTMENU_HH +#define CLIENTMENU_HH + +#include + +#include "FbMenu.hh" + +class BScreen; +class FluxboxWindow; + +class ClientMenu: public FbMenu { +public: + + typedef std::list Focusables; + + ClientMenu(BScreen &screen, Focusables &clients, FbTk::Subject *refresh); + +private: + + void refreshMenu(); + void update(FbTk::Subject *subj); + + Focusables &m_list; + FbTk::Subject *m_refresh_sig; +}; + +#endif // CLIENTMENU_HH diff --git a/src/ColSmartPlacement.cc b/src/ColSmartPlacement.cc index cb3fbd9..16c3b81 100644 --- a/src/ColSmartPlacement.cc +++ b/src/ColSmartPlacement.cc @@ -27,7 +27,7 @@ #include "ScreenPlacement.hh" #include "Window.hh" -bool ColSmartPlacement::placeWindow(const std::vector &windowlist, +bool ColSmartPlacement::placeWindow(const std::list &windowlist, const FluxboxWindow &win, int &place_x, int &place_y) { @@ -85,9 +85,9 @@ bool ColSmartPlacement::placeWindow(const std::vector &windowli next_y = test_y + change_y; - std::vector::const_iterator it = + std::list::const_iterator it = windowlist.begin(); - std::vector::const_iterator it_end = + std::list::const_iterator it_end = windowlist.end(); for (; it != it_end && placed; ++it) { int curr_x = (*it)->x() - (*it)->xOffset(); diff --git a/src/ColSmartPlacement.hh b/src/ColSmartPlacement.hh index ad17d3b..f8c85cf 100644 --- a/src/ColSmartPlacement.hh +++ b/src/ColSmartPlacement.hh @@ -28,7 +28,7 @@ class ColSmartPlacement: public PlacementStrategy { public: - bool placeWindow(const std::vector &windowlist, + bool placeWindow(const std::list &windowlist, const FluxboxWindow &win, int &place_x, int &place_y); }; diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index fadc998..d98c8f6 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am @@ -49,7 +49,6 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ GContext.hh GContext.cc \ KeyUtil.hh KeyUtil.cc \ MenuSeparator.hh MenuSeparator.cc \ - MenuIcon.hh MenuIcon.cc \ stringstream.hh \ TypeAhead.hh SearchResult.hh SearchResult.cc ITypeAheadable.hh \ Select2nd.hh \ diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index c77b0c0..7ca4e39 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -49,7 +49,8 @@ class MenuItem; class ImageControl; /// Base class for menus -class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer, protected FbTk::Observer { +class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer, + public FbTk::Observer { public: enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; enum { RIGHT = 1, LEFT }; @@ -192,7 +193,7 @@ protected: virtual void internal_hide(); - void update(FbTk::Subject *); + virtual void update(FbTk::Subject *); private: diff --git a/src/FbTk/MenuIcon.cc b/src/FbTk/MenuIcon.cc deleted file mode 100644 index d64d876..0000000 --- a/src/FbTk/MenuIcon.cc +++ /dev/null @@ -1,96 +0,0 @@ -// MenuIcon.cc for FbTk - Fluxbox ToolKit -// Copyright (c) 2004 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// and Simon Bowden (rathnor at users.sourceforge.net) -// -// 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$ - -#include "MenuIcon.hh" - -#include "MenuTheme.hh" -#include "Image.hh" -#include "App.hh" - -namespace FbTk { - -MenuIcon::MenuIcon(const std::string &filename, FbString &label, int screen_num): - MenuItem(label), - m_filename(filename) { - FbTk::PixmapWithMask *pm = Image::load(filename.c_str(), screen_num); - if (pm != 0) { - m_pixmap = pm->pixmap().release(); - m_mask = pm->mask().release(); - delete pm; - } - -} - -void MenuIcon::updateTheme(const MenuTheme &theme) { - FbTk::PixmapWithMask *pm = Image::load(m_filename.c_str(), theme.screenNum()); - if (pm != 0) { - m_pixmap = pm->pixmap().release(); - m_mask = pm->mask().release(); - delete pm; - } -} - -void MenuIcon::draw(FbDrawable &drawable, - const MenuTheme &theme, - bool highlight, bool draw_foreground, bool draw_background, - int x, int y, - unsigned int width, unsigned int height) const { - - // all background - if (draw_background) { - Display *disp = FbTk::App::instance()->display(); - if (height - 2*theme.bevelWidth() != m_pixmap.height() && - !m_filename.empty()) { - unsigned int scale_size = height - 2*theme.bevelWidth(); - m_pixmap.scale(scale_size, scale_size); - m_mask.scale(scale_size, scale_size); - } - - if (m_pixmap.drawable() != 0) { - GC gc = theme.frameTextGC().gc(); - - // enable clip mask - XSetClipMask(disp, gc, m_mask.drawable()); - XSetClipOrigin(disp, gc, x + theme.bevelWidth(), y + theme.bevelWidth()); - - drawable.copyArea(m_pixmap.drawable(), - gc, - 0, 0, - x + theme.bevelWidth(), y + theme.bevelWidth(), - m_pixmap.width(), m_pixmap.height()); - - // restore clip mask - XSetClipMask(disp, gc, None); - } - } - FbTk::MenuItem::draw(drawable, theme, highlight, - draw_background, draw_foreground, x, y, width, height); -} - -unsigned int MenuIcon::width(const MenuTheme &theme) const { - return MenuItem::width(theme) + 2 * (theme.bevelWidth() + height(theme)); -} - -} // end namespace FbTk - diff --git a/src/FbTk/MenuIcon.hh b/src/FbTk/MenuIcon.hh deleted file mode 100644 index 90cf320..0000000 --- a/src/FbTk/MenuIcon.hh +++ /dev/null @@ -1,54 +0,0 @@ -// MenuIcon.hh for FbTk - Fluxbox ToolKit -// Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot org) -// and Simon Bowden (rathnor at users.sourceforge.net) -// -// 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$ - -#ifndef MENUICON_HH -#define MENUICON_HH - -#include "MenuItem.hh" -#include "FbPixmap.hh" - -#include - -namespace FbTk { - -class MenuIcon: public MenuItem { -public: - MenuIcon(const std::string &filename, FbString &label, int screen_num); - void draw(FbDrawable &drawable, - const MenuTheme &theme, - bool highlight, - bool draw_foreground, bool draw_background, - int x, int y, - unsigned int width, unsigned int height) const; - unsigned int width(const MenuTheme &item) const; - void updateTheme(const MenuTheme &theme); -private: - mutable FbPixmap m_pixmap, m_mask; - const std::string m_filename; -}; - -} // end namespace FbTk - -#endif // MENUICON_HH - diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index 82dd155..b598c47 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc @@ -90,27 +90,32 @@ void MenuItem::draw(FbDrawable &draw, // Icon // if (draw_background) { - if (m_icon.get() != 0 && m_icon->pixmap.get() != 0) { + if (icon() != 0) { + // copy pixmap, so we don't resize the original + FbPixmap tmp_pixmap, tmp_mask; + tmp_pixmap.copy(icon()->pixmap()); + tmp_mask.copy(icon()->mask()); + // scale pixmap to right size - if (height - 2*theme.bevelWidth() != m_icon->pixmap->height() && - !m_icon->filename.empty()) { + if (height - 2*theme.bevelWidth() != tmp_pixmap.height()) { unsigned int scale_size = height - 2*theme.bevelWidth(); - m_icon->pixmap->scale(scale_size, scale_size); + tmp_pixmap.scale(scale_size, scale_size); + tmp_mask.scale(scale_size, scale_size); } - if (m_icon->pixmap->pixmap().drawable() != 0) { + if (tmp_pixmap.drawable() != 0) { GC gc = theme.frameTextGC().gc(); int icon_x = x + theme.bevelWidth(); int icon_y = y + theme.bevelWidth(); // enable clip mask - XSetClipMask(disp, gc, m_icon->pixmap->mask().drawable()); + XSetClipMask(disp, gc, tmp_mask.drawable()); XSetClipOrigin(disp, gc, icon_x, icon_y); - draw.copyArea(m_icon->pixmap->pixmap().drawable(), + draw.copyArea(tmp_pixmap.drawable(), gc, 0, 0, icon_x, icon_y, - m_icon->pixmap->width(), m_icon->pixmap->height()); + tmp_pixmap.width(), tmp_pixmap.height()); // restore clip mask XSetClipMask(disp, gc, None); diff --git a/src/FbTk/MenuItem.hh b/src/FbTk/MenuItem.hh index 701b624..adc6b79 100644 --- a/src/FbTk/MenuItem.hh +++ b/src/FbTk/MenuItem.hh @@ -102,6 +102,9 @@ public: */ //@{ virtual const std::string &label() const { return m_label; } + virtual const PixmapWithMask *icon() const { + return m_icon.get() ? m_icon->pixmap.get() : 0; + } virtual const Menu *submenu() const { return m_submenu; } virtual bool isEnabled() const { return m_enabled; } virtual bool isSelected() const { return m_selected; } diff --git a/src/Focusable.hh b/src/Focusable.hh index e2c7e50..d7c1ae8 100644 --- a/src/Focusable.hh +++ b/src/Focusable.hh @@ -19,10 +19,12 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +// $Id$ + #ifndef FOCUSABLE_HH #define FOCUSABLE_HH -#include "FbTk/FbPixmap.hh" +#include "FbTk/PixmapWithMask.hh" #include "FbTk/ITypeAheadable.hh" #include "FbTk/Subject.hh" @@ -52,14 +54,8 @@ public: inline FluxboxWindow *fbwindow() { return m_fbwin; } // so we can make nice buttons, menu entries, etc. - virtual const FbTk::FbPixmap &iconPixmap() const { return m_icon_pixmap; } - virtual bool usePixmap() const { return iconPixmap().drawable() != None; } - - virtual const FbTk::FbPixmap &iconMask() const { return m_icon_mask; } - virtual bool useMask() const { return iconMask().drawable() != None; } - + virtual const FbTk::PixmapWithMask &icon() const { return m_icon; } virtual const std::string &title() const { return m_title; } - virtual const std::string &iconTitle() const { return m_icon_title; } const std::string &iTypeString() const { return title(); } class FocusSubject: public FbTk::Subject { @@ -80,8 +76,8 @@ protected: FluxboxWindow *m_fbwin; bool m_focused; - std::string m_title, m_icon_title; - FbTk::FbPixmap m_icon_pixmap, m_icon_mask; + std::string m_title; + FbTk::PixmapWithMask m_icon; FocusSubject m_titlesig; }; diff --git a/src/IconButton.cc b/src/IconButton.cc index 8530c83..e3aae47 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -119,7 +119,7 @@ void IconButton::update(FbTk::Subject *subj) { int screen = m_win.screen().screenNumber(); - if (m_use_pixmap && m_win.usePixmap()) { + if (m_use_pixmap && m_win.icon().pixmap().drawable() != None) { // setup icon window m_icon_window.show(); unsigned int w = width(); @@ -138,7 +138,7 @@ void IconButton::update(FbTk::Subject *subj) { m_icon_window.moveResize(iconx, icony, neww, newh); - m_icon_pixmap.copy(m_win.iconPixmap().drawable(), DefaultDepth(display, screen), screen); + m_icon_pixmap.copy(m_win.icon().pixmap().drawable(), DefaultDepth(display, screen), screen); m_icon_pixmap.scale(m_icon_window.width(), m_icon_window.height()); // rotate the icon or not?? lets go not for now, and see what they say... @@ -153,8 +153,8 @@ void IconButton::update(FbTk::Subject *subj) { m_icon_pixmap = 0; } - if(m_use_pixmap && m_win.useMask()) { - m_icon_mask.copy(m_win.iconMask().drawable(), 0, 0); + if(m_icon_pixmap.drawable() && m_win.icon().mask().drawable() != None) { + m_icon_mask.copy(m_win.icon().mask().drawable(), 0, 0); m_icon_mask.scale(m_icon_pixmap.width(), m_icon_pixmap.height()); m_icon_mask.rotate(orientation()); } else @@ -171,9 +171,6 @@ void IconButton::update(FbTk::Subject *subj) { #endif // SHAPE - if (subj == &(m_win.titleSig())) - setText(m_win.title()); - if (subj != 0) { setupWindow(); } else { diff --git a/src/IconMenu.cc b/src/IconMenu.cc deleted file mode 100644 index 33ef05a..0000000 --- a/src/IconMenu.cc +++ /dev/null @@ -1,66 +0,0 @@ -// IconMenu.cc for Fluxbox -// Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot 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$ - -#include "IconMenu.hh" - -#include "Screen.hh" -#include "IconMenuItem.hh" -#include "Layer.hh" -#include "FbTk/I18n.hh" - -#include - -static void updateItems(FbTk::Menu &menu, BScreen &screen) { - menu.removeAll(); - BScreen::Icons::iterator it = screen.iconList().begin(); - BScreen::Icons::iterator it_end = screen.iconList().end(); - for (; it != it_end; ++it) { - FluxboxWindow::ClientList::iterator client_it = (*it)->clientList().begin(); - FluxboxWindow::ClientList::iterator client_it_end = (*it)->clientList().end(); - for (; client_it != client_it_end; ++client_it) - menu.insert(new IconMenuItem(**client_it)); - } - menu.updateMenu(); -} - -IconMenu::IconMenu(BScreen &screen): - FbMenu(screen.menuTheme(), - screen.imageControl(), - *screen.layerManager(). - getLayer(Layer::MENU)) { - - _FB_USES_NLS; - setLabel(_FB_XTEXT(Menu, Icons, "Icons", "Iconic windows menu title")); - screen.iconListSig().attach(this); - updateItems(*this, screen); -} - -void IconMenu::update(FbTk::Subject *subj) { - if (subj == 0) - FbTk::Menu::update(subj); - else if (typeid(*subj) == typeid(BScreen::ScreenSubject)) { - BScreen &screen = static_cast(subj)->screen(); - updateItems(*this, screen); - } else - FbTk::Menu::update(subj); -} diff --git a/src/IconMenu.hh b/src/IconMenu.hh deleted file mode 100644 index 43351d1..0000000 --- a/src/IconMenu.hh +++ /dev/null @@ -1,38 +0,0 @@ -// IconMenu.hh for Fluxbox -// Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot 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$ - -#ifndef ICONMENU_HH -#define ICONMENU_HH - -#include "FbMenu.hh" - -class BScreen; - -class IconMenu: public FbMenu { -public: - explicit IconMenu(BScreen &screen); - virtual ~IconMenu() { } - void update(FbTk::Subject *subj); -}; - -#endif // ICONMENU_HH diff --git a/src/IconMenuItem.hh b/src/IconMenuItem.hh deleted file mode 100644 index b737833..0000000 --- a/src/IconMenuItem.hh +++ /dev/null @@ -1,44 +0,0 @@ -// IconMenuItem.hh for Fluxbox Window Manager -// Copyright (c) 2003 Henrik Kinnunen (fluxgen at fluxbox dot org) -// and Simon Bowden (rathnor at users.sourceforge.net) -// -// 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$ - -#ifndef ICONMENUITEM_HH -#define ICONMENUITEM_HH - -#include "FbTk/MenuItem.hh" -#include "WinClient.hh" -#include "Window.hh" - -class IconMenuItem: public FbTk::MenuItem { -public: - explicit IconMenuItem(WinClient &client):FbTk::MenuItem(client.iconTitle().c_str()), m_client(client) { } - const std::string &label() const { return m_client.iconTitle(); } - void click(int button, int time) { - if (m_client.fbwindow() != 0) - m_client.fbwindow()->deiconify(); - } -private: - WinClient &m_client; -}; - -#endif // ICONMENUITEM_HH diff --git a/src/Makefile.am b/src/Makefile.am index a353b52..b1e6052 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,7 +104,6 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ WinClient.hh WinClient.cc \ Strut.hh \ Xinerama.hh \ - IconMenuItem.hh \ Xutil.hh Xutil.cc \ CurrentWindowCmd.hh CurrentWindowCmd.cc \ WorkspaceCmd.hh WorkspaceCmd.cc \ @@ -122,7 +121,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ StyleMenuItem.hh StyleMenuItem.cc \ RootCmdMenuItem.hh RootCmdMenuItem.cc\ MenuCreator.hh MenuCreator.cc \ - IconMenu.hh IconMenu.cc \ + ClientMenu.hh ClientMenu.cc \ WorkspaceMenu.hh WorkspaceMenu.cc \ FocusModelMenuItem.hh \ ToggleMenu.hh \ diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 5264a4d..e24693e 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -30,8 +30,7 @@ #include "Window.hh" #include "WindowCmd.hh" -#include "FbMenu.hh" -#include "IconMenu.hh" +#include "ClientMenu.hh" #include "WorkspaceMenu.hh" #include "LayerMenu.hh" #include "SendToMenu.hh" @@ -51,7 +50,6 @@ #include "FbTk/StringUtil.hh" #include "FbTk/FileUtil.hh" #include "FbTk/MenuSeparator.hh" -#include "FbTk/MenuIcon.hh" #include "FbTk/Transparent.hh" #include @@ -511,7 +509,8 @@ FbTk::Menu *MenuCreator::createMenuType(const string &type, int screen_num) { if (screen == 0) return 0; if (type == "iconmenu") { - return new IconMenu(*screen); + return new ClientMenu(*screen, screen->iconList(), + &screen->iconListSig()); } else if (type == "workspacemenu") { return new WorkspaceMenu(*screen); } else if (type == "windowmenu") { diff --git a/src/PlacementStrategy.hh b/src/PlacementStrategy.hh index 001218d..e8b0e96 100644 --- a/src/PlacementStrategy.hh +++ b/src/PlacementStrategy.hh @@ -24,7 +24,7 @@ #ifndef PLACEMENTSTRATEGY_HH #define PLACEMENTSTRATEGY_HH -#include +#include class FluxboxWindow; @@ -37,7 +37,7 @@ struct PlacementStrategy { * @param place_y y placement of specific strategy * @return true if the strategy found a placement for the window */ - virtual bool placeWindow(const std::vector &windowlist, + virtual bool placeWindow(const std::list &windowlist, const FluxboxWindow &win, int &place_x, int &place_y) = 0; virtual ~PlacementStrategy() { } diff --git a/src/RowSmartPlacement.cc b/src/RowSmartPlacement.cc index 22ab768..e2a0be4 100644 --- a/src/RowSmartPlacement.cc +++ b/src/RowSmartPlacement.cc @@ -27,7 +27,7 @@ #include "Screen.hh" #include "ScreenPlacement.hh" -bool RowSmartPlacement::placeWindow(const std::vector &windowlist, +bool RowSmartPlacement::placeWindow(const std::list &windowlist, const FluxboxWindow &win, int &place_x, int &place_y) { @@ -95,9 +95,9 @@ bool RowSmartPlacement::placeWindow(const std::vector &windowli next_x = test_x + change_x; - std::vector::const_iterator win_it = + std::list::const_iterator win_it = windowlist.begin(); - std::vector::const_iterator win_it_end = + std::list::const_iterator win_it_end = windowlist.end(); for (; win_it != win_it_end && placed; ++win_it) { diff --git a/src/RowSmartPlacement.hh b/src/RowSmartPlacement.hh index 43dbf55..7b54fc1 100644 --- a/src/RowSmartPlacement.hh +++ b/src/RowSmartPlacement.hh @@ -28,7 +28,7 @@ class RowSmartPlacement: public PlacementStrategy { public: - bool placeWindow(const std::vector &windowlist, + bool placeWindow(const std::list &windowlist, const FluxboxWindow &win, int &place_x, int &place_y); }; diff --git a/src/Screen.cc b/src/Screen.cc index a0bc01d..ba3401e 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -325,6 +325,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, altscrname+".overlay.CapStyle"), scroll_action(rm, "", scrname+".windowScrollAction", altscrname+".WindowScrollAction"), scroll_reverse(rm, false, scrname+".windowScrollReverse", altscrname+".WindowScrollReverse"), + clientmenu_use_pixmap(rm, true, scrname+".clientMenu.usePixmap", altscrname+".ClientMenu.UsePixmap"), tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"), max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"), default_internal_tabs(rm, false /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { @@ -1154,7 +1155,7 @@ void BScreen::removeClient(WinClient &client) { int BScreen::addWorkspace() { bool save_name = getNameOfWorkspace(m_workspaces_list.size()) != "" ? false : true; - Workspace *wkspc = new Workspace(*this, m_layermanager, + Workspace *wkspc = new Workspace(*this, getNameOfWorkspace(m_workspaces_list.size()), m_workspaces_list.size()); m_workspaces_list.push_back(wkspc); @@ -1822,6 +1823,9 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { tab_menu->insert(new BoolMenuItem(_FB_XTEXT(Common, MaximizeOver, "Maximize Over", "Maximize over this thing when maximizing"), *resource.max_over_tabs, save_and_reconfigure)); + tab_menu->insert(new BoolMenuItem(_FB_XTEXT(Toolbar, ShowIcons, + "Show Pictures", "chooses if little icons are shown next to title in the iconbar"), + *resource.tabs_use_pixmap, save_and_reconfigure)); FbTk::MenuItem *tab_width_item = new IntResMenuItem< FbTk::Resource >(_FB_XTEXT(Configmenu, ExternalTabWidth, diff --git a/src/Screen.hh b/src/Screen.hh index 53198fc..b1b5a7a 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -99,7 +99,7 @@ public: DEFAULTRESIZE = BOTTOMRESIZE }; - typedef std::vector Icons; + typedef std::list Icons; typedef std::vector Workspaces; typedef std::vector WorkspaceNames; @@ -146,6 +146,7 @@ public: inline const std::string &getScrollAction() const { return *resource.scroll_action; } inline const bool getScrollReverse() const { return *resource.scroll_reverse; } + inline const bool clientMenuUsePixmap() const { return *resource.clientmenu_use_pixmap; } inline const bool getDefaultInternalTabs() const { return *resource.default_internal_tabs; } inline const bool getTabsUsePixmap() const { return *resource.tabs_use_pixmap; } inline const bool getMaxOverTabs() const { return *resource.max_over_tabs; } @@ -469,10 +470,12 @@ private: FbTk::Resource gc_cap_style; FbTk::Resource scroll_action; FbTk::Resource scroll_reverse; + FbTk::Resource clientmenu_use_pixmap; FbTk::Resource tabs_use_pixmap; FbTk::Resource max_over_tabs; FbTk::Resource default_internal_tabs; + } resource; /// Holds manage resources that screen destroys diff --git a/src/ScreenPlacement.cc b/src/ScreenPlacement.cc index 86c0804..6ba4b6f 100644 --- a/src/ScreenPlacement.cc +++ b/src/ScreenPlacement.cc @@ -52,7 +52,7 @@ ScreenPlacement::ScreenPlacement(BScreen &screen): { } -bool ScreenPlacement::placeWindow(const std::vector &windowlist, +bool ScreenPlacement::placeWindow(const std::list &windowlist, const FluxboxWindow &win, int &place_x, int &place_y) { diff --git a/src/ScreenPlacement.hh b/src/ScreenPlacement.hh index be007eb..4326c91 100644 --- a/src/ScreenPlacement.hh +++ b/src/ScreenPlacement.hh @@ -62,7 +62,7 @@ public: virtual ~ScreenPlacement() {} /// placeWindow is guaranteed to succeed, ignore return value /// @return true - bool placeWindow(const std::vector &windowlist, + bool placeWindow(const std::list &windowlist, const FluxboxWindow &window, int &place_x, int &place_y); diff --git a/src/UnderMousePlacement.cc b/src/UnderMousePlacement.cc index 3af2975..e601e77 100644 --- a/src/UnderMousePlacement.cc +++ b/src/UnderMousePlacement.cc @@ -27,7 +27,7 @@ #include "Screen.hh" #include "Window.hh" -bool UnderMousePlacement::placeWindow(const std::vector &list, +bool UnderMousePlacement::placeWindow(const std::list &list, const FluxboxWindow &win, int &place_x, int &place_y) { diff --git a/src/UnderMousePlacement.hh b/src/UnderMousePlacement.hh index d89133c..7f95e0c 100644 --- a/src/UnderMousePlacement.hh +++ b/src/UnderMousePlacement.hh @@ -28,7 +28,7 @@ class UnderMousePlacement: public PlacementStrategy { public: - bool placeWindow(const std::vector &windowlist, + bool placeWindow(const std::list &windowlist, const FluxboxWindow &win, int &place_x, int &place_y); }; diff --git a/src/WinButton.cc b/src/WinButton.cc index f690f93..cdfb8b5 100644 --- a/src/WinButton.cc +++ b/src/WinButton.cc @@ -321,15 +321,15 @@ void WinButton::update(FbTk::Subject *subj) { Display* display = m_listen_to.fbWindow().display(); int screen = m_listen_to.screen().screenNumber(); - if (m_listen_to.usePixmap()) { - m_icon_pixmap.copy(m_listen_to.iconPixmap().drawable(), + if (m_listen_to.icon().pixmap().drawable() != None) { + m_icon_pixmap.copy(m_listen_to.icon().pixmap().drawable(), DefaultDepth(display, screen), screen); m_icon_pixmap.scale(width() - 4, height() - 4); } else m_icon_pixmap.release(); - if (m_listen_to.useMask()) { - m_icon_mask.copy(m_listen_to.iconMask().drawable(), 0, 0); + if (m_listen_to.icon().mask().drawable() != None) { + m_icon_mask.copy(m_listen_to.icon().mask().drawable(), 0, 0); m_icon_mask.scale(width() - 4, height() - 4); } else m_icon_mask.release(); diff --git a/src/WinClient.cc b/src/WinClient.cc index 4e491f0..3c20912 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -234,6 +234,12 @@ const string &WinClient::getWMClassClass() const { return m_class_name; } +const string &WinClient::title() const { + if (!fbwindow() || !fbwindow()->isIconic()) + return m_title; + return m_icon_title; +} + void WinClient::updateWMClassHint() { XClassHint ch; if (XGetClassHint(display(), window(), &ch) == 0) { @@ -369,6 +375,8 @@ void WinClient::setTitle(FbTk::FbString &title) { void WinClient::setIconTitle(FbTk::FbString &icon_title) { m_icon_title = icon_title; m_icon_title_override = true; + if (fbwindow() && fbwindow()->isIconic()) + fbwindow()->updateTitleFromClient(*this); } void WinClient::updateIconTitle() { @@ -401,6 +409,8 @@ void WinClient::updateIconTitle() { } else m_icon_title = title(); + if (fbwindow() && fbwindow()->isIconic()) + fbwindow()->updateTitleFromClient(*this); } void WinClient::saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs) { @@ -514,14 +524,14 @@ void WinClient::updateWMHints() { window_group = None; if ((bool)(wmhint->flags & IconPixmapHint) && wmhint->icon_pixmap != 0) - m_icon_pixmap.copy(wmhint->icon_pixmap, 0, 0); + m_icon.pixmap().copy(wmhint->icon_pixmap, 0, 0); else - m_icon_pixmap = 0; + m_icon.pixmap().release(); if ((bool)(wmhint->flags & IconMaskHint) && wmhint->icon_mask != 0) - m_icon_mask.copy(wmhint->icon_mask, 0, 0); + m_icon.mask().copy(wmhint->icon_mask, 0, 0); else - m_icon_mask = 0; + m_icon.mask().release(); if (fbwindow()) { if (wmhint->flags & XUrgencyHint) { diff --git a/src/WinClient.hh b/src/WinClient.hh index 671b7d4..dd7da21 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -82,6 +82,7 @@ public: void clearStrut(); bool focus(); // calls Window->setCurrentClient to give focus to this client + const std::string &title() const; /** * Changes width and height to the nearest (lower) value @@ -184,7 +185,7 @@ private: int m_win_gravity; - std::string m_class_name, m_instance_name; + std::string m_class_name, m_instance_name, m_icon_title; bool m_title_override, m_icon_title_override; FluxboxWindow::BlackboxHints *m_blackbox_hint; diff --git a/src/Window.cc b/src/Window.cc index 9790220..41628f2 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -1095,6 +1095,11 @@ void FluxboxWindow::reconfigure() { frame().setOnClickTitlebar(null_cmd, 5); } + Client2ButtonMap::iterator it = m_labelbuttons.begin(), + it_end = m_labelbuttons.end(); + for (; it != it_end; ++it) + it->second->setPixmap(screen().getTabsUsePixmap()); + } /// update current client title and title in our frame @@ -3674,12 +3679,8 @@ bool FluxboxWindow::acceptsFocus() const { return (m_client ? m_client->acceptsFocus() : false); } -const FbTk::FbPixmap &FluxboxWindow::iconPixmap() const { - return (m_client ? m_client->iconPixmap() : m_icon_pixmap); -} - -const FbTk::FbPixmap &FluxboxWindow::iconMask() const { - return (m_client ? m_client->iconMask() : m_icon_mask); +const FbTk::PixmapWithMask &FluxboxWindow::icon() const { + return (m_client ? m_client->icon() : m_icon); } const FbTk::Menu &FluxboxWindow::menu() const { @@ -3704,13 +3705,6 @@ const string &FluxboxWindow::title() const { return m_client->title(); } -const string &FluxboxWindow::iconTitle() const { - static string empty_string; - if (m_client == 0) - return empty_string; - return m_client->iconTitle(); -} - int FluxboxWindow::initialState() const { return m_client->initial_state; } void FluxboxWindow::changeBlackboxHints(const BlackboxHints &net) { diff --git a/src/Window.hh b/src/Window.hh index d04f171..29f2274 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -376,10 +376,8 @@ public: FbTk::FbWindow &parent() { return m_parent; } bool acceptsFocus() const; - const FbTk::FbPixmap &iconPixmap() const; - const FbTk::FbPixmap &iconMask() const; + const FbTk::PixmapWithMask &icon() const; const std::string &title() const; - const std::string &iconTitle() const; inline int x() const { return frame().x(); } inline int y() const { return frame().y(); } diff --git a/src/Workspace.cc b/src/Workspace.cc index 66dd4a6..e65a89f 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -30,13 +30,10 @@ #include "Window.hh" #include "WinClient.hh" #include "FbWinFrame.hh" -#include "WindowCmd.hh" #include "FocusControl.hh" #include "PlacementStrategy.hh" -#include "Layer.hh" #include "FbTk/I18n.hh" -#include "FbTk/MenuItem.hh" #include "FbTk/StringUtil.hh" #include "FbTk/FbString.hh" @@ -65,7 +62,6 @@ #include #include -#include using std::string; using std::vector; @@ -76,83 +72,11 @@ using std::cerr; using std::endl; #endif // DEBUG -namespace { // anonymous - -int countTransients(const WinClient &client) { - if (client.transientList().empty()) - return 0; - // now go throu the entire tree and count transients - size_t ret = client.transientList().size(); - WinClient::TransientList::const_iterator it = client.transientList().begin(); - WinClient::TransientList::const_iterator it_end = client.transientList().end(); - for (; it != it_end; ++it) - ret += countTransients(*(*it)); - - return ret; -} - -class ClientMenuItem:public FbTk::MenuItem { -public: - ClientMenuItem(WinClient &client): - FbTk::MenuItem(client.title().c_str(), &client.screen().windowMenu()), - m_client(client) { - - } - FbTk::Menu *submenu() { return &m_client.screen().windowMenu(); } - const FbTk::Menu *submenu() const { return &m_client.screen().windowMenu(); } - - void showSubmenu() { - WindowCmd::setClient(&m_client); - FbTk::MenuItem::showSubmenu(); - } - - void click(int button, int time) { - if (m_client.fbwindow() == 0) - return; - FluxboxWindow &win = *m_client.fbwindow(); - - if (win.screen().currentWorkspaceID() != win.workspaceNumber() && - !win.isStuck()) { - win.menu().hide(); - BScreen::FollowModel model = win.screen().getUserFollowModel(); - if (model == BScreen::IGNORE_OTHER_WORKSPACES) - return; - // fetch the window to the current workspace - else if ((button == 3) ^ (model == BScreen::FETCH_ACTIVE_WINDOW || - win.isIconic() && model == BScreen::SEMIFOLLOW_ACTIVE_WINDOW)) { - win.screen().sendToWorkspace(win.screen().currentWorkspaceID(), &win, true); - return; - } - // warp to the workspace of the window - win.screen().changeWorkspaceID(win.workspaceNumber()); - } - win.setCurrentClient(m_client); - win.raiseAndFocus(); - } - - const string &label() const { return m_client.title(); } - bool isSelected() const { - if (m_client.fbwindow() == 0) - return false; - if (m_client.fbwindow()->isFocused() == false) - return false; - return (&(m_client.fbwindow()->winClient()) == &m_client); - - } -private: - WinClient &m_client; -}; - -}; - Workspace::GroupList Workspace::m_groups; -Workspace::Workspace(BScreen &scrn, FbTk::MultLayers &layermanager, - const string &name, unsigned int id): +Workspace::Workspace(BScreen &scrn, const string &name, unsigned int id): m_screen(scrn), - m_clientmenu(scrn.menuTheme(), scrn.imageControl(), - *scrn.layerManager().getLayer(Layer::MENU)), - m_layermanager(layermanager), + m_clientmenu(scrn, m_windowlist, &m_clientlist_sig), m_name(name), m_id(id) { @@ -171,14 +95,12 @@ void Workspace::addWindow(FluxboxWindow &w, bool place) { return; w.setWorkspace(m_id); - // attach signals - w.titleSig().attach(this); if (place) placeWindow(w); m_windowlist.push_back(&w); - updateClientmenu(); + m_clientlist_sig.notify(); if (!w.isStuck()) { FluxboxWindow::ClientList::iterator client_it = @@ -200,19 +122,11 @@ int Workspace::removeWindow(FluxboxWindow *w, bool still_alive) { if (w == 0) return -1; - // detach from signals - w->titleSig().detach(this); - if (w->isFocused() && still_alive) FocusControl::unfocusWindow(w->winClient(), true, true); - // we don't remove it from the layermanager, as it may be being moved - Windows::iterator erase_it = remove(m_windowlist.begin(), - m_windowlist.end(), w); - if (erase_it != m_windowlist.end()) - m_windowlist.erase(erase_it); - - updateClientmenu(); + m_windowlist.remove(w); + m_clientlist_sig.notify(); if (!w->isStuck()) { FluxboxWindow::ClientList::iterator client_it = @@ -361,11 +275,6 @@ bool Workspace::loadGroups(const string &filename) { return true; } -void Workspace::update(FbTk::Subject *subj) { - updateClientmenu(); -} - - void Workspace::setName(const string &name) { if (!name.empty() && name != "") { m_name = name; @@ -399,22 +308,7 @@ void Workspace::shutdown() { } void Workspace::updateClientmenu() { - // remove all items and then add them again - menu().removeAll(); - // for each fluxboxwindow add every client in them to our clientlist - Windows::iterator win_it = m_windowlist.begin(); - Windows::iterator win_it_end = m_windowlist.end(); - for (; win_it != win_it_end; ++win_it) { - // add every client in this fluxboxwindow to menu - FluxboxWindow::ClientList::iterator client_it = - (*win_it)->clientList().begin(); - FluxboxWindow::ClientList::iterator client_it_end = - (*win_it)->clientList().end(); - for (; client_it != client_it_end; ++client_it) - menu().insert(new ClientMenuItem(*(*client_it))); - } - - menu().updateMenu(); + m_clientlist_sig.notify(); } void Workspace::placeWindow(FluxboxWindow &win) { diff --git a/src/Workspace.hh b/src/Workspace.hh index b7c2951..e4fffd0 100644 --- a/src/Workspace.hh +++ b/src/Workspace.hh @@ -25,30 +25,24 @@ #ifndef WORKSPACE_HH #define WORKSPACE_HH +#include "ClientMenu.hh" - -#include "FbMenu.hh" - -#include "FbTk/MultLayers.hh" -#include "FbTk/Observer.hh" #include "FbTk/NotCopyable.hh" #include -#include #include class BScreen; class FluxboxWindow; -class WinClient; /** * Handles a single workspace */ -class Workspace:private FbTk::NotCopyable, private FbTk::Observer { +class Workspace: private FbTk::NotCopyable { public: - typedef std::vector Windows; + typedef std::list Windows; - Workspace(BScreen &screen, FbTk::MultLayers &layermanager, const std::string &name, + Workspace(BScreen &screen, const std::string &name, unsigned int workspaceid = 0); ~Workspace(); @@ -88,19 +82,18 @@ public: static bool loadGroups(const std::string &filename); private: - void update(FbTk::Subject *subj); void placeWindow(FluxboxWindow &win); BScreen &m_screen; - FbMenu m_clientmenu; typedef std::vector Group; typedef std::vector GroupList; static GroupList m_groups; ///< handle auto groupings - FbTk::MultLayers &m_layermanager; Windows m_windowlist; + FbTk::Subject m_clientlist_sig; + ClientMenu m_clientmenu; std::string m_name; ///< name of this workspace unsigned int m_id; ///< id, obsolete, this should be in BScreen -- cgit v0.11.2