Comment 5 for bug 1459671

Revision history for this message
Guilherme Quentel Melo (gqmelo) wrote : Re: focus goes to the wrong window after a modal dialog is closed

I decided to investigate this problem and checked out the source code. After a lot of debugging I found out that the call to focus the wrong window is coming from compiz CompScreenImpl::focusDefaultWindow which comes from this code on compiz event.cpp :

  else if (event->xfocus.window == privateScreen.rootWindow())
  {
      /* Don't ever let the focus go to the root
       * window except in grab cases
       *
       * FIXME: There might be a case where we have to
       * handle root windows of other screens here, but
       * the other window managers should handle that
       */

      if (event->xfocus.detail == NotifyDetailNone ||
   (event->xfocus.mode == NotifyNormal &&
    event->xfocus.detail == NotifyInferior))
      {
   privateScreen.orphanData.activeWindow = None;

   if (event->xfocus.detail == NotifyDetailNone ||
       (event->xfocus.mode == NotifyNormal &&
        event->xfocus.detail == NotifyInferior))
   {
       screen->focusDefaultWindow ();
   }
      }
  }

The FIXME comment is very suspicious but I have no idea what would be the solution.
I'm adding an attachment file with the stacktrace.