X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=openbox%2Fevent.c;h=b048e7e64e7e95babf6c08f0536386d9bb99df5a;hb=5895fa84ac6f66f272be745505e76250c24d3ba1;hp=26c218d0ada8ac698f2977525897feeba95721ca;hpb=a1e450ee6933b69614f48b67180ac826ca1a7068;p=chaz%2Fopenbox diff --git a/openbox/event.c b/openbox/event.c index 26c218d0..b048e7e6 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -1,5 +1,6 @@ #include "openbox.h" #include "client.h" +#include "config.h" #include "xerror.h" #include "prop.h" #include "screen.h" @@ -220,17 +221,22 @@ void event_process(XEvent *e) event_lasttime = e->xproperty.time; break; case FocusIn: - if (e->xfocus.mode == NotifyGrab || - !(e->xfocus.detail == NotifyNonlinearVirtual || - e->xfocus.detail == NotifyNonlinear)) - return; + g_message("FocusIn on %lx mode %d detail %d", window, + e->xfocus.mode, e->xfocus.detail); + if (e->xfocus.detail == NotifyInferior || + /*e->xfocus.detail == NotifyAncestor ||*/ + e->xfocus.detail > NotifyNonlinearVirtual) return; + g_message("FocusIn on %lx", window); break; case FocusOut: + g_message("FocusOut on %lx mode %d detail %d", window, + e->xfocus.mode, e->xfocus.detail); if (e->xfocus.mode == NotifyGrab || - !(e->xfocus.detail == NotifyNonlinearVirtual || - e->xfocus.detail == NotifyNonlinear)) - return; + e->xfocus.detail == NotifyInferior || + e->xfocus.detail == NotifyAncestor || + e->xfocus.detail > NotifyNonlinearVirtual) return; + g_message("FocusOut on %lx", window); /* FocusOut events just make us look for FocusIn events. They are mostly ignored otherwise. */ { @@ -238,9 +244,23 @@ void event_process(XEvent *e) if (XCheckTypedEvent(ob_display, FocusIn, &fi)) { event_process(&fi); + /* secret magic way of event_process telling us that no client + was found for the FocusIn event. + + it should be noted!! that focus events of invalud types + (the ones that cause a return in the FocusIn case above) + will not cause this focus_fallback to be called. it will + be assumed that focus is going someplace sane still, or + there are more focus events coming to fix up the situation. + this may not be perfect.. but its working! and focus events + are too much headache to take that for granted. ktnx. ^_^ + */ + if (fi.xfocus.window == None) + focus_fallback(FALSE); if (fi.xfocus.window == e->xfocus.window) return; - } + } else + focus_fallback(FALSE); } break; case EnterNotify: @@ -250,6 +270,9 @@ void event_process(XEvent *e) caused, like when lowering a window */ if (e->xcrossing.mode == NotifyGrab) return; break; + default: + event_lasttime = CurrentTime; + break; } client = g_hash_table_lookup(client_map, &window); @@ -261,6 +284,8 @@ void event_process(XEvent *e) event_handle_root(e); else if (e->type == MapRequest) client_manage(window); + else if (e->type == FocusIn) + e->xfocus.window = None; /* says a client was found for the event! */ else if (e->type == ConfigureRequest) { /* unhandled configure requests must be used to configure the window directly */ @@ -297,7 +322,7 @@ static void event_handle_root(XEvent *e) msgtype = e->xclient.message_type; if (msgtype == prop_atoms.net_current_desktop) { unsigned int d = e->xclient.data.l[0]; - if (d <= screen_num_desktops) + if (d < screen_num_desktops) screen_set_desktop(d); } else if (msgtype == prop_atoms.net_number_of_desktops) { unsigned int d = e->xclient.data.l[0]; @@ -320,13 +345,37 @@ static void event_handle_client(Client *client, XEvent *e) { XEvent ce; Atom msgtype; - int i=0; + int i=0; + ConfigValue focus_follow; switch (e->type) { case FocusIn: + focus_set_client(client); case FocusOut: - client_set_focused(client, e->type == FocusIn); + g_message("Focus%s on client for %lx", (e->type==FocusIn?"In":"Out"), + client->window); + /* focus state can affect the stacking layer */ + client_calc_layer(client); + engine_frame_adjust_focus(client->frame); break; + case EnterNotify: + if (client_normal(client)) { + if (ob_state == State_Starting) { + /* move it to the top of the focus order */ + guint desktop = client->desktop; + if (desktop == DESKTOP_ALL) desktop = screen_desktop; + focus_order[desktop] = g_list_remove(focus_order[desktop], + client); + focus_order[desktop] = g_list_prepend(focus_order[desktop], + client); + } else { + if (!config_get("focusFollowsMouse",Config_Bool,&focus_follow)) + g_assert_not_reached(); + if (focus_follow.bool) + client_focus(client); + } + } + break; case ConfigureRequest: /* compress these */ while (XCheckTypedWindowEvent(ob_display, client->window, @@ -482,8 +531,10 @@ static void event_handle_client(Client *client, XEvent *e) } e->xclient = ce.xclient; } - if ((unsigned)e->xclient.data.l[0] < screen_num_desktops) - client_set_desktop(client, (unsigned)e->xclient.data.l[0]); + 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); } else if (msgtype == prop_atoms.net_wm_state) { /* can't compress these */ g_message("net_wm_state %s %ld %ld for 0x%lx",