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'.
This commit is contained in:
Mathias Gumz 2011-02-22 22:07:39 +01:00
parent b7e84104a6
commit d11aa42ace
26 changed files with 65 additions and 61 deletions

View file

@ -49,7 +49,7 @@ void ButtonTool::updateSizing() {
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());

View file

@ -41,7 +41,7 @@ public:
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;

View file

@ -334,7 +334,7 @@ void ClockTool::reRender() {
}
void ClockTool::renderTheme(unsigned char alpha) {
void ClockTool::renderTheme(int alpha) {
m_button.setAlpha(alpha);
m_button.setJustify(m_theme->justify());

View file

@ -69,7 +69,7 @@ public:
private:
void updateTime();
void update(FbTk::Subject *subj);
void renderTheme(unsigned char alpha);
void renderTheme(int alpha);
void reRender();
void updateSizing();

View file

@ -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));
}

View file

@ -91,7 +91,7 @@ public:
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(); }

View file

@ -171,7 +171,7 @@ void FbWindow::invalidateBackground() {
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 @@ void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, u
#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 @@ void FbWindow::setAlpha(unsigned char alpha) {
#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 @@ long FbWindow::eventMask() const {
}
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;

View file

@ -88,7 +88,7 @@ public:
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 @@ public:
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 @@ public:
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,

View file

@ -107,7 +107,7 @@ public:
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 @@ private:
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)

View file

@ -43,7 +43,7 @@ using std::endl;
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 @@ bool Transparent::haveComposite(bool for_real) {
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 @@ Transparent::~Transparent() {
#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 @@ void Transparent::setSource(Drawable source, int screen_num) {
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 @@ void Transparent::render(int src_x, int src_y,
#endif // HAVE_XRENDER
}
void Transparent::allocAlpha(unsigned char alpha) {
void Transparent::allocAlpha(int alpha) {
#ifdef HAVE_XRENDER
if (m_source == 0 || !s_render)
return;

View file

@ -29,10 +29,10 @@ namespace FbTk {
/// 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 @@ public:
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 @@ public:
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;

View file

@ -427,7 +427,7 @@ void FbWinFrame::alignTabs() {
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 @@ void FbWinFrame::setFocus(bool 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 @@ void FbWinFrame::applyState() {
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 @@ void FbWinFrame::setAlpha(bool focused, unsigned char alpha) {
}
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 @@ void FbWinFrame::applyAlpha() {
}
}
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 @@ void FbWinFrame::reconfigure() {
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 @@ void FbWinFrame::applyTitlebar() {
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::renderHandles() {
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);

View file

@ -121,9 +121,9 @@ public:
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 @@ private:
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;
};

View file

@ -74,8 +74,8 @@ public:
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 @@ private:
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;
};

View file

@ -78,7 +78,7 @@ FocusControl::FocusControl(BScreen &screen):
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) {

View file

@ -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();
}

View file

@ -60,7 +60,7 @@ public:
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);

View file

@ -475,7 +475,7 @@ void IconbarTool::updateSizing() {
}
void IconbarTool::renderTheme(unsigned char alpha) {
void IconbarTool::renderTheme(int alpha) {
m_alpha = alpha;
renderTheme();

View file

@ -81,7 +81,7 @@ private:
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 @@ private:
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

View file

@ -74,7 +74,7 @@ public:
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);

View file

@ -41,8 +41,8 @@ public:
// 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 @@ protected:
private:
FbTk::ThemeItem<FbTk::Texture> m_texture;
FbTk::BorderTheme m_border;
unsigned char m_alpha;
int m_alpha;
};
#endif // TOOLTHEME_HH

View file

@ -54,7 +54,7 @@ public:
// 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

View file

@ -198,11 +198,11 @@ public:
// ------------------
// 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(); }

View file

@ -37,7 +37,9 @@ public:
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();

View file

@ -147,7 +147,7 @@ void WorkspaceNameTool::reRender() {
}
}
void WorkspaceNameTool::renderTheme(unsigned char alpha) {
void WorkspaceNameTool::renderTheme(int alpha) {
m_button.setJustify(m_theme->justify());
m_button.setBorderWidth(m_theme->border().width());

View file

@ -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;