Fixed issues with add_fd() addon. Dialogs popped up, especially from

service_watcher() would not be drawn correctly yielding program hang since
add_fd() would not send events to fltk.

Also commented hack from Splash to keep it's window at the top of all;
now, using add_fd() evoke will get events before fltk which is what I want.
Not tested with other wm's.

Note: enabling that hack will surely crash evoke unless fl_handle() is removed
from main evoke loop.
This commit is contained in:
Sanel Zukan 2007-09-18 15:43:01 +00:00
parent ad69c2fc2c
commit 04a87a7f7c
4 changed files with 48 additions and 27 deletions

View File

@ -55,7 +55,7 @@ void resolve_path(const edelib::String& datadir, edelib::String& item, bool have
char* get_basename(const char* path) {
char* p = strrchr(path, '/');
if(p)
if(p)
return (p + 1);
return (char*)path;
@ -718,62 +718,74 @@ bool EvokeService::find_and_unregister_process(pid_t pid, EvokeProcess& pc) {
return 0;
}
int EvokeService::handle(const XEvent* ev) {
logfile->printf("Got event %i\n", ev->type);
/*
* Main loop for processing got X events.
*
* Great care must be taken to route this events to fltk too (via fl_handle()), since
* add_fd() (in evoke.cpp) will not do that. If events are not routed to fltk, popped
* dialogs, especially from service_watcher() will not be correctly drawn and will hand
* whole program.
*
* FIXME: any better way ?
*/
int EvokeService::handle(const XEvent* xev) {
EVOKE_LOG("Got event %i\n", xev->type);
if(xsm && xsm->should_quit(ev)) {
if(xsm && xsm->should_quit(xev)) {
EVOKE_LOG("XSETTINGS manager shutdown\n");
stop_xsettings_manager();
return 1;
} else if(ev->type == MapNotify) {
// return 1;
} else if(xev->type == MapNotify) {
if(top_win) {
// for splash to keep it at top (working in old edewm)
XRaiseWindow(fl_display, fl_xid(top_win));
return 1;
// return 1;
}
} else if(ev->type == ConfigureNotify) {
if(ev->xconfigure.event == DefaultRootWindow(fl_display) && top_win) {
} else if(xev->type == ConfigureNotify) {
if(xev->xconfigure.event == DefaultRootWindow(fl_display) && top_win) {
// splash too, but keep window under other wm's
XRaiseWindow(fl_display, fl_xid(top_win));
return 1;
// return 1;
}
} else if(ev->type == PropertyNotify) {
if(ev->xproperty.atom == _ede_spawn) {
} else if(xev->type == PropertyNotify) {
if(xev->xproperty.atom == _ede_spawn) {
char buff[1024];
if(get_string_property_value(_ede_spawn, buff, sizeof(buff))) {
logfile->printf("Got _EDE_EVOKE_SPAWN with %s. Starting client...\n", buff);
EVOKE_LOG("Got _EDE_EVOKE_SPAWN with %s. Starting client...\n", buff);
run_program(buff);
//heuristic_run_program(buff);
} else {
logfile->printf("Got _EDE_EVOKE_SPAWN with malformed data. Ignoring...\n");
EVOKE_LOG("Got _EDE_EVOKE_SPAWN with malformed data. Ignoring...\n");
}
return 1;
// return 1;
}
if(ev->xproperty.atom == _ede_evoke_quit) {
if(xev->xproperty.atom == _ede_evoke_quit) {
int val = get_int_property_value(_ede_evoke_quit);
if(val == 1) {
logfile->printf("Got accepted _EDE_EVOKE_QUIT\n");
EVOKE_LOG("Got accepted _EDE_EVOKE_QUIT\n");
stop();
} else
logfile->printf("Got _EDE_EVOKE_QUIT with bad code (%i). Ignoring...\n", val);
return 1;
EVOKE_LOG("Got _EDE_EVOKE_QUIT with bad code (%i). Ignoring...\n", val);
// return 1;
}
if(ev->xproperty.atom == _ede_shutdown_all) {
if(xev->xproperty.atom == _ede_shutdown_all) {
int val = get_int_property_value(_ede_shutdown_all);
if(val == 1) {
logfile->printf("Got accepted _EDE_EVOKE_SHUTDOWN_ALL\n");
EVOKE_LOG("Got accepted _EDE_EVOKE_SHUTDOWN_ALL\n");
int dw = DisplayWidth(fl_display, fl_screen);
int dh = DisplayHeight(fl_display, fl_screen);
// TODO: add XDM service permissions
printf("got %i\n", logout_dialog(dw, dh, 1, 1));
//quit_x11();
} else
logfile->printf("Got _EDE_EVOKE_SHUTDOWN_ALL with bad code (%i). Ignoring...\n", val);
return 1;
EVOKE_LOG("Got _EDE_EVOKE_SHUTDOWN_ALL with bad code (%i). Ignoring...\n", val);
// return 1;
}
}
return 0;
//return 0;
return fl_handle(*xev);
}

View File

@ -26,10 +26,11 @@
#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);
}
#endif
/*
* repeatedly call runner() untill all clients are
@ -181,6 +182,8 @@ void Splash::run(void) {
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
@ -188,6 +191,7 @@ void Splash::run(void) {
*/
XSelectInput(fl_display, RootWindow(fl_display, fl_screen), SubstructureNotifyMask);
Fl::add_handler(splash_xmessage_handler);
#endif
// make sure MappingNotify keeps this window at the top
EvokeService::instance()->register_top(this);

View File

@ -145,7 +145,6 @@ bool Xsm::should_quit(const XEvent* xev) {
if(xev->xany.window == data->window &&
xev->xany.type == SelectionClear &&
xev->xselectionclear.selection == data->selection_atom) {
puts("XXXXXXXXXXXXX");
return true;
}

View File

@ -48,6 +48,11 @@ void xmessage_handler(int, void*) {
}
}
int xmessage_handler2(int e) {
return EvokeService::instance()->handle(fl_xevent);
}
const char* next_param(int curr, char** argv, int argc) {
int j = curr + 1;
if(j >= argc)
@ -202,6 +207,7 @@ int main(int argc, char** argv) {
* Also note that '1' parameter means POLLIN, and for the details see Fl_x.cxx
*/
Fl::add_fd(ConnectionNumber(fl_display), 1, xmessage_handler);
//Fl::add_handler(xmessage_handler2);
while(service->running())
Fl::wait(FOREVER);