From 5284410840bcd67946551c2aac95dc077f5c22cf Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Thu, 20 Sep 2007 08:47:50 +0000 Subject: [PATCH] After splash would finish, evoke would ignore first request to run external command, althought second and rest would be fine. That is hopefully fixed now. Splash window still gets hidden by old eiconman; for other apps it is fine. Pending for revision. --- evoke/EvokeService.cpp | 11 ++++++--- evoke/EvokeService.h | 5 ---- evoke/Jamfile | 12 ++++++++-- evoke/Spawn.cpp | 15 +++++------- evoke/Splash.cpp | 52 +++++++++++++++++++++++++----------------- 5 files changed, 55 insertions(+), 40 deletions(-) diff --git a/evoke/EvokeService.cpp b/evoke/EvokeService.cpp index 033ac8f..a3a75aa 100644 --- a/evoke/EvokeService.cpp +++ b/evoke/EvokeService.cpp @@ -196,7 +196,7 @@ void service_watcher_cb(int pid, int signum) { } EvokeService::EvokeService() : - is_running(0), logfile(NULL), xsm(NULL), pidfile(NULL), lockfile(NULL), top_win(NULL) { + is_running(0), logfile(NULL), xsm(NULL), pidfile(NULL), lockfile(NULL) { } EvokeService::~EvokeService() { @@ -745,7 +745,10 @@ int EvokeService::handle(const XEvent* xev) { EVOKE_LOG("XSETTINGS manager shutdown\n"); stop_xsettings_manager(); // return 1; - } else if(xev->type == MapNotify) { + } +#if 0 + else if(xev->type == MapNotify) { + puts("================="); if(top_win) { // for splash to keep it at top (working in old edewm) XRaiseWindow(fl_display, fl_xid(top_win)); @@ -757,7 +760,9 @@ int EvokeService::handle(const XEvent* xev) { XRaiseWindow(fl_display, fl_xid(top_win)); // return 1; } - } else if(xev->type == PropertyNotify) { + } +#endif + else if(xev->type == PropertyNotify) { if(xev->xproperty.atom == _ede_spawn) { char buff[1024]; if(get_string_property_value(_ede_spawn, buff, sizeof(buff))) { diff --git a/evoke/EvokeService.h b/evoke/EvokeService.h index a3cef4d..5e918bd 100644 --- a/evoke/EvokeService.h +++ b/evoke/EvokeService.h @@ -52,8 +52,6 @@ class EvokeService { char* pidfile; char* lockfile; - Fl_Double_Window* top_win; - Atom _ede_shutdown_all; Atom _ede_spawn; Atom _ede_evoke_quit; @@ -83,9 +81,6 @@ class EvokeService { Log* log(void) { return logfile; } - void register_top(Fl_Double_Window* win) { top_win = win; } - void unregister_top(void) { top_win = NULL; } - void service_watcher(int pid, int signum); void run_program(const char* cmd, bool enable_vars = 1); //void heuristic_run_program(const char* cmd); diff --git a/evoke/Jamfile b/evoke/Jamfile index ee0451e..922946d 100644 --- a/evoke/Jamfile +++ b/evoke/Jamfile @@ -13,9 +13,17 @@ SubDir TOP evoke ; # use SIGHUP for now as default ObjectC++Flags evoke.cpp : -DUSE_SIGHUP ; -SOURCE = evoke.cpp EvokeService.cpp Xsm.cpp Spawn.cpp Splash.cpp Log.cpp Logout.cpp Crash.cpp Autostart.cpp ; +SOURCE = evoke.cpp + EvokeService.cpp + Xsm.cpp + Spawn.cpp + Splash.cpp + Log.cpp + Logout.cpp + Crash.cpp + Autostart.cpp ; -LinkAgainst evoke : -lao -lvorbis -lvorbisfile -lmad ; +LinkAgainst evoke : -lao -lvorbis -lvorbisfile ; EdeProgram evoke : $(SOURCE) ; FltkProgramBare test/evoke_test : test/evoke_test.cpp ; diff --git a/evoke/Spawn.cpp b/evoke/Spawn.cpp index 574ef22..a70ebca 100644 --- a/evoke/Spawn.cpp +++ b/evoke/Spawn.cpp @@ -56,18 +56,15 @@ int spawn_program(const char* cmd, SignalWatch wf, pid_t* child_pid_ret, const c int nulldev = -1; int status_ret = 0; - if(wf) { - struct sigaction sa; - sa.sa_handler = sigchld_handler; - sa.sa_flags = SA_NOCLDSTOP; - sigemptyset(&sa.sa_mask); - sigaction(SIGCHLD, &sa, (struct sigaction*)0); + struct sigaction sa; + sa.sa_handler = sigchld_handler; + sa.sa_flags = SA_NOCLDSTOP; + sigemptyset(&sa.sa_mask); + sigaction(SIGCHLD, &sa, (struct sigaction*)0); - global_watch = wf; - } + global_watch = wf; pid_t pid = fork(); - if(pid == -1) return SPAWN_FORK_FAILED; diff --git a/evoke/Splash.cpp b/evoke/Splash.cpp index eb45a3c..1f4d060 100644 --- a/evoke/Splash.cpp +++ b/evoke/Splash.cpp @@ -26,11 +26,21 @@ #define TIMEOUT_START 0.5 // timeout when splash is first time shown (also for first client) #define TIMEOUT_CONTINUE 2.0 // timeout between starting rest of the cliens -#if 0 -int splash_xmessage_handler(int ev) { - return EvokeService::instance()->handle(fl_xevent); + +extern void service_watcher_cb(int pid, int signum); + +Fl_Double_Window* splash_win = 0; + +int splash_xmessage_handler(int e) { + if(fl_xevent->type == MapNotify || fl_xevent->type == ConfigureNotify) { + if(splash_win) { + XRaiseWindow(fl_display, fl_xid(splash_win)); + return 1; + } + } + + return 0; } -#endif /* * repeatedly call runner() untill all clients are @@ -54,6 +64,7 @@ Splash::~Splash() { EVOKE_LOG("Cleaning splash data\n"); // elements of icons cleans Fl_Group delete [] icons; + Fl::remove_timeout(runner_cb); } @@ -175,39 +186,36 @@ void Splash::run(void) { int sh = DisplayHeight(fl_display, fl_screen); position(sw/2 - w()/2, sh/2 - h()/2); + bool sound_loaded = false; if(sound && !sound->empty()) - edelib::SoundSystem::init(); + sound_loaded = edelib::SoundSystem::init(); show(); Fl::add_timeout(TIMEOUT_START, runner_cb, this); - // FIXME: validate this again ! -#if 0 /* - * Fl::wait() will block all events to EvokeService and it will not - * be able to keep this window at the top. So we again select event inputs - * and redirect them to EvokeService::handle(). + * Force keeping splash window at the top of all. To do this, we will listen + * MappingNotify and ConfigureNotify events, and when they be triggered we will + * raise splash window. */ - XSelectInput(fl_display, RootWindow(fl_display, fl_screen), SubstructureNotifyMask); - Fl::add_handler(splash_xmessage_handler); -#endif + splash_win = this; - // make sure MappingNotify keeps this window at the top - EvokeService::instance()->register_top(this); + //XSelectInput(fl_display, RootWindow(fl_display, fl_screen), SubstructureNotifyMask); + //Fl::add_handler(splash_xmessage_handler); - if(edelib::SoundSystem::inited()) + if(sound_loaded) edelib::SoundSystem::play(sound->c_str(), 0); while(shown()) Fl::wait(); - EvokeService::instance()->unregister_top(); - - if(edelib::SoundSystem::inited()) { + if(sound_loaded) { edelib::SoundSystem::stop(); edelib::SoundSystem::shutdown(); } + + splash_win = 0; } // called when splash option is on @@ -236,7 +244,8 @@ bool Splash::next_client(void) { redraw(); if(!dry_run) - spawn_program(cmd); + spawn_program(cmd, service_watcher_cb); + //spawn_program(cmd); ++clist_it; ++counter; @@ -266,7 +275,8 @@ bool Splash::next_client_nosplash(void) { printf("%s\n", buff); if(!dry_run) - spawn_program(cmd); + spawn_program(cmd, service_watcher_cb); + //spawn_program(cmd); ++clist_it; ++counter;