}
}
-static gboolean wanted_focusevent(XEvent *e)
+static gboolean wanted_focusevent(XEvent *e, gboolean in_client_only)
{
gint mode = e->xfocus.mode;
gint detail = e->xfocus.detail;
Window win = e->xany.window;
if (e->type == FocusIn) {
-
/* These are ones we never want.. */
/* This means focus was given by a keyboard/mouse grab. */
/* These are the ones we want.. */
- if (win == RootWindow(ob_display, ob_screen)) {
+ if (win == RootWindow(ob_display, ob_screen) && !in_client_only) {
/* This means focus reverted off of a client */
if (detail == NotifyPointerRoot || detail == NotifyDetailNone ||
detail == NotifyInferior)
/* This means focus moved from one client to another */
if (detail == NotifyNonlinearVirtual)
return TRUE;
+ /* This means focus moved to the frame window */
+ if (detail == NotifyInferior && !in_client_only)
+ return TRUE;
/* Otherwise.. */
return FALSE;
} else {
g_assert(e->type == FocusOut);
-
/* These are ones we never want.. */
/* This means focus was taken by a keyboard/mouse grab. */
static Bool look_for_focusin(Display *d, XEvent *e, XPointer arg)
{
- return e->type == FocusIn && wanted_focusevent(e);
+ return e->type == FocusIn && wanted_focusevent(e, FALSE);
+}
+
+static Bool look_for_focusin_client(Display *d, XEvent *e, XPointer arg)
+{
+ return e->type == FocusIn && wanted_focusevent(e, TRUE);
+}
+
+static void print_focusevent(XEvent *e)
+{
+ gint mode = e->xfocus.mode;
+ gint detail = e->xfocus.detail;
+ Window win = e->xany.window;
+ const gchar *modestr, *detailstr;
+
+ switch (mode) {
+ case NotifyNormal: modestr="NotifyNormal"; break;
+ case NotifyGrab: modestr="NotifyGrab"; break;
+ case NotifyUngrab: modestr="NotifyUngrab"; break;
+ case NotifyWhileGrabbed: modestr="NotifyWhileGrabbed"; break;
+ }
+ switch (detail) {
+ case NotifyAncestor: detailstr="NotifyAncestor"; break;
+ case NotifyVirtual: detailstr="NotifyVirtual"; break;
+ case NotifyInferior: detailstr="NotifyInferior"; break;
+ case NotifyNonlinear: detailstr="NotifyNonlinear"; break;
+ case NotifyNonlinearVirtual: detailstr="NotifyNonlinearVirtual"; break;
+ case NotifyPointer: detailstr="NotifyPointer"; break;
+ case NotifyPointerRoot: detailstr="NotifyPointerRoot"; break;
+ case NotifyDetailNone: detailstr="NotifyDetailNone"; break;
+ }
+
+ g_assert(modestr);
+ g_assert(detailstr);
+ ob_debug_type(OB_DEBUG_FOCUS, "Focus%s 0x%x mode=%s detail=%s\n",
+ (e->xfocus.type == FocusIn ? "In" : "Out"),
+ win,
+ modestr, detailstr);
+
}
static gboolean event_ignore(XEvent *e, ObClient *client)
{
switch(e->type) {
case FocusIn:
- if (!wanted_focusevent(e))
+ print_focusevent(e);
+ if (!wanted_focusevent(e, FALSE))
return TRUE;
break;
case FocusOut:
- if (!wanted_focusevent(e))
+ print_focusevent(e);
+ if (!wanted_focusevent(e, FALSE))
return TRUE;
break;
}
event_handle_menu(e);
} else if (e->type == FocusIn) {
if (e->xfocus.detail == NotifyPointerRoot ||
- e->xfocus.detail == NotifyDetailNone)
+ e->xfocus.detail == NotifyDetailNone ||
+ e->xfocus.detail == NotifyInferior)
{
- ob_debug_type(OB_DEBUG_FOCUS, "Focus went to pointer root/none\n");
- /* Focus has been reverted to the root window or nothing.
- FocusOut events come after UnmapNotify, so we don't need to
- worry about focusing an invalid window
- */
- if (!focus_left_screen)
- focus_fallback(TRUE);
- } else if (e->xfocus.detail == NotifyInferior) {
+ XEvent ce;
ob_debug_type(OB_DEBUG_FOCUS,
- "Focus went to root or our frame window");
- /* Focus has been given to the root window. */
- focus_fallback(TRUE);
+ "Focus went to pointer root/none or to our frame "
+ "window\n");
+
+ /* If another FocusIn is in the queue then don't fallback yet. This
+ fixes the fun case of:
+ window map -> send focusin
+ window unmap -> get focusout
+ window map -> send focusin
+ get first focus out -> fall back to something (new window
+ hasn't received focus yet, so something else) -> send focusin
+ which means the "something else" is the last thing to get a
+ focusin sent to it, so the new window doesn't end up with focus.
+
+ But if the other focus in is something like PointerRoot then we
+ still want to fall back.
+ */
+ if (XCheckIfEvent(ob_display, &ce, look_for_focusin_client, NULL)){
+ XPutBackEvent(ob_display, &ce);
+ ob_debug_type(OB_DEBUG_FOCUS,
+ " but another FocusIn is coming\n");
+ } else {
+ /* Focus has been reverted to the root window, nothing, or to
+ our frame window.
+
+ FocusOut events come after UnmapNotify, so we don't need to
+ worry about focusing an invalid window
+ */
+
+ /* In this case we know focus is in our screen */
+ if (e->xfocus.detail == NotifyInferior)
+ focus_left_screen = FALSE;
+
+ if (!focus_left_screen)
+ focus_fallback(TRUE);
+ }
} else if (client && client != focus_client) {
focus_left_screen = FALSE;
frame_adjust_focus(client->frame, TRUE);
focus_set_client(client);
client_calc_layer(client);
+ client_bring_non_application_windows(client);
}
} else if (e->type == FocusOut) {
gboolean nomove = FALSE;
XEvent ce;
- ob_debug_type(OB_DEBUG_FOCUS, "FocusOut Event\n");
-
/* Look for the followup FocusIn */
if (!XCheckIfEvent(ob_display, &ce, look_for_focusin, NULL)) {
/* There is no FocusIn, this means focus went to a window that
guint d = e->xclient.data.l[0];
if (d < screen_num_desktops) {
event_curtime = e->xclient.data.l[1];
- ob_debug("SWITCH DESKTOP TIME: %d\n", event_curtime);
- screen_set_desktop(d);
+ if (event_curtime == 0)
+ ob_debug_type(OB_DEBUG_APP_BUGS,
+ "_NET_CURRENT_DESKTOP message is missing "
+ "a timestamp\n");
+ screen_set_desktop(d, TRUE);
}
} else if (msgtype == prop_atoms.net_number_of_desktops) {
guint d = e->xclient.data.l[0];
screen_set_num_desktops(d);
} else if (msgtype == prop_atoms.net_showing_desktop) {
screen_show_desktop(e->xclient.data.l[0] != 0, TRUE);
- } else if (msgtype == prop_atoms.ob_control) {
+ } else if (msgtype == prop_atoms.openbox_control) {
if (e->xclient.data.l[0] == 1)
ob_reconfigure();
else if (e->xclient.data.l[0] == 2)
{
XEvent ce;
Atom msgtype;
- gint i=0;
ObFrameContext con;
switch (e->type) {
case ButtonPress:
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 (!(e->xbutton.button == 4 || e->xbutton.button == 5)) {
+ is a waste of resources to go drawing it.
+ if the user is doing an intereactive 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) &&
+ !keyboard_interactively_grabbed() &&
+ !menu_frame_visible)
+ {
con = frame_context(client, e->xbutton.window);
con = mouse_button_frame_context(con, e->xbutton.button);
switch (con) {
break;
}
case ConfigureRequest:
- /* compress these */
- while (XCheckTypedWindowEvent(ob_display, client->window,
- ConfigureRequest, &ce)) {
- ++i;
- /* XXX if this causes bad things.. we can compress config req's
- with the same mask. */
- e->xconfigurerequest.value_mask |=
- ce.xconfigurerequest.value_mask;
- if (ce.xconfigurerequest.value_mask & CWX)
- e->xconfigurerequest.x = ce.xconfigurerequest.x;
- if (ce.xconfigurerequest.value_mask & CWY)
- e->xconfigurerequest.y = ce.xconfigurerequest.y;
- if (ce.xconfigurerequest.value_mask & CWWidth)
- e->xconfigurerequest.width = ce.xconfigurerequest.width;
- if (ce.xconfigurerequest.value_mask & CWHeight)
- e->xconfigurerequest.height = ce.xconfigurerequest.height;
- if (ce.xconfigurerequest.value_mask & CWBorderWidth)
- e->xconfigurerequest.border_width =
- ce.xconfigurerequest.border_width;
- if (ce.xconfigurerequest.value_mask & CWStackMode)
- e->xconfigurerequest.detail = ce.xconfigurerequest.detail;
- }
+ /* dont compress these unless you're going to watch for property
+ notifies in between (these can change what the configure would
+ do to the window).
+ also you can't compress stacking events
+ */
ob_debug("ConfigureRequest desktop %d wmstate %d vis %d\n",
screen_desktop, client->wmstate, client->frame->visible);
- /* If the client is in IconicState then ignore the event.
- This used to only ignore iconic or shaded windows, but windows on
- other desktops are also in IconicState, so now those can't
- send ConfigureRequests either..
- This fixes the bug of KDE apps moving when they try to active them-
- selves on another desktop.
- It used to say "fvwm does this" but I'm not sure if fvwm does
- this for windows on other desktops too. Probably, it makes sense.
- */
- if (client->wmstate == IconicState) return;
+ /* don't allow clients to move shaded windows (fvwm does this) */
+ if (client->shaded) {
+ e->xconfigurerequest.value_mask &= ~CWX;
+ e->xconfigurerequest.value_mask &= ~CWY;
+ }
/* resize, then move, as specified in the EWMH section 7.7 */
if (e->xconfigurerequest.value_mask & (CWWidth | CWHeight |
e->xconfigurerequest.value_mask & CWX, x,
e->xconfigurerequest.value_mask & CWY, y);
+ /* check for broken apps moving to their root position
+
+ XXX remove this some day...that would be nice. right now all
+ kde apps do this when they try activate themselves on another
+ desktop. eg. open amarok window on desktop 1, switch to desktop
+ 2, click amarok tray icon. it will move by its decoration size.
+ */
+ if (x != client->area.x &&
+ x == (client->frame->area.x + client->frame->size.left -
+ (gint)client->border_width) &&
+ y != client->area.y &&
+ y == (client->frame->area.y + client->frame->size.top -
+ (gint)client->border_width))
+ {
+ ob_debug_type(OB_DEBUG_APP_BUGS,
+ "Application %s is trying to move via "
+ "ConfigureRequest to it's root window position "
+ "but it is not using StaticGravity\n",
+ client->title);
+ /* don't move it */
+ x = client->area.x;
+ y = client->area.y;
+ }
+
client_find_onscreen(client, &x, &y, w, h, FALSE);
client_configure_full(client, x, y, w, h, FALSE, TRUE, TRUE);
}
if ((unsigned)e->xclient.data.l[0] < screen_num_desktops ||
(unsigned)e->xclient.data.l[0] == DESKTOP_ALL)
client_set_desktop(client, (unsigned)e->xclient.data.l[0],
- FALSE);
+ FALSE, FALSE);
} else if (msgtype == prop_atoms.net_wm_state) {
/* can't compress these */
ob_debug("net_wm_state %s %ld %ld for 0x%lx\n",
(e->xclient.data.l[0] == 0 ? "unknown" :
(e->xclient.data.l[0] == 1 ? "application" :
(e->xclient.data.l[0] == 2 ? "user" : "INVALID"))));
- /* XXX make use of data.l[2] ! */
+ /* XXX make use of data.l[2] !? */
event_curtime = e->xclient.data.l[1];
+ ob_debug_type(OB_DEBUG_APP_BUGS,
+ "_NET_ACTIVE_WINDOW message for window %s is "
+ "missing a timestamp\n", client->title);
client_activate(client, FALSE,
(e->xclient.data.l[0] == 0 ||
e->xclient.data.l[0] == 2));
msgtype == prop_atoms.net_wm_icon_name ||
msgtype == prop_atoms.wm_icon_name) {
client_update_title(client);
- } else if (msgtype == prop_atoms.wm_class) {
- client_update_class(client);
} else if (msgtype == prop_atoms.wm_protocols) {
client_update_protocols(client);
client_setup_decor_and_functions(client);
client_update_sync_request_counter(client);
}
#endif
- else if (msgtype == prop_atoms.sm_client_id) {
- client_update_sm_client_id(client);
- }
case ColormapNotify:
client_update_colormap(client, e->xcolormap.colormap);
break;
ObMenuEntryFrame *e = it->data;
gunichar entrykey = 0;
- if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
- e->entry->data.normal.enabled)
+ if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
entrykey = e->entry->data.normal.shortcut;
else if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
entrykey = e->entry->data.submenu.submenu->shortcut;
num_found == 1)
{
menu_frame_select(frame, found, TRUE);
- usleep(50000);
+ usleep(50000); /* highlight the item for a short bit so the
+ user can see what happened */
menu_entry_frame_execute(found, state, ev->xkey.time);
} else {
menu_frame_select(frame, found, TRUE);