![]() |
| | #1 |
| Registered User Join Date: Oct 2003
Posts: 92
| Daemon problem Assume for 00:00 time, you are in workspace ( ws ) 2, you got Spiderman2.png wallpaper. If you change to ws 1, you will get Britney.png wallpaper, if you change to ws3, you will get Donald.png. But you don't change the ws. you just wait one minute. 01:00. Now you wallpaper change in your current ws( that is number 2 ) to Superman.jpg. If you change to ws 1, you will get Madonna.png wallpaper not Britney anymore, if you change to ws3, you will get MickeyMouse.png not Donald anymore. What is the best way to randomize this list? Threads? So for this case, I am making three threads. Thread 1 randomize 4 wallpapers. Thread 2 randomize 3 wallpapers. Thread 3 randomize 2 wallpapers. Or just forking the child process? That is question number one. This is the rough daemon source code: Code: string wallpaper;
int workspace, dump;
const int forever = 1;
while( forever )
{
//check if the workspace change
workspace = whatWorkspaceIsIt();
//if still the same
if( previous_workspace == workspace )
{
//check if has passed 60 seconds
dump = getCurrentTime() - previousTime;
if( dump >= 60 )
{
//here we ask the information from thread or child process that randomize
wallpaper = getCurrentWallpaper( workspace );
changeTheWallpaper( wallpaper );
previousTime = getCurrentTime();
}
}
else
{
previousTime = getCurrentTime();
wallpaper = getCurrentWallpaper( workspace );
changeTheWallpaper( wallpaper );
}
previous_workspace = workspace;
}
Ideally it would be better if I can hacked the workspace swithcer source code. So the wallpaper changer is included in workspace switcher. So if you change the workspace , it will automatically change the wallpaper. But it is in C. And I am still newbie...... And it is not easy to read somebody sourcecode.
__________________ A man asked, "Who are you?" Buddha answered, "I am awaked." |
| gandalf_bar is offline | |
| | #2 |
| Obsessed with C Join Date: Jan 2003
Posts: 501
| It took up too much cpu because it is always comparing dump to 60. What you should do, when you know sixty seconds has elapsed, tell your daemon to sleep for 60 seconds. This way your program won't get scheduled and won't check dump to 60 until at least 60 seconds has passed. Do you see what I am saying?
__________________ Help populate a c/c++ help irc channel server: irc://irc.efnet.net channel: #c |
| chrismiceli is offline | |
| | #3 |
| Registered User Join Date: Oct 2003
Posts: 92
| The problem is.... when I use your approach.... : 00:00, I am in ws 2.... my wallpaper is Superman.jpg now. If I wait for 60 seconds ( my daemon sleep for 60 seconds ) and I don't change ws, that would be no problem. Then my daemon wake up after 60 seconds. 01:00. Ok, time to change wallpaper now. Now my wallpaper is SpiderMan2.png. Happily ever after. Now here's come the problem: If after 15 seconds, that is 00:15, I change to ws 1, the daemon didn't change wallpaper because it is still sleeping ( it is still under 60 seconds ). But it <b> should </b> change the wallpaper to Britney.jpg or Madonna.png. Or if I change to ws 3 after 15 seconds ( under 60 seconds ), it <b> should </b> change the wallpaper to Donald.jpg or MickeyMouse.png. But it didn't because the daemon is still sleeping. That is the problem. ws = workspace or virtual desktop wallpaper in workspace 1 = Britney.jpg, Madonna.png ( hot chick wallpapers ) wallpaper in workspace 2 = Superman.jpg, SpiderMan2.png ( superhero wallpapers ) wallpaper in workspace 3 = Donald.jpg, MickeyMouse.png ( cartoon wallpapers )
__________________ A man asked, "Who are you?" Buddha answered, "I am awaked." |
| gandalf_bar is offline | |
| | #4 |
| Obsessed with C Join Date: Jan 2003
Posts: 501
| Then you need to wake your program with a signal when you change from a ws then. I don't know how you would go about doing that, though.
__________________ Help populate a c/c++ help irc channel server: irc://irc.efnet.net channel: #c |
| chrismiceli is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| daemon problem please help | fairyjerry14 | C Programming | 2 | 09-07-2007 02:43 AM |
| Someone having same problem with Code Block? | ofayto | C++ Programming | 1 | 07-12-2007 08:38 AM |
| A question related to strcmp | meili100 | C++ Programming | 6 | 07-07-2007 02:51 PM |
| WS_POPUP, continuation of old problem | blurrymadness | Windows Programming | 1 | 04-20-2007 06:54 PM |
| Laptop Problem | Boomba | Tech Board | 1 | 03-07-2006 06:24 PM |