Esempio n. 1
0
int should_discard_event(XEvent *ev) {
    int ret_val = FALSE;
    if ((is_focus_out(ev)) || (should_ignore_focus_in(ev))) {
        ret_val = TRUE;
    }
    // Remember, for next time, if we encountered a focus in event
    // and do not relay it.
    identify_focus_in_event(ev);
    return ret_val;
}
Esempio n. 2
0
int should_discard_focus_out_event(FocusKeepStatus* stat, Display* dpy,
                                   XEvent *ev)
{
  int ret_val = FALSE;
  if (is_focus_out(ev) == FALSE) {
    return FALSE;
  }

  const int detail = ev->xfocus.detail;

  if (stat->new_window != 0) {
    /*
    if (!(event_on_active_or_adj_window(dpy, ev, stat->new_window)
        || event_on_active_or_adj_window(dpy, ev, get_active_window(stat)))) {
      LOG( "ERROR - Event on window %#lx, which is neither new nor active.\n",
           extract_window_id(ev));
    } else */ {
      LOG("Event on new/active (%#lx) during new window creation, allowing.",
          extract_window_id(ev));
      LOG(" New: %#lx Active: %#lx\n", stat->new_window, stat->active_window);
    }
    return FALSE;
  }

  if (event_on_active_or_adj_window(dpy, ev, get_active_window(stat))) {
    // If moving ownership between sub-windows of the same Firefox window.
    if ((detail == NotifyAncestor) || (detail == NotifyInferior)) {
      // Allow this one.
      LOG("Focus will move to ancestor / inferior (%d). Allowing.\n", detail);
      stat->encountered_focus_in_event = FALSE;
    } else {
      // Disallow transfer of focus to outside windows.
      if (!stat->active_window_from_close) {
        ret_val = TRUE;
      } else {
        LOG("FocusOut event, but active window from close. Not discarding.\n");
      }
    }
  } else {
    LOG("Got Focus out event on window %#lx but active window is %#lx\n",
        extract_window_id(ev), get_active_window(stat));
  }

  return ret_val;
}