From 2b25b05b27a0d4735ace950d667510bb4cf309b7 Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 2 Feb 2007 19:04:57 +0000 Subject: added SetAlpha key command --- ChangeLog | 11 +++++++++++ src/CurrentWindowCmd.cc | 30 ++++++++++++++++++++++++++++++ src/CurrentWindowCmd.hh | 10 ++++++++++ src/FbCommandFactory.cc | 25 ++++++++++++++++++++++++- src/FbWinFrame.cc | 19 ++++++++++++++++--- 5 files changed, 91 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 278079f..61408c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 [[+-] [[+-]]] (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 diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index a975bdd..fcc141b 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/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); +} diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index d013b24..c1b9140 100644 --- a/src/CurrentWindowCmd.hh +++ b/src/CurrentWindowCmd.hh @@ -197,4 +197,14 @@ public: 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 diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc index ece8c9e..b82332a 100644 --- a/src/FbCommandFactory.cc +++ b/src/FbCommandFactory.cc @@ -123,6 +123,7 @@ FbCommandFactory::FbCommandFactory() { "sendtoworkspace", "sendtonextworkspace", "sendtoprevworkspace", + "setalpha", "setenv", "sethead", "setmodkey", @@ -247,7 +248,29 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, return new CurrentWindowCmd(&FluxboxWindow::maximizeVertical); else if (command == "maximizehorizontal") return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal); - else if (command == "resize") { + else if (command == "setalpha") { + typedef vector StringTokens; + StringTokens tokens; + FbTk::StringUtil::stringtok(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; diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 30d8389..e78ed5f 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -546,8 +546,15 @@ void FbWinFrame::setAlpha(bool focused, unsigned char 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 @@ void FbWinFrame::setUseDefaultAlpha(bool default_alpha) 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) { -- cgit v0.11.2