all repos — fluxbox @ 2b25b05b27a0d4735ace950d667510bb4cf309b7

custom fork of the fluxbox windowmanager

added SetAlpha key command
markt markt
commit

2b25b05b27a0d4735ace950d667510bb4cf309b7

parent

de9ac128956c08aef22e68306c4f3fdcfde0221d

5 files changed, 91 insertions(+), 4 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,5 +1,16 @@

(Format: Year/Month/Day) Changes for 1.0rc3: +*07/02/02: + * Update window transparency immediately when using pseudotransparency, + also introduced new key command: SetAlpha [[+-]<int> [[+-]<int>]] (Mark) + - with no arguments, returns the focused window to default settings + - with one argument, changes both focused and unfocused settings the same + way + - with two arguments, the first changes the focused alpha, and the second + changes the unfocused alpha + E.g. SetAlpha 127 +5 will set the focused alpha to 127 and increment the + unfocused alpha by 5 (until it reaches 255) + FbWinFrame.cc FbCommandFactory.cc CurrentWindowCmd.cc/hh *07/01/26: * Fix default workspace names, and don't show empty menus (Mark) Workspace.cc FbTk/Menu.cc
M src/CurrentWindowCmd.ccsrc/CurrentWindowCmd.cc

@@ -173,3 +173,33 @@ FullscreenCmd::FullscreenCmd() { }

void FullscreenCmd::real_execute() { fbwindow().setFullscreen(!fbwindow().isFullscreen()); } + +SetAlphaCmd::SetAlphaCmd(int focused, bool relative, + int unfocused, bool un_relative) : + m_focus(focused), m_unfocus(unfocused), + m_relative(relative), m_un_relative(un_relative) { } + +void SetAlphaCmd::real_execute() { + if (m_focus == 256 && m_unfocus == 256) { + // made up signal to return to default + fbwindow().setUseDefaultAlpha(true); + return; + } + + int new_alpha; + if (m_relative) { + new_alpha = fbwindow().getFocusedAlpha() + m_focus; + if (new_alpha < 0) new_alpha = 0; + if (new_alpha > 255) new_alpha = 255; + fbwindow().setFocusedAlpha(new_alpha); + } else + fbwindow().setFocusedAlpha(m_focus); + + if (m_un_relative) { + new_alpha = fbwindow().getUnfocusedAlpha() + m_unfocus; + if (new_alpha < 0) new_alpha = 0; + if (new_alpha > 255) new_alpha = 255; + fbwindow().setUnfocusedAlpha(new_alpha); + } else + fbwindow().setUnfocusedAlpha(m_unfocus); +}
M src/CurrentWindowCmd.hhsrc/CurrentWindowCmd.hh

@@ -197,4 +197,14 @@ explicit FullscreenCmd();

protected: void real_execute(); }; + +class SetAlphaCmd: public WindowHelperCmd { +public: + SetAlphaCmd(int focus, bool rel, int unfocus, bool unrel); +protected: + void real_execute(); +private: + int m_focus, m_unfocus; + int m_relative, m_un_relative; +}; #endif // CURRENTWINDOWCMD_HH
M src/FbCommandFactory.ccsrc/FbCommandFactory.cc

@@ -123,6 +123,7 @@ "saverc",

"sendtoworkspace", "sendtonextworkspace", "sendtoprevworkspace", + "setalpha", "setenv", "sethead", "setmodkey",

@@ -247,7 +248,29 @@ else if (command == "maximizevertical")

return new CurrentWindowCmd(&FluxboxWindow::maximizeVertical); else if (command == "maximizehorizontal") return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal); - else if (command == "resize") { + else if (command == "setalpha") { + typedef vector<string> StringTokens; + StringTokens tokens; + FbTk::StringUtil::stringtok<StringTokens>(tokens, arguments); + + int focused, unfocused; + bool relative, un_rel; + + if (tokens.empty()) { // set default alpha + focused = unfocused = 256; + relative = un_rel = false; + } else { + relative = un_rel = (tokens[0][0] == '+' || tokens[0][0] == '-'); + focused = unfocused = atoi(tokens[0].c_str()); + } + + if (tokens.size() > 1) { // set different unfocused alpha + un_rel = (tokens[1][0] == '+' || tokens[1][0] == '-'); + unfocused = atoi(tokens[1].c_str()); + } + + return new SetAlphaCmd(focused, relative, unfocused, un_rel); + } else if (command == "resize") { FbTk_istringstream is(arguments.c_str()); int dx = 0, dy = 0; is >> dx >> dy;
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -546,8 +546,15 @@ m_focused_alpha = alpha;

else m_unfocused_alpha = alpha; - if (m_focused == focused) - m_window.setOpaque(alpha); + if (m_focused == focused) { + if (FbTk::Transparent::haveComposite()) + m_window.setOpaque(alpha); + else { + // don't need to setAlpha, since apply updates them anyway + applyAll(); + clearAll(); + } + } } unsigned char FbWinFrame::getAlpha(bool focused) const

@@ -569,7 +576,13 @@ }

m_use_default_alpha = default_alpha; - m_window.setOpaque(getAlpha(m_focused)); + if (FbTk::Transparent::haveComposite()) + m_window.setOpaque(getAlpha(m_focused)); + else { + // don't need to setAlpha, since apply updates them anyway + applyAll(); + clearAll(); + } } void FbWinFrame::setDoubleClickTime(unsigned int time) {