aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CurrentWindowCmd.cc30
-rw-r--r--src/CurrentWindowCmd.hh10
-rw-r--r--src/FbCommandFactory.cc25
-rw-r--r--src/FbWinFrame.cc19
4 files changed, 80 insertions, 4 deletions
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() { }
173void FullscreenCmd::real_execute() { 173void FullscreenCmd::real_execute() {
174 fbwindow().setFullscreen(!fbwindow().isFullscreen()); 174 fbwindow().setFullscreen(!fbwindow().isFullscreen());
175} 175}
176
177SetAlphaCmd::SetAlphaCmd(int focused, bool relative,
178 int unfocused, bool un_relative) :
179 m_focus(focused), m_unfocus(unfocused),
180 m_relative(relative), m_un_relative(un_relative) { }
181
182void SetAlphaCmd::real_execute() {
183 if (m_focus == 256 && m_unfocus == 256) {
184 // made up signal to return to default
185 fbwindow().setUseDefaultAlpha(true);
186 return;
187 }
188
189 int new_alpha;
190 if (m_relative) {
191 new_alpha = fbwindow().getFocusedAlpha() + m_focus;
192 if (new_alpha < 0) new_alpha = 0;
193 if (new_alpha > 255) new_alpha = 255;
194 fbwindow().setFocusedAlpha(new_alpha);
195 } else
196 fbwindow().setFocusedAlpha(m_focus);
197
198 if (m_un_relative) {
199 new_alpha = fbwindow().getUnfocusedAlpha() + m_unfocus;
200 if (new_alpha < 0) new_alpha = 0;
201 if (new_alpha > 255) new_alpha = 255;
202 fbwindow().setUnfocusedAlpha(new_alpha);
203 } else
204 fbwindow().setUnfocusedAlpha(m_unfocus);
205}
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:
197protected: 197protected:
198 void real_execute(); 198 void real_execute();
199}; 199};
200
201class SetAlphaCmd: public WindowHelperCmd {
202public:
203 SetAlphaCmd(int focus, bool rel, int unfocus, bool unrel);
204protected:
205 void real_execute();
206private:
207 int m_focus, m_unfocus;
208 int m_relative, m_un_relative;
209};
200#endif // CURRENTWINDOWCMD_HH 210#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() {
123 "sendtoworkspace", 123 "sendtoworkspace",
124 "sendtonextworkspace", 124 "sendtonextworkspace",
125 "sendtoprevworkspace", 125 "sendtoprevworkspace",
126 "setalpha",
126 "setenv", 127 "setenv",
127 "sethead", 128 "sethead",
128 "setmodkey", 129 "setmodkey",
@@ -247,7 +248,29 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
247 return new CurrentWindowCmd(&FluxboxWindow::maximizeVertical); 248 return new CurrentWindowCmd(&FluxboxWindow::maximizeVertical);
248 else if (command == "maximizehorizontal") 249 else if (command == "maximizehorizontal")
249 return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal); 250 return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal);
250 else if (command == "resize") { 251 else if (command == "setalpha") {
252 typedef vector<string> StringTokens;
253 StringTokens tokens;
254 FbTk::StringUtil::stringtok<StringTokens>(tokens, arguments);
255
256 int focused, unfocused;
257 bool relative, un_rel;
258
259 if (tokens.empty()) { // set default alpha
260 focused = unfocused = 256;
261 relative = un_rel = false;
262 } else {
263 relative = un_rel = (tokens[0][0] == '+' || tokens[0][0] == '-');
264 focused = unfocused = atoi(tokens[0].c_str());
265 }
266
267 if (tokens.size() > 1) { // set different unfocused alpha
268 un_rel = (tokens[1][0] == '+' || tokens[1][0] == '-');
269 unfocused = atoi(tokens[1].c_str());
270 }
271
272 return new SetAlphaCmd(focused, relative, unfocused, un_rel);
273 } else if (command == "resize") {
251 FbTk_istringstream is(arguments.c_str()); 274 FbTk_istringstream is(arguments.c_str());
252 int dx = 0, dy = 0; 275 int dx = 0, dy = 0;
253 is >> dx >> dy; 276 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) {
546 else 546 else
547 m_unfocused_alpha = alpha; 547 m_unfocused_alpha = alpha;
548 548
549 if (m_focused == focused) 549 if (m_focused == focused) {
550 m_window.setOpaque(alpha); 550 if (FbTk::Transparent::haveComposite())
551 m_window.setOpaque(alpha);
552 else {
553 // don't need to setAlpha, since apply updates them anyway
554 applyAll();
555 clearAll();
556 }
557 }
551} 558}
552 559
553unsigned char FbWinFrame::getAlpha(bool focused) const 560unsigned char FbWinFrame::getAlpha(bool focused) const
@@ -569,7 +576,13 @@ void FbWinFrame::setUseDefaultAlpha(bool default_alpha)
569 576
570 m_use_default_alpha = default_alpha; 577 m_use_default_alpha = default_alpha;
571 578
572 m_window.setOpaque(getAlpha(m_focused)); 579 if (FbTk::Transparent::haveComposite())
580 m_window.setOpaque(getAlpha(m_focused));
581 else {
582 // don't need to setAlpha, since apply updates them anyway
583 applyAll();
584 clearAll();
585 }
573} 586}
574 587
575void FbWinFrame::setDoubleClickTime(unsigned int time) { 588void FbWinFrame::setDoubleClickTime(unsigned int time) {