+static gboolean more_client_message_event(Window window, Atom msgtype)
+{
+ ObtXQueueWindowMessage wm;
+ wm.window = window;
+ wm.message = msgtype;
+ return xqueue_exists_local(xqueue_match_window_message, &wm);
+}
+
+struct ObSkipPropertyChange {
+ Window window;
+ Atom prop;
+};
+
+static gboolean skip_property_change(XEvent *e, gpointer data)
+{
+ const struct ObSkipPropertyChange s = *(struct ObSkipPropertyChange*)data;
+
+ if (e->type == PropertyNotify && e->xproperty.window == s.window) {
+ const Atom a = e->xproperty.atom;
+ const Atom b = s.prop;
+
+ /* these are all updated together */
+ if ((a == OBT_PROP_ATOM(NET_WM_NAME) ||
+ a == OBT_PROP_ATOM(WM_NAME) ||
+ a == OBT_PROP_ATOM(NET_WM_ICON_NAME) ||
+ a == OBT_PROP_ATOM(WM_ICON_NAME))
+ &&
+ (b == OBT_PROP_ATOM(NET_WM_NAME) ||
+ b == OBT_PROP_ATOM(WM_NAME) ||
+ b == OBT_PROP_ATOM(NET_WM_ICON_NAME) ||
+ b == OBT_PROP_ATOM(WM_ICON_NAME)))
+ {
+ return TRUE;
+ }
+ else if (a == b && a == OBT_PROP_ATOM(NET_WM_ICON))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void event_handle_client(ObClient *client, XEvent *e)
+{
+ Atom msgtype;
+ ObFrameContext con;
+ gboolean *but;
+ static gint px = -1, py = -1;
+ static guint pb = 0;
+ static ObFrameContext pcon = OB_FRAME_CONTEXT_NONE;
+
+ switch (e->type) {
+ case ButtonPress:
+ /* save where the press occured for the first button pressed */
+ if (!pb) {
+ pb = e->xbutton.button;
+ px = e->xbutton.x;
+ py = e->xbutton.y;
+
+ pcon = frame_context(client, e->xbutton.window, px, py);
+ pcon = mouse_button_frame_context(pcon, e->xbutton.button,
+ e->xbutton.state);
+ }
+ case ButtonRelease:
+ /* Wheel buttons don't draw because they are an instant click, so it
+ is a waste of resources to go drawing it.
+ if the user is doing an interactive thing, or has a menu open then
+ the mouse is grabbed (possibly) and if we get these events we don't
+ want to deal with them
+ */
+ if (!(e->xbutton.button == 4 || e->xbutton.button == 5) &&
+ !grab_on_keyboard())
+ {
+ /* use where the press occured */
+ con = frame_context(client, e->xbutton.window, px, py);
+ con = mouse_button_frame_context(con, e->xbutton.button,
+ e->xbutton.state);
+
+ /* button presses on CLIENT_CONTEXTs are not accompanied by a
+ release because they are Replayed to the client */
+ if ((e->type == ButtonRelease || CLIENT_CONTEXT(con, client)) &&
+ e->xbutton.button == pb)
+ pb = 0, px = py = -1, pcon = OB_FRAME_CONTEXT_NONE;
+
+ but = context_to_button(client->frame, con, TRUE);
+ if (but) {
+ *but = (e->type == ButtonPress);
+ frame_adjust_state(client->frame);
+ }
+ }
+ break;
+ case MotionNotify:
+ /* when there is a grab on the pointer, we won't get enter/leave
+ notifies, but we still get motion events */
+ if (grab_on_pointer()) break;
+
+ con = frame_context(client, e->xmotion.window,
+ e->xmotion.x, e->xmotion.y);
+ switch (con) {
+ case OB_FRAME_CONTEXT_TITLEBAR:
+ case OB_FRAME_CONTEXT_TLCORNER:
+ case OB_FRAME_CONTEXT_TRCORNER:
+ /* we've left the button area inside the titlebar */
+ if (client->frame->max_hover || client->frame->desk_hover ||
+ client->frame->shade_hover || client->frame->iconify_hover ||
+ client->frame->close_hover)
+ {
+ client->frame->max_hover =
+ client->frame->desk_hover =
+ client->frame->shade_hover =
+ client->frame->iconify_hover =
+ client->frame->close_hover = FALSE;
+ frame_adjust_state(client->frame);
+ }
+ break;
+ default:
+ but = context_to_button(client->frame, con, FALSE);
+ if (but && !*but && !pb) {
+ *but = TRUE;
+ frame_adjust_state(client->frame);
+ }
+ break;
+ }
+ break;
+ case LeaveNotify:
+ con = frame_context(client, e->xcrossing.window,
+ e->xcrossing.x, e->xcrossing.y);
+ switch (con) {
+ case OB_FRAME_CONTEXT_TITLEBAR:
+ case OB_FRAME_CONTEXT_TLCORNER:
+ case OB_FRAME_CONTEXT_TRCORNER:
+ /* we've left the button area inside the titlebar */
+ client->frame->max_hover =
+ client->frame->desk_hover =
+ client->frame->shade_hover =
+ client->frame->iconify_hover =
+ client->frame->close_hover = FALSE;
+ if (e->xcrossing.mode == NotifyGrab) {
+ client->frame->max_press =
+ client->frame->desk_press =
+ client->frame->shade_press =
+ client->frame->iconify_press =
+ client->frame->close_press = FALSE;
+ }
+ break;
+ case OB_FRAME_CONTEXT_FRAME:
+ /* When the mouse leaves an animating window, don't use the
+ corresponding enter events. Pretend like the animating window
+ doesn't even exist..! */
+ if (frame_iconify_animating(client->frame))
+ event_end_ignore_all_enters(event_start_ignore_all_enters());
+
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "%sNotify mode %d detail %d on %lx",
+ (e->type == EnterNotify ? "Enter" : "Leave"),
+ e->xcrossing.mode,
+ e->xcrossing.detail, (client?client->window:0));
+ if (grab_on_keyboard())
+ break;
+ if (config_focus_follow &&
+ /* leave inferior events can happen when the mouse goes onto
+ the window's border and then into the window before the
+ delay is up */
+ e->xcrossing.detail != NotifyInferior)