fix disappearing menu selection boxes
simonb simonb
5 files changed,
35 insertions(+),
12 deletions(-)
M
ChangeLog
→
ChangeLog
@@ -1,5 +1,9 @@
(Format: Year/Month/Day) Changes for 1.0rc2: +*06/06/24: + * Fix bug #1362463, menu selection pixmaps disappear (Simon) + - pixmap from image cache was put into FbPixmap, which freed it. + FbPixmap.hh/cc MenuTheme.hh Menu.cc *06/06/23: * Make startfluxbox aware of --program-prefix and --program-suffix (Mark) configure.in util/Makefile.am util/startfluxbox.in
M
src/FbTk/FbPixmap.cc
→
src/FbTk/FbPixmap.cc
@@ -54,18 +54,18 @@
FbPixmap::FbPixmap():m_pm(0), m_width(0), m_height(0), - m_depth(0) { + m_depth(0), m_dont_free(false) { } FbPixmap::FbPixmap(const FbPixmap &the_copy):FbDrawable(), m_pm(0), m_width(0), m_height(0), - m_depth(0){ + m_depth(0), m_dont_free(false) { copy(the_copy); } FbPixmap::FbPixmap(Pixmap pm):m_pm(0), m_width(0), m_height(0), - m_depth(0) { + m_depth(0), m_dont_free(false) { if (pm == 0) return; // assign X pixmap to this@@ -76,7 +76,7 @@ FbPixmap::FbPixmap(const FbDrawable &src,
unsigned int width, unsigned int height, unsigned int depth):m_pm(0), m_width(0), m_height(0), - m_depth(0) { + m_depth(0), m_dont_free(false) { create(src.drawable(), width, height, depth); }@@ -85,7 +85,7 @@ FbPixmap::FbPixmap(Drawable src,
unsigned int width, unsigned int height, unsigned int depth):m_pm(0), m_width(0), m_height(0), - m_depth(0) { + m_depth(0), m_dont_free(false) { create(src, width, height, depth); }@@ -470,10 +470,13 @@ }
} void FbPixmap::free() { - if (m_pm != 0) { + if (!m_dont_free && m_pm != 0) XFreePixmap(display(), m_pm); - m_pm = 0; - } + + /* note: m_dont_free shouldnt be required anywhere else, + because then free() isn't being called appropriately! */ + m_dont_free = false; + m_pm = 0; m_width = 0; m_height = 0; m_depth = 0;
M
src/FbTk/FbPixmap.hh
→
src/FbTk/FbPixmap.hh
@@ -77,11 +77,18 @@ void create(Drawable src,
unsigned int width, unsigned int height, unsigned int depth); + /* Will be reset to false whenever this pixmap is reassigned */ + void dontFree() { m_dont_free = true; } + private: void free(); + Pixmap m_pm; unsigned int m_width, m_height; unsigned int m_depth; + + // if pixmap not *owned* by this object (eg assigned from cache object) + bool m_dont_free; /// Functions relating to the maintenance of root window pixmap caching static void checkAtoms();
M
src/FbTk/Menu.cc
→
src/FbTk/Menu.cc
@@ -470,11 +470,11 @@
if (!theme().selectedPixmap().pixmap().drawable()) { int hw = theme().itemHeight() / 2; - m_theme.setSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().hiliteTexture())); + m_theme.setSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().hiliteTexture()), true); if (!theme().highlightSelectedPixmap().pixmap().drawable()) { int hw = theme().itemHeight() / 2; - m_theme.setHighlightSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().frameTexture())); + m_theme.setHighlightSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().frameTexture()), true); } }
M
src/FbTk/MenuTheme.hh
→
src/FbTk/MenuTheme.hh
@@ -126,8 +126,17 @@
inline const FbTk::Color &borderColor() const { return *m_border_color; } // special override - inline void setSelectedPixmap(Pixmap pm) { m_selected_pixmap->pixmap() = pm; } - inline void setHighlightSelectedPixmap(Pixmap pm) { m_hl_selected_pixmap->pixmap() = pm; } + inline void setSelectedPixmap(Pixmap pm, bool is_imagecached) { + m_selected_pixmap->pixmap() = pm; + if (is_imagecached) + m_selected_pixmap->pixmap().dontFree(); + } + + inline void setHighlightSelectedPixmap(Pixmap pm, bool is_imagecached) { + m_hl_selected_pixmap->pixmap() = pm; + if (is_imagecached) + m_hl_selected_pixmap->pixmap().dontFree(); + } private: FbTk::ThemeItem<FbTk::Color> t_text, f_text, h_text, d_text;