all repos — fluxbox @ d11aa42ace928efc3dd1eebc8988b6bbbc005b2b

custom fork of the fluxbox windowmanager

bugfix: consistent use of 'int' for alpha values (#3187373)

WindowMenuAccessor returned strange alpha values if compiled
with 'g++ -Os'; unholy black magic happens if template<int> faces
functions returning only 'usigned char'.
Mathias Gumz akira at fluxbox dot org
commit

d11aa42ace928efc3dd1eebc8988b6bbbc005b2b

parent

b7e84104a695bb3628e482c4be93f6f516e46e7d

M src/ButtonTool.ccsrc/ButtonTool.cc

@@ -49,7 +49,7 @@ FbTk::Button &btn = static_cast<FbTk::Button &>(window());

btn.setBorderWidth(theme()->border().width()); } -void ButtonTool::renderTheme(unsigned char alpha) { +void ButtonTool::renderTheme(int alpha) { FbTk::Button &btn = static_cast<FbTk::Button &>(window()); btn.setGC(static_cast<const ButtonTheme &>(*theme()).gc());
M src/ButtonTool.hhsrc/ButtonTool.hh

@@ -41,7 +41,7 @@ FbTk::ImageControl &img_ctrl);

virtual ~ButtonTool(); protected: - void renderTheme(unsigned char alpha); + void renderTheme(int alpha); void updateSizing(); Pixmap m_cache_pm, m_cache_pressed_pm; FbTk::ImageControl &m_image_ctrl;
M src/ClockTool.ccsrc/ClockTool.cc

@@ -334,7 +334,7 @@ }

} -void ClockTool::renderTheme(unsigned char alpha) { +void ClockTool::renderTheme(int alpha) { m_button.setAlpha(alpha); m_button.setJustify(m_theme->justify());
M src/ClockTool.hhsrc/ClockTool.hh

@@ -69,7 +69,7 @@

private: void updateTime(); void update(FbTk::Subject *subj); - void renderTheme(unsigned char alpha); + void renderTheme(int alpha); void reRender(); void updateSizing();
M src/FbTk/Container.ccsrc/FbTk/Container.cc

@@ -440,7 +440,7 @@ void Container::for_each(std::mem_fun_t<void, FbWindow> function) {

std::for_each(begin(), end(), function); } -void Container::setAlpha(unsigned char alpha) { +void Container::setAlpha(int alpha) { FbWindow::setAlpha(alpha); STLUtil::forAll(m_item_list, std::bind2nd(std::mem_fun(&Button::setAlpha), alpha)); }
M src/FbTk/Container.hhsrc/FbTk/Container.hh

@@ -91,7 +91,7 @@ unsigned int maxWidthPerClient() const;

bool updateLock() const { return m_update_lock; } void for_each(std::mem_fun_t<void, FbWindow> function); - void setAlpha(unsigned char alpha); // set alpha on all windows + void setAlpha(int alpha); // set alpha on all windows ItemList::iterator begin() { return m_item_list.begin(); } ItemList::iterator end() { return m_item_list.end(); }
M src/FbTk/FbWindow.ccsrc/FbTk/FbWindow.cc

@@ -171,7 +171,7 @@ }

void FbWindow::updateBackground(bool only_if_alpha) { Pixmap newbg = m_lastbg_pm; - unsigned char alpha = 255; + int alpha = 255; bool free_newbg = false; if (m_lastbg_pm == None && !m_lastbg_color_set)

@@ -344,7 +344,7 @@ the_width, the_height);

#endif // HAVE_XRENDER } -void FbWindow::setAlpha(unsigned char alpha) { +void FbWindow::setAlpha(int alpha) { #ifdef HAVE_XRENDER if (FbTk::Transparent::haveComposite()) { if (m_transparent.get() != 0) {

@@ -371,7 +371,7 @@ }

#endif // HAVE_XRENDER } -unsigned char FbWindow::alpha() const { +int FbWindow::alpha() const { #ifdef HAVE_XRENDER if (m_transparent.get()) return m_transparent->alpha();

@@ -588,7 +588,7 @@ return attrib.your_event_mask;

} -void FbWindow::setOpaque(unsigned char alpha) { +void FbWindow::setOpaque(int alpha) { #ifdef HAVE_XRENDER static Atom m_alphaatom = XInternAtom(display(), "_NET_WM_WINDOW_OPACITY", False); unsigned long opacity = alpha * 0x1010101;
M src/FbTk/FbWindow.hhsrc/FbTk/FbWindow.hh

@@ -88,7 +88,7 @@ void updateTransparent(int x = -1, int y = -1, unsigned int width = 0,

unsigned int height = 0, Pixmap dest_override = None, bool override_is_offset = false); - void setAlpha(unsigned char alpha); + void setAlpha(int alpha); virtual FbWindow &operator = (const FbWindow &win); /// assign a new X window to this

@@ -176,7 +176,7 @@ unsigned int height() const { return m_height; }

unsigned int borderWidth() const { return m_border_width; } unsigned long borderColor() const { return m_border_color; } unsigned int depth() const { return m_depth; } - unsigned char alpha() const; + int alpha() const; int screenNumber() const; long eventMask() const;

@@ -188,7 +188,7 @@ bool operator == (const FbWindow &win) const { return m_window == win.m_window; }

bool operator != (const FbWindow &win) const { return m_window != win.m_window; } // used for composite - void setOpaque(unsigned char alpha); + void setOpaque(int alpha); void setRenderer(FbWindowRenderer &renderer) { m_renderer = &renderer; } void sendConfigureNotify(int x, int y, unsigned int width,
M src/FbTk/MenuTheme.hhsrc/FbTk/MenuTheme.hh

@@ -107,7 +107,7 @@ unsigned int borderWidth() const { return *m_border_width; }

unsigned int bevelWidth() const { return *m_bevel_width; } unsigned char alpha() const { return m_alpha; } - void setAlpha(unsigned char alpha) { m_alpha = alpha; } + void setAlpha(int alpha) { m_alpha = alpha; } // this isn't actually a theme item // but we'll let it be here for now, until there's a better way to // get resources into menu

@@ -154,7 +154,7 @@

Display *m_display; GContext t_text_gc, f_text_gc, u_text_gc, h_text_gc, d_text_gc, hilite_gc; - unsigned char m_alpha; + int m_alpha; unsigned int m_delay; ///< in msec unsigned int m_real_title_height; ///< the calculated item height (from font and menu.titleHeight) unsigned int m_real_item_height; ///< the calculated item height (from font and menu.itemHeight)
M src/FbTk/Transparent.ccsrc/FbTk/Transparent.cc

@@ -43,7 +43,7 @@

namespace { #ifdef HAVE_XRENDER -Picture createAlphaPic(Window drawable, unsigned char alpha) { +Picture createAlphaPic(Window drawable, int alpha) { Display *disp = FbTk::App::instance()->display(); _FB_USES_NLS;

@@ -149,7 +149,7 @@ else

return s_use_composite; } -Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int screen_num): +Transparent::Transparent(Drawable src, Drawable dest, int alpha, int screen_num): m_alpha_pic(0), m_src_pic(0), m_dest_pic(0), m_source(src), m_dest(dest), m_alpha(alpha) {

@@ -196,7 +196,7 @@ XRenderFreePicture(disp, m_src_pic);

#endif // HAVE_XRENDER } -void Transparent::setAlpha(unsigned char alpha) { +void Transparent::setAlpha(int alpha) { if (m_source == 0 || !s_render) return;

@@ -254,7 +254,7 @@ if (m_source == source || !s_render)

return; // save old alpha value so we can recreate new later // with the same value - unsigned char old_alpha = m_alpha; + int old_alpha = m_alpha; if (m_alpha_pic != 0) freeAlpha();

@@ -314,7 +314,7 @@

#endif // HAVE_XRENDER } -void Transparent::allocAlpha(unsigned char alpha) { +void Transparent::allocAlpha(int alpha) { #ifdef HAVE_XRENDER if (m_source == 0 || !s_render) return;
M src/FbTk/Transparent.hhsrc/FbTk/Transparent.hh

@@ -29,10 +29,10 @@

/// renders to drawable together with an alpha mask class Transparent { public: - Transparent(Drawable source, Drawable dest, unsigned char alpha, int screen_num); + Transparent(Drawable source, Drawable dest, int alpha, int screen_num); ~Transparent(); /// sets alpha value - void setAlpha(unsigned char alpha); + void setAlpha(int alpha); /// sets source drawable void setSource(Drawable src, int screen_num); /// sets destination drawable

@@ -45,7 +45,7 @@ void render(int src_x, int src_y,

int dest_x, int dest_y, unsigned int width, unsigned int height) const; - unsigned char alpha() const { return m_alpha; } + int alpha() const { return m_alpha; } Drawable dest() const { return m_dest; } Drawable source() const { return m_source; }

@@ -55,7 +55,7 @@ static void usePseudoTransparent(bool force);

private: void freeAlpha(); - void allocAlpha(unsigned char newval); + void allocAlpha(int newval); unsigned long m_alpha_pic; unsigned long m_src_pic; unsigned long m_dest_pic;
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -427,7 +427,7 @@ }

void FbWinFrame::notifyMoved(bool clear) { // not important if no alpha... - unsigned char alpha = getAlpha(m_state.focused); + int alpha = getAlpha(m_state.focused); if (alpha == 255) return;

@@ -482,7 +482,7 @@ m_state.focused = newvalue;

if (FbTk::Transparent::haveRender() && getAlpha(true) != getAlpha(false)) { // different alpha for focused and unfocused - unsigned char alpha = getAlpha(m_state.focused); + int alpha = getAlpha(m_state.focused); if (FbTk::Transparent::haveComposite()) { m_tab_container.setAlpha(255); m_window.setOpaque(alpha);

@@ -536,7 +536,7 @@ moveResize(new_x, new_y, new_w, new_h);

frameExtentSig().notify(); } -void FbWinFrame::setAlpha(bool focused, unsigned char alpha) { +void FbWinFrame::setAlpha(bool focused, int alpha) { if (focused) m_focused_alpha = alpha; else

@@ -547,7 +547,7 @@ applyAlpha();

} void FbWinFrame::applyAlpha() { - unsigned char alpha = getAlpha(m_state.focused); + int alpha = getAlpha(m_state.focused); if (FbTk::Transparent::haveComposite()) m_window.setOpaque(alpha); else {

@@ -557,8 +557,11 @@ clearAll();

} } -unsigned char FbWinFrame::getAlpha(bool focused) const { - return focused ? m_focused_alpha : m_unfocused_alpha; +int FbWinFrame::getAlpha(bool focused) const { + if (focused) + return m_focused_alpha; + else + return m_unfocused_alpha; } void FbWinFrame::setDefaultAlpha() {

@@ -966,8 +969,7 @@ // render the theme

if (isVisible()) { // update transparency settings if (FbTk::Transparent::haveRender()) { - unsigned char alpha = - getAlpha(m_state.focused); + int alpha = getAlpha(m_state.focused); if (FbTk::Transparent::haveComposite()) { m_tab_container.setAlpha(255); m_window.setOpaque(alpha);

@@ -1168,7 +1170,7 @@ FbTk::Color title_color;

getCurrentFocusPixmap(label_pm, title_pm, label_color, title_color); - unsigned char alpha = getAlpha (m_state.focused); + int alpha = getAlpha (m_state.focused); m_titlebar.setAlpha(alpha); m_label.setAlpha(alpha);

@@ -1220,7 +1222,7 @@ }

void FbWinFrame::applyHandles() { - unsigned char alpha = getAlpha(m_state.focused); + int alpha = getAlpha(m_state.focused); m_handle.setAlpha(alpha); m_grip_left.setAlpha(alpha); m_grip_right.setAlpha(alpha);
M src/FbWinFrame.hhsrc/FbWinFrame.hh

@@ -121,9 +121,9 @@ bool setTabMode(TabMode tabmode);

void updateTabProperties() { alignTabs(); } /// Alpha settings - void setAlpha(bool focused, unsigned char value); + void setAlpha(bool focused, int value); void applyAlpha(); - unsigned char getAlpha(bool focused) const; + int getAlpha(bool focused) const; void setDefaultAlpha(); bool getUseDefaultAlpha() const;

@@ -377,9 +377,9 @@

bool m_need_render; int m_button_size; ///< size for all titlebar buttons /// alpha values - typedef FbTk::ConstObjectAccessor<unsigned char, FbWinFrameTheme> AlphaAcc; - FbTk::DefaultValue<unsigned char, AlphaAcc> m_focused_alpha; - FbTk::DefaultValue<unsigned char, AlphaAcc> m_unfocused_alpha; + typedef FbTk::ConstObjectAccessor<int, FbWinFrameTheme> AlphaAcc; + FbTk::DefaultValue<int, AlphaAcc> m_focused_alpha; + FbTk::DefaultValue<int, AlphaAcc> m_unfocused_alpha; FbTk::Shape m_shape; };
M src/FbWinFrameTheme.hhsrc/FbWinFrameTheme.hh

@@ -74,8 +74,8 @@ unsigned int titleHeight() const { return *m_title_height; }

unsigned int bevelWidth() const { return *m_bevel_width; } unsigned int handleWidth() const { return *m_handle_width; } - unsigned char alpha() const { return m_alpha; } - void setAlpha(unsigned char alpha) { m_alpha = alpha; } + int alpha() const { return m_alpha; } + void setAlpha(int alpha) { m_alpha = alpha; } IconbarTheme &iconbarTheme() { return m_iconbar_theme; }

@@ -107,7 +107,7 @@ Cursor m_cursor_left_side;

Cursor m_cursor_right_side; Cursor m_cursor_top_side; Cursor m_cursor_bottom_side; - unsigned char m_alpha; + int m_alpha; IconbarTheme m_iconbar_theme; };
M src/FocusControl.ccsrc/FocusControl.cc

@@ -78,7 +78,7 @@ screen.altName()+".FocusNewWindows"),

m_focused_list(screen), m_creation_order_list(screen), m_focused_win_list(screen), m_creation_order_win_list(screen), m_cycling_list(0), - m_was_iconic(false), + m_was_iconic(0), m_cycling_last(0), m_ignore_mouse_x(-1), m_ignore_mouse_y(-1) {
M src/GenericTool.ccsrc/GenericTool.cc

@@ -75,7 +75,7 @@ unsigned int GenericTool::borderWidth() const {

return m_window->borderWidth(); } -void GenericTool::renderTheme(unsigned char alpha) { +void GenericTool::renderTheme(int alpha) { m_window->setAlpha(alpha); m_window->clear(); }
M src/GenericTool.hhsrc/GenericTool.hh

@@ -60,7 +60,7 @@ FbTk::FbWindow &window() { return *m_window; }

const FbTk::FbWindow &window() const { return *m_window; } protected: - virtual void renderTheme(unsigned char alpha); + virtual void renderTheme(int alpha); private: void update(FbTk::Subject *subj);
M src/IconbarTool.ccsrc/IconbarTool.cc

@@ -475,7 +475,7 @@ FbTk::Select2nd<IconMap::value_type>()));

} -void IconbarTool::renderTheme(unsigned char alpha) { +void IconbarTool::renderTheme(int alpha) { m_alpha = alpha; renderTheme();
M src/IconbarTool.hhsrc/IconbarTool.hh

@@ -81,7 +81,7 @@ /// @param clear if the window should be cleared first

void renderButton(IconButton &button, bool clear = true); /// render all buttons void renderTheme(); - void renderTheme(unsigned char alpha); + void renderTheme(int alpha); /// destroy all icons void deleteIcons(); /// add or move a single window

@@ -111,7 +111,7 @@ FbTk::Resource<int> m_rc_client_width; ///< size of client button in LEFT/RIGHT mode

FbTk::Resource<unsigned int> m_rc_client_padding; ///< padding of the text FbTk::Resource<bool> m_rc_use_pixmap; ///< if iconbar should use win pixmap or not FbMenu m_menu; - unsigned char m_alpha; + int m_alpha; }; #endif // ICONBARTOOL_HH
M src/SystemTray.hhsrc/SystemTray.hh

@@ -74,7 +74,7 @@

int numClients() const { return m_clients.size(); } const FbTk::FbWindow &window() const { return m_window; } - void renderTheme(unsigned char alpha) { + void renderTheme(int alpha) { m_window.setBorderWidth(m_theme->border().width()); m_window.setBorderColor(m_theme->border().color()); m_window.setAlpha(alpha);
M src/ToolTheme.hhsrc/ToolTheme.hh

@@ -41,8 +41,8 @@ void reconfigTheme();

// textures const FbTk::Texture &texture() const { return *m_texture; } const FbTk::BorderTheme &border() const { return m_border; } - unsigned char alpha() const { return m_alpha; } - void setAlpha(unsigned char alpha) { m_alpha = alpha; } + int alpha() const { return m_alpha; } + void setAlpha(int alpha) { m_alpha = alpha; } virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); }

@@ -56,7 +56,7 @@

private: FbTk::ThemeItem<FbTk::Texture> m_texture; FbTk::BorderTheme m_border; - unsigned char m_alpha; + int m_alpha; }; #endif // TOOLTHEME_HH
M src/ToolbarItem.hhsrc/ToolbarItem.hh

@@ -54,7 +54,7 @@ virtual bool active() { return true; }

// Tools should NOT listen to theme changes - they'll get notified by // the toolbar instead. Otherwise there are ordering problems. - virtual void renderTheme(unsigned char alpha) = 0; + virtual void renderTheme(int alpha) = 0; // insist implemented, even if blank virtual void parentMoved() = 0; // called when moved from hiding
M src/Window.hhsrc/Window.hh

@@ -198,11 +198,11 @@ void deiconify(bool do_raise = true);

// ------------------ // Per window transparency addons - unsigned char getFocusedAlpha() const { return frame().getAlpha(true); } - unsigned char getUnfocusedAlpha() const { return frame().getAlpha(false); } - void setFocusedAlpha(unsigned char alpha) { frame().setAlpha(true, alpha); } - void setUnfocusedAlpha(unsigned char alpha) { frame().setAlpha(false, alpha); } - void updateAlpha(bool focused, unsigned char alpha) { frame().setAlpha(focused, alpha); } + int getFocusedAlpha() const { return frame().getAlpha(true); } + int getUnfocusedAlpha() const { return frame().getAlpha(false); } + void setFocusedAlpha(int alpha) { frame().setAlpha(true, alpha); } + void setUnfocusedAlpha(int alpha) { frame().setAlpha(false, alpha); } + void updateAlpha(bool focused, int alpha) { frame().setAlpha(focused, alpha); } bool getUseDefaultAlpha() const { return frame().getUseDefaultAlpha(); } void setDefaultAlpha() { frame().setDefaultAlpha(); }
M src/WindowMenuAccessor.hhsrc/WindowMenuAccessor.hh

@@ -37,7 +37,9 @@ m_getter(g), m_setter(s), m_def(def) { }

operator Ret() const { FluxboxWindow *fbwin = FbMenu::window(); - return fbwin ? (fbwin->*m_getter)() : m_def; + if (fbwin) + return (Ret)(fbwin->*m_getter)(); + return m_def; } FbTk::Accessor<Ret> &operator =(const Ret &val) { FluxboxWindow *fbwin = FbMenu::window();
M src/WorkspaceNameTool.ccsrc/WorkspaceNameTool.cc

@@ -147,7 +147,7 @@ m_button.setBackgroundColor(m_theme->texture().color());

} } -void WorkspaceNameTool::renderTheme(unsigned char alpha) { +void WorkspaceNameTool::renderTheme(int alpha) { m_button.setJustify(m_theme->justify()); m_button.setBorderWidth(m_theme->border().width());
M src/WorkspaceNameTool.hhsrc/WorkspaceNameTool.hh

@@ -64,7 +64,7 @@ private:

/// Called when workspace changed on \c screen void updateForScreen(BScreen &screen); - void renderTheme(unsigned char alpha); + void renderTheme(int alpha); void reRender(); void updateSizing(); FbTk::TextButton m_button;