X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fevent.c;h=71dca5f7da3dc702b0c3507b840c1ac1c42320c3;hb=064901801e8ceb7b07dbd0d27b4fecd600f7c766;hp=93cdf0b220f3b89cd426e1bf276ce9ac13c90c1d;hpb=df436132bda79134e822fd56a896ed28cdc289e0;p=chaz%2Fopenbox diff --git a/openbox/event.c b/openbox/event.c index 93cdf0b2..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,6 +321,8 @@ 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) @@ -342,19 +344,34 @@ static void event_done(gpointer data) 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); - } - focus_hilite = focus_in; + 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; } @@ -463,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); } } } @@ -488,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) { @@ -551,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) { @@ -608,7 +623,8 @@ static void event_handle_client(ObClient *client, XEvent *e) e->xfocus.window, client->window, e->xfocus.mode, e->xfocus.detail); #endif - focus_out = client; + if (focus_hilite == client || focus_client == client) + focus_out = client; if (focus_in == client) focus_in = NULL; break; @@ -735,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) @@ -751,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) @@ -830,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: @@ -919,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; @@ -946,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) @@ -1199,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;