X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Fevent.c;h=71dca5f7da3dc702b0c3507b840c1ac1c42320c3;hb=7c827e16ba99824a6a3862c6f72d2102f5abc5c2;hp=eff9d5907b256fe2c3597931086711cfa1fea60e;hpb=2572f111e011152fb5a844fb0c3577eafef11a09;p=chaz%2Fopenbox diff --git a/openbox/event.c b/openbox/event.c index eff9d590..71dca5f7 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -73,17 +73,17 @@ static gboolean menu_hide_delay_func(gpointer data); Time event_lasttime = 0; /*! The value of the mask for the NumLock modifier */ -unsigned int NumLockMask; +guint NumLockMask; /*! The value of the mask for the ScrollLock modifier */ -unsigned int ScrollLockMask; +guint ScrollLockMask; /*! The key codes for the modifier keys */ static XModifierKeymap *modmap; /*! Table of the constant modifier masks */ -static const int mask_table[] = { +static const gint mask_table[] = { ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask }; -static int mask_table_size; +static gint mask_table_size; static guint ignore_enter_focus = 0; @@ -92,7 +92,7 @@ static gboolean menu_can_hide; static ObClient *focus_in, *focus_out; #ifdef USE_SM -static void ice_handler(int fd, gpointer conn) +static void ice_handler(gint fd, gpointer conn) { Bool b; IceProcessMessages(conn, NULL, &b); @@ -249,7 +249,7 @@ static void event_set_lasttime(XEvent *e) static void event_hack_mods(XEvent *e) { KeyCode *kp; - int i, k; + gint i, k; switch (e->type) { case ButtonPress: @@ -321,29 +321,57 @@ static void event_client_dest(ObClient *client, gpointer data) focus_in = NULL; if (client == focus_out) focus_out = NULL; + if (client == focus_hilite) + focus_hilite = NULL; } static void event_done(gpointer data) { static ObClient *last = NULL; + /* sometimes focus_hilite can be on an unfocused window, this make sure + it loses its focus hilite when focus moves */ + if (focus_hilite && + (focus_in && focus_hilite != focus_in) && + (focus_out && focus_hilite != focus_out)) + { + frame_adjust_focus(focus_hilite->frame, FALSE); + } + if (focus_in) { if (focus_in != focus_client) { focus_set_client(focus_in); frame_adjust_focus(focus_in->frame, TRUE); client_calc_layer(focus_in); } + + focus_hilite = focus_in; } if (focus_out) { if (focus_out == focus_client) focus_set_client(NULL); frame_adjust_focus(focus_out->frame, FALSE); client_calc_layer(focus_out); + + if (!focus_in) + focus_hilite = NULL; } if (focus_client != last) { - if (!focus_client) - focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS); + if (!focus_client) { + Window w; + gint r; + + /* is focus anywhere valid? */ + XGetInputFocus(ob_display, &w, &r); + +#ifdef DEBUG_FOCUS + ob_debug("Focus was found on 0x%x revert %d\n", w, r); +#endif + + if (!w || w == PointerRoot) + focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS); + } last = focus_client; } @@ -452,11 +480,9 @@ static void event_process(const XEvent *ec, gpointer data) e->type == MotionNotify) mouse_event(client, e); else if (e->type == KeyPress) - /* when in the middle of a focus cycling action, this - causes the window which appears to be focused to be - the one on which the actions will be executed */ - keyboard_event((focus_cycle_target ? - focus_cycle_target : client), e); + keyboard_event((focus_cycle_target ? focus_cycle_target : + (focus_hilite ? focus_hilite : client)), + e); } } } @@ -477,11 +503,11 @@ 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]; + guint d = e->xclient.data.l[0]; 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]; + guint d = e->xclient.data.l[0]; if (d > 0) screen_set_num_desktops(d); } else if (msgtype == prop_atoms.net_showing_desktop) { @@ -540,7 +566,7 @@ static void event_handle_client(ObClient *client, XEvent *e) { XEvent ce; Atom msgtype; - int i=0; + gint i=0; ObFrameContext con; switch (e->type) { @@ -597,10 +623,10 @@ static void event_handle_client(ObClient *client, XEvent *e) e->xfocus.window, client->window, e->xfocus.mode, e->xfocus.detail); #endif + if (focus_hilite == client || focus_client == client) + focus_out = client; if (focus_in == client) focus_in = NULL; - if (client == focus_client) - focus_out = client; break; case LeaveNotify: con = frame_context(client, e->xcrossing.window); @@ -626,12 +652,10 @@ static void event_handle_client(ObClient *client, XEvent *e) frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_FRAME: - /* - if (config_focus_follow && config_focus_delay) - ob_main_loop_timeout_remove_data(ob_main_loop, - focus_delay_func, - client); - */ + if (config_focus_follow && config_focus_delay) + ob_main_loop_timeout_remove_data(ob_main_loop, + focus_delay_func, + client); break; default: break; @@ -727,7 +751,7 @@ static void event_handle_client(ObClient *client, XEvent *e) if (e->xconfigurerequest.value_mask & (CWWidth | CWHeight | CWX | CWY | CWBorderWidth)) { - int x, y, w, h; + gint x, y, w, h; ObCorner corner; if (e->xconfigurerequest.value_mask & CWBorderWidth) @@ -743,12 +767,12 @@ static void event_handle_client(ObClient *client, XEvent *e) e->xconfigurerequest.height : client->area.height; { - int newx = x; - int newy = y; - int fw = w + - client->frame->size.left + client->frame->size.right; - int fh = h + - client->frame->size.top + client->frame->size.bottom; + gint newx = x; + gint newy = y; + gint fw = w + + client->frame->size.left + client->frame->size.right; + gint fh = h + + client->frame->size.top + client->frame->size.bottom; client_find_onscreen(client, &newx, &newy, fw, fh, client_normal(client)); if (e->xconfigurerequest.value_mask & CWX) @@ -822,7 +846,10 @@ static void event_handle_client(ObClient *client, XEvent *e) case MapRequest: ob_debug("MapRequest for 0x%lx\n", client->window); if (!client->iconic) break; /* this normally doesn't happen, but if it - does, we don't want it! */ + does, we don't want it! + it can happen now when the window is on + another desktop, but we still don't + want it! */ client_activate(client, FALSE); break; case ClientMessage: @@ -911,8 +938,8 @@ static void event_handle_client(ObClient *client, XEvent *e) e->xclient.data.l[2]); } } else if (msgtype == prop_atoms.net_moveresize_window) { - int oldg = client->gravity; - int tmpg, x, y, w, h; + gint oldg = client->gravity; + gint tmpg, x, y, w, h; if (e->xclient.data.l[0] & 0xff) tmpg = e->xclient.data.l[0] & 0xff; @@ -938,12 +965,12 @@ static void event_handle_client(ObClient *client, XEvent *e) client->gravity = tmpg; { - int newx = x; - int newy = y; - int fw = w + - client->frame->size.left + client->frame->size.right; - int fh = h + - client->frame->size.top + client->frame->size.bottom; + gint newx = x; + gint newy = y; + gint fw = w + + client->frame->size.left + client->frame->size.right; + gint fh = h + + client->frame->size.top + client->frame->size.bottom; client_find_onscreen(client, &newx, &newy, fw, fh, client_normal(client)); if (e->xclient.data.l[0] & 1 << 8) @@ -1191,6 +1218,11 @@ static void focus_delay_client_dest(ObClient *client, gpointer data) ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func, client); } +void event_halt_focus_delay() +{ + ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func); +} + void event_ignore_queued_enters() { GSList *saved = NULL, *it;