all repos — fluxbox @ ea184b3566bfee3f720763edf4e11cd27e9cd1d0

custom fork of the fluxbox windowmanager

fix rendering of icon buttons when they are slightly larger because of
rounding
rathnor rathnor
commit

ea184b3566bfee3f720763edf4e11cd27e9cd1d0

parent

3e41157a3532537a859cbbeb2d6adf367de25f96

4 files changed, 47 insertions(+), 10 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,6 +1,9 @@

(Format: Year/Month/Day) Changes for 0.9.7: *03/12/22: + * Fix rendering of icon buttons when larger from rounding (Simon) + Container.hh IconbarTool.hh/cc +*03/12/22: * Added Lock Screen to fluxbox-generate_menu (Thanks Han) *03/12/21: * Fix rounding on Iconbar (Simon)
M src/Container.hhsrc/Container.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: Container.hh,v 1.4 2003/12/12 14:35:34 fluxgen Exp $ +// $Id: Container.hh,v 1.5 2003/12/23 01:55:07 rathnor Exp $ #ifndef CONTAINER_HH #define CONTAINER_HH

@@ -54,6 +54,8 @@ int find(Item item);

void setSelected(int index); void setMaxSizePerClient(unsigned int size); void setAlignment(Alignment a); + + Item back() { return m_item_list.back(); } /// force update inline void update() { repositionItems(); }
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.24 2003/12/19 14:58:48 fluxgen Exp $ +// $Id: IconbarTool.cc,v 1.25 2003/12/23 01:55:07 rathnor Exp $ #include "IconbarTool.hh"

@@ -237,6 +237,8 @@ m_icon_container(parent),

m_theme(theme), m_focused_pm(0), m_unfocused_pm(0), + m_focused_err_pm(0), + m_unfocused_err_pm(0), m_empty_pm(0), m_rc_mode(screen.resourceManager(), WORKSPACE, screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"),

@@ -292,7 +294,11 @@ // remove cached images

if (m_focused_pm) m_screen.imageControl().removeImage(m_focused_pm); if (m_unfocused_pm) - m_screen.imageControl().removeImage(m_focused_pm); + m_screen.imageControl().removeImage(m_unfocused_pm); + if (m_focused_err_pm) + m_screen.imageControl().removeImage(m_focused_err_pm); + if (m_unfocused_err_pm) + m_screen.imageControl().removeImage(m_unfocused_err_pm); if (m_empty_pm) m_screen.imageControl().removeImage(m_empty_pm);

@@ -510,27 +516,43 @@ }

void IconbarTool::renderTheme() { Pixmap tmp = m_focused_pm; + Pixmap err_tmp = m_focused_err_pm; + unsigned int icon_width = m_icon_container.maxWidthPerClient(); if (!m_theme.focusedTexture().usePixmap()) { - m_focused_pm = 0; + m_focused_pm = 0; + m_focused_err_pm = 0; } else { - m_focused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), + m_focused_pm = m_screen.imageControl().renderImage(icon_width, + m_icon_container.height(), + m_theme.focusedTexture()); + m_focused_err_pm = m_screen.imageControl().renderImage(icon_width+1, m_icon_container.height(), m_theme.focusedTexture()); } if (tmp) m_screen.imageControl().removeImage(tmp); + if (err_tmp) + m_screen.imageControl().removeImage(err_tmp); tmp = m_unfocused_pm; + err_tmp = m_unfocused_err_pm; + if (!m_theme.unfocusedTexture().usePixmap()) { - m_unfocused_pm = 0; + m_unfocused_pm = 0; + m_unfocused_err_pm = 0; } else { - m_unfocused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), + m_unfocused_pm = m_screen.imageControl().renderImage(icon_width, + m_icon_container.height(), + m_theme.unfocusedTexture()); + m_unfocused_err_pm = m_screen.imageControl().renderImage(icon_width+1, m_icon_container.height(), m_theme.unfocusedTexture()); } if (tmp) m_screen.imageControl().removeImage(tmp); + if (err_tmp) + m_screen.imageControl().removeImage(err_tmp); // if we dont have any icons then we should render empty texture tmp = m_empty_pm;

@@ -561,14 +583,20 @@ void IconbarTool::renderButton(IconButton &button) {

button.setPixmap(*m_rc_use_pixmap); + // if we're rendering a button, there must be a back button. + // The last button is always the regular width + bool wider_button = (button.width() != m_icon_container.back()->width()); + if (button.win().isFocused()) { // focused texture m_icon_container.setSelected(m_icon_container.find(&button)); button.setGC(m_theme.focusedText().textGC()); button.setFont(m_theme.focusedText().font()); button.setJustify(m_theme.focusedText().justify()); - if (m_focused_pm != 0) + if (!wider_button && m_focused_pm != 0) button.setBackgroundPixmap(m_focused_pm); + else if (wider_button && m_focused_err_pm != 0) + button.setBackgroundPixmap(m_focused_err_pm); else button.setBackgroundColor(m_theme.focusedTexture().color());

@@ -583,8 +611,10 @@ button.setGC(m_theme.unfocusedText().textGC());

button.setFont(m_theme.unfocusedText().font()); button.setJustify(m_theme.unfocusedText().justify()); - if (m_unfocused_pm != 0) + if (!wider_button && m_unfocused_pm != 0) button.setBackgroundPixmap(m_unfocused_pm); + else if (wider_button && m_unfocused_err_pm != 0) + button.setBackgroundPixmap(m_unfocused_err_pm); else button.setBackgroundColor(m_theme.unfocusedTexture().color());
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.12 2003/12/19 14:57:44 fluxgen Exp $ +// $Id: IconbarTool.hh,v 1.13 2003/12/23 01:55:07 rathnor Exp $ #ifndef ICONBARTOOL_HH #define ICONBARTOOL_HH

@@ -107,6 +107,8 @@ Container m_icon_container;

const IconbarTheme &m_theme; // cached pixmaps Pixmap m_focused_pm, m_unfocused_pm; + // some are a fraction bigger due to rounding + Pixmap m_focused_err_pm, m_unfocused_err_pm; Pixmap m_empty_pm; ///< pixmap for empty container