I think I fixed the problem with a workaround.
This situation is probably a result from a mess in the window manager or in the 
X server.
My main window was suddenly closed and looking at the code I saw:
int fl_handle(const XEvent& thisevent)
{
..
..
case ClientMessage: {
    Atom message = fl_xevent->xclient.message_type;
    const long* data = fl_xevent->xclient.data.l;
    if ((Atom)(data[0]) == WM_DELETE_WINDOW) {
      event = FL_CLOSE;
    } else if (message == fl_XdndEnter) {
      fl_xmousewin = window;
      in_a_window = true;
      fl_dnd_source_window = data[0];
..
..
}
So that is the only way I can get my window closed by FL_CLOSE.(Which was the 
case).
Going forward with the code we have:

int Fl::handle(int e, Fl_Window* window)
  e_number = e;
  if (fl_local_grab) return fl_local_grab(e);

  Fl_Widget* wi = window;

  switch (e) {

  case FL_CLOSE:
    if (grab() || modal() && window != modal()) return 0;
    wi->do_callback();
    return 1;
..

And the default callback for Fl_Window classes is:

void Fl::default_atclose(Fl_Window* window, void* v) {
  window->hide();
  Fl_Widget::default_callback(window, v); // put on Fl::read_queue()
}

void (*Fl::atclose)(Fl_Window*, void*) = default_atclose;

void Fl_Window::default_callback(Fl_Window* win, void* v) {
  Fl::atclose(win, v);
}

void Fl_Widget::default_callback(Fl_Widget *o, void * /*v*/) {
  obj_queue[obj_head++] = o;
  if (obj_head >= QUEUE_SIZE) obj_head = 0;
  if (obj_head == obj_tail) {
    obj_tail++;
    if (obj_tail >= QUEUE_SIZE) obj_tail = 0;
  }
}


So, my workaround was to set a callback in my mainwindow, that should never 
close, that does nothing besides ensure that mainwindow is active( 
this->show(); ). My intention here is to create a window that never gets 
closed. This solution appears to be working.
The cause is related with WM_DELETE_WINDOW which I believe being from Window 
Manager.
Just to explain, my application has a lot of windows... so the key generator 
keeps opening and closing those windows, what probably should confuse WM or X.

Thanks,
J.Marcelo Auler




_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to