summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-08-06 06:40:18 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-08-06 06:40:18 (GMT)
commitc52a84a1704a2963b3d454a43617d8911778fb72 (patch)
tree256f5d56ab4e19912661e383fc645de57f642432 /src
parent9e259590a2a59b89471bf3f42366c2209c69bf9c (diff)
downloadfluxbox_lack-c52a84a1704a2963b3d454a43617d8911778fb72.zip
fluxbox_lack-c52a84a1704a2963b3d454a43617d8911778fb72.tar.bz2
make wallpapers do The Right Thing (tm)
Diffstat (limited to 'src')
-rw-r--r--src/RootTheme.cc74
-rw-r--r--src/RootTheme.hh2
2 files changed, 37 insertions, 39 deletions
diff --git a/src/RootTheme.cc b/src/RootTheme.cc
index 617c3d5..c09957f 100644
--- a/src/RootTheme.cc
+++ b/src/RootTheme.cc
@@ -150,7 +150,8 @@ RootTheme::RootTheme(FbTk::ImageControl &image_control):
150 FbTk::Theme(image_control.screenNumber()), 150 FbTk::Theme(image_control.screenNumber()),
151 m_background(new BackgroundItem(*this, "background", "Background")), 151 m_background(new BackgroundItem(*this, "background", "Background")),
152 m_opgc(RootWindow(FbTk::App::instance()->display(), image_control.screenNumber())), 152 m_opgc(RootWindow(FbTk::App::instance()->display(), image_control.screenNumber())),
153 m_image_ctrl(image_control) { 153 m_image_ctrl(image_control),
154 m_first(true) {
154 155
155 Display *disp = FbTk::App::instance()->display(); 156 Display *disp = FbTk::App::instance()->display();
156 m_opgc.setForeground(WhitePixel(disp, screenNum())^BlackPixel(disp, screenNum())); 157 m_opgc.setForeground(WhitePixel(disp, screenNum())^BlackPixel(disp, screenNum()));
@@ -183,10 +184,6 @@ void RootTheme::reconfigTheme() {
183 if (!m_background->changed()) 184 if (!m_background->changed())
184 return; 185 return;
185 186
186 // style doesn't wish to change the background
187 if (strstr(m_background->options().c_str(), "none") != 0)
188 return;
189
190 // 187 //
191 // Else parse background from style 188 // Else parse background from style
192 // 189 //
@@ -197,37 +194,35 @@ void RootTheme::reconfigTheme() {
197 std::string filename = m_background->filename(); 194 std::string filename = m_background->filename();
198 FbTk::StringUtil::removeTrailingWhitespace(filename); 195 FbTk::StringUtil::removeTrailingWhitespace(filename);
199 FbTk::StringUtil::removeFirstWhitespace(filename); 196 FbTk::StringUtil::removeFirstWhitespace(filename);
197
200 // if background argument is a file then 198 // if background argument is a file then
201 // parse image options and call image setting 199 // parse image options and call image setting
202 // command specified in the resources 200 // command specified in the resources
203 filename = FbTk::StringUtil::expandFilename(filename); 201 filename = FbTk::StringUtil::expandFilename(filename);
204 if (FbTk::FileUtil::isRegularFile(filename.c_str())) { 202 std::string cmd = realProgramName("fbsetbg") + (m_first ? " -z " : " -Z ");
203
204 // style doesn't wish to change the background
205 if (strstr(m_background->options().c_str(), "none") != 0) {
206 if (!m_first)
207 return;
208 } else if (FbTk::FileUtil::isRegularFile(filename.c_str())) {
205 // parse options 209 // parse options
206 std::string options = "-F ";
207 if (strstr(m_background->options().c_str(), "tiled") != 0) 210 if (strstr(m_background->options().c_str(), "tiled") != 0)
208 options = "-T "; 211 cmd += "-t ";
209 if (strstr(m_background->options().c_str(), "centered") != 0) 212 else if (strstr(m_background->options().c_str(), "centered") != 0)
210 options = "-C "; 213 cmd += "-c ";
211 if (strstr(m_background->options().c_str(), "aspect") != 0) 214 else if (strstr(m_background->options().c_str(), "aspect") != 0)
212 options = "-A "; 215 cmd += "-a ";
213 216 else
214 // compose wallpaper application "fbsetbg" with argumetns 217 cmd += "-f ";
215 std::string commandargs = realProgramName("fbsetbg") + " " + options + 218
216 filename; 219 cmd += filename;
217
218 // call command with options
219 FbCommands::ExecuteCmd exec(commandargs, screenNum());
220 exec.execute();
221
222 } else if (FbTk::FileUtil::isDirectory(filename.c_str()) && 220 } else if (FbTk::FileUtil::isDirectory(filename.c_str()) &&
223 strstr(m_background->options().c_str(), "random") != 0) { 221 strstr(m_background->options().c_str(), "random") != 0) {
224 std::string commandargs = realProgramName("fbsetbg") + " -R " + 222 cmd += "-r " + filename;
225 filename;
226 FbCommands::ExecuteCmd exec(commandargs, screenNum());
227 exec.execute();
228 } else { 223 } else {
229 // render normal texture with fbsetroot 224 // render normal texture with fbsetroot
230 225 cmd += "-b ";
231 226
232 // Make sure the color strings are valid, 227 // Make sure the color strings are valid,
233 // so we dont pass any `commands` that can be executed 228 // so we dont pass any `commands` that can be executed
@@ -240,23 +235,26 @@ void RootTheme::reconfigTheme() {
240 235
241 std::string options; 236 std::string options;
242 if (color_valid) 237 if (color_valid)
243 options += "-foreground '" + m_background->colorString() + "' "; 238 cmd += "-foreground '" + m_background->colorString() + "' ";
244 if (color_to_valid) 239 if (color_to_valid)
245 options += "-background '" + m_background->colorToString() + "' "; 240 cmd += "-background '" + m_background->colorToString() + "' ";
246 241
247 if (strstr(m_background->options().c_str(), "mod") != 0) 242 if (strstr(m_background->options().c_str(), "mod") != 0)
248 options += "-mod " + m_background->modX() + " " + m_background->modY(); 243 cmd += "-mod " + m_background->modX() + " " + m_background->modY();
249 else if ((*m_background)->type() & FbTk::Texture::SOLID && color_valid) 244 else if ((*m_background)->type() & FbTk::Texture::SOLID && color_valid)
250 options += "-solid '" + m_background->colorString() + "' "; 245 cmd += "-solid '" + m_background->colorString() + "' ";
251
252 else if ((*m_background)->type() & FbTk::Texture::GRADIENT) { 246 else if ((*m_background)->type() & FbTk::Texture::GRADIENT) {
253 options += "-gradient '" + m_background->options() + "'"; 247 // remove whitespace from the options, since fbsetroot doesn't care
248 // and dealing with sh and fbsetbg is impossible if we don't
249 std::string options = m_background->options();
250 options = FbTk::StringUtil::replaceString(options, " ", "");
251 options = FbTk::StringUtil::replaceString(options, "\t", "");
252 cmd += "-gradient " + options;
254 } 253 }
255
256 std::string commandargs = realProgramName("fbsetroot") + " " + options;
257
258 FbCommands::ExecuteCmd exec(commandargs, screenNum());
259 exec.execute();
260 } 254 }
261 255
256 // call command with options
257 FbCommands::ExecuteCmd exec(cmd, screenNum());
258 m_first = false;
259 exec.execute();
262} 260}
diff --git a/src/RootTheme.hh b/src/RootTheme.hh
index 5ae5165..09c752c 100644
--- a/src/RootTheme.hh
+++ b/src/RootTheme.hh
@@ -64,7 +64,7 @@ private:
64 BackgroundItem *m_background;///< background image/texture 64 BackgroundItem *m_background;///< background image/texture
65 FbTk::GContext m_opgc; 65 FbTk::GContext m_opgc;
66 FbTk::ImageControl &m_image_ctrl; ///< image control for rendering background texture 66 FbTk::ImageControl &m_image_ctrl; ///< image control for rendering background texture
67 67 bool m_first;
68}; 68};
69 69
70#endif // ROOTTHEME_HH 70#endif // ROOTTHEME_HH