all repos — fluxbox @ 5ce35d9fa811358162ae44ee1ca514270d7da466

custom fork of the fluxbox windowmanager

toggle pixmap for IconButton
fluxgen fluxgen
commit

5ce35d9fa811358162ae44ee1ca514270d7da466

parent

258cb10be2dc5a7b932ee4bebb9833d597b3cb18

4 files changed, 48 insertions(+), 11 deletions(-)

jump to
M src/IconButton.ccsrc/IconButton.cc

@@ -20,7 +20,7 @@ // 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: IconButton.cc,v 1.12 2003/11/19 12:57:27 rathnor Exp $ +// $Id: IconButton.cc,v 1.13 2003/11/27 14:27:48 fluxgen Exp $ #include "IconButton.hh"

@@ -66,7 +66,8 @@ FluxboxWindow &win):

FbTk::TextButton(parent, font, win.winClient().title()), m_win(win), m_icon_window(*this, 1, 1, 1, 1, - ExposureMask | ButtonPressMask | ButtonReleaseMask) { + ExposureMask | ButtonPressMask | ButtonReleaseMask), + m_use_pixmap(true) { FbTk::RefCount<FbTk::Command> focus(new FbTk::SimpleCommand<FluxboxWindow>(m_win, &FluxboxWindow::raiseAndFocus)); FbTk::RefCount<FbTk::Command> menu(new ::ShowMenu(m_win));

@@ -117,6 +118,13 @@ FbTk::TextButton::clearArea(x, y,

width, height, exposure); } +void IconButton::setPixmap(bool use) { + if (m_use_pixmap != use) { + m_use_pixmap = use; + update(0); + } +} + void IconButton::update(FbTk::Subject *subj) { // we got signal that either title or // icon pixmap was updated,

@@ -130,7 +138,7 @@ XWMHints *hints = XGetWMHints(FbTk::App::instance()->display(), m_win.winClient().window());

if (hints == 0) return; - if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) { + if (m_use_pixmap && (hints->flags & IconPixmapHint) && hints->icon_pixmap != 0) { // setup icon window m_icon_window.show(); int new_height = height() - 2*m_icon_window.y(); // equally padded

@@ -148,7 +156,7 @@ m_icon_window.hide();

m_icon_pixmap = 0; } - if(hints->flags & IconMaskHint) { + if(m_use_pixmap && (hints->flags & IconMaskHint)) { m_icon_mask.copy(hints->icon_mask); m_icon_mask.scale(m_icon_pixmap.width(), m_icon_pixmap.height()); } else

@@ -186,7 +194,10 @@ }

void IconButton::drawText(int x, int y) { // offset text - FbTk::TextButton::drawText(m_icon_window.x() + m_icon_window.width() + 1, y); + if (m_icon_pixmap.drawable() != 0) + FbTk::TextButton::drawText(m_icon_window.x() + m_icon_window.width() + 1, y); + else + FbTk::TextButton::drawText(1, y); }
M src/IconButton.hhsrc/IconButton.hh

@@ -20,7 +20,7 @@ // 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: IconButton.hh,v 1.3 2003/09/10 21:40:01 fluxgen Exp $ +// $Id: IconButton.hh,v 1.4 2003/11/27 14:27:48 fluxgen Exp $ #ifndef ICONBUTTON_HH #define ICONBUTTON_HH

@@ -33,7 +33,8 @@ class FluxboxWindow;

class IconButton: public FbTk::TextButton, public FbTk::Observer { public: - IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, FluxboxWindow &window); + IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, + FluxboxWindow &window); virtual ~IconButton(); void exposeEvent(XExposeEvent &event);

@@ -46,8 +47,11 @@ unsigned int width, unsigned int height);

void resize(unsigned int width, unsigned int height); void update(FbTk::Subject *subj); + void setPixmap(bool use); + FluxboxWindow &win() { return m_win; } const FluxboxWindow &win() const { return m_win; } + protected: void drawText(int x = 0, int y = 0); private:

@@ -57,6 +61,7 @@ FluxboxWindow &m_win;

FbTk::FbWindow m_icon_window; FbTk::FbPixmap m_icon_pixmap; FbTk::FbPixmap m_icon_mask; + bool m_use_pixmap; }; #endif // ICONBUTTON_HH
M src/IconbarTool.ccsrc/IconbarTool.cc

@@ -20,7 +20,7 @@ // 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: IconbarTool.cc,v 1.15 2003/10/26 20:13:11 fluxgen Exp $ +// $Id: IconbarTool.cc,v 1.16 2003/11/27 14:30:11 fluxgen Exp $ #include "IconbarTool.hh"

@@ -31,12 +31,15 @@ #include "IconButton.hh"

#include "Workspace.hh" #include "fluxbox.hh" #include "FbMenu.hh" +#include "BoolMenuItem.hh" +#include "CommandParser.hh" #include "FbTk/Menu.hh" #include "FbTk/MenuItem.hh" #include "FbTk/RefCount.hh" #include "FbTk/SimpleCommand.hh" #include "FbTk/ImageControl.hh" +#include "FbTk/MacroCommand.hh" #include <typeinfo> #include <string>

@@ -181,11 +184,26 @@ m_unfocused_pm(0),

m_empty_pm(0), m_rc_mode(screen.resourceManager(), WORKSPACE, screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), + m_rc_use_pixmap(screen.resourceManager(), true, + screen.name() + ".iconbar.usePixmap", screen.altName() + ".Iconbar.UsePixmap"), m_menu(*screen.menuTheme(), menu.screenNumber(), screen.imageControl(), *screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())) { - // setup menu + // setup mode menu setupModeMenu(m_menu, *this); + + using namespace FbTk; + // setup use pixmap item to reconfig iconbar and save resource on click + MacroCommand *save_and_reconfig = new MacroCommand(); + RefCount<Command> reconfig(new SimpleCommand<IconbarTool>(*this, &IconbarTool::renderTheme)); + RefCount<Command> save(CommandParser::instance().parseLine("saverc")); + save_and_reconfig->add(reconfig); + save_and_reconfig->add(save); + RefCount<Command> s_and_reconfig(save_and_reconfig); + m_menu.insert(new BoolMenuItem("Use Pixmap", *m_rc_use_pixmap, s_and_reconfig)); + m_menu.update(); + + // add iconbar menu to toolbar menu menu.insert(m_menu.label().c_str(), &m_menu); // setup signals

@@ -445,6 +463,8 @@ }

void IconbarTool::renderButton(IconButton &button) { + button.setPixmap(*m_rc_use_pixmap); + if (button.win().isFocused()) { // focused texture button.setGC(m_theme.focusedText().textGC()); button.setFont(m_theme.focusedText().font());

@@ -517,6 +537,7 @@ if (win.clientList().size() == 0)

return; IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), win); + button->setPixmap(*m_rc_use_pixmap); m_icon_container.insertItem(button); m_icon_list.push_back(button);

@@ -526,7 +547,6 @@ win.dieSig().attach(this);

win.workspaceSig().attach(this); win.stateSig().attach(this); } - void IconbarTool::updateIcons() { std::list<FluxboxWindow *> itemlist;
M src/IconbarTool.hhsrc/IconbarTool.hh

@@ -20,7 +20,7 @@ // 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: IconbarTool.hh,v 1.9 2003/10/06 06:22:42 rathnor Exp $ +// $Id: IconbarTool.hh,v 1.10 2003/11/27 14:30:11 fluxgen Exp $ #ifndef ICONBARTOOL_HH #define ICONBARTOOL_HH

@@ -108,6 +108,7 @@

IconList m_icon_list; FbTk::Resource<Mode> m_rc_mode; + FbTk::Resource<bool> m_rc_use_pixmap; ///< if iconbar should use win pixmap or not FbMenu m_menu; };