added SetAlpha key command
This commit is contained in:
parent
de9ac12895
commit
2b25b05b27
5 changed files with 91 additions and 4 deletions
11
ChangeLog
11
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 [[+-]<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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue