X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fevent.c;h=51cfc658c638a9db5128f4fd3a70d71216715acd;hb=7be28d3010d4bf68954a113ab8350ac2ddb768aa;hp=1b7b77391f91c629804348f0c49d4b16d44a2a92;hpb=ad812e6299223efb0cb4faee03ce99870e5c7ce5;p=chaz%2Fopenbox diff --git a/openbox/event.c b/openbox/event.c index 1b7b7739..51cfc658 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -90,7 +90,7 @@ static gboolean event_handle_prompt(ObPrompt *p, XEvent *e); static void event_handle_dock(ObDock *s, XEvent *e); static void event_handle_dockapp(ObDockApp *app, XEvent *e); static void event_handle_client(ObClient *c, XEvent *e); -static void event_handle_user_input(ObClient *client, XEvent *e); +static gboolean event_handle_user_input(ObClient *client, XEvent *e); static gboolean is_enter_focus_event_ignored(gulong serial); static void event_ignore_enter_range(gulong start, gulong end); @@ -472,6 +472,7 @@ static void event_process(const XEvent *ec, gpointer data) ObWindow *obwin = NULL; ObMenuFrame *menu = NULL; ObPrompt *prompt = NULL; + gboolean used; /* make a copy we can mangle */ ee = *ec; @@ -717,31 +718,37 @@ static void event_process(const XEvent *ec, gpointer data) } #endif - if (prompt && event_handle_prompt(prompt, e)) - ; - else if (e->type == ButtonPress || e->type == ButtonRelease) { + if (e->type == ButtonPress || e->type == ButtonRelease) { + ObWindow *w; + static guint pressed = 0; + static Window pressed_win = None; + /* If the button press was on some non-root window, or was physically - on the root window, then process it */ + on the root window... */ if (window != obt_root(ob_screen) || - e->xbutton.subwindow == None) + e->xbutton.subwindow == None || + /* ...or if it is related to the last button press we handled... */ + pressed == e->xbutton.button || + /* ...or it if it was physically on an openbox + internal window... */ + ((w = window_find(e->xbutton.subwindow)) && + WINDOW_IS_INTERNAL(w))) + /* ...then process the event, otherwise ignore it */ { - event_handle_user_input(client, e); - } - /* Otherwise only process it if it was physically on an openbox - internal window */ - else { - ObWindow *w; + used = event_handle_user_input(client, e); - if ((w = window_find(e->xbutton.subwindow)) && - WINDOW_IS_INTERNAL(w)) - { - event_handle_user_input(client, e); + if (e->type == ButtonPress) { + pressed = e->xbutton.button; + pressed_win = e->xbutton.subwindow; } } } else if (e->type == KeyPress || e->type == KeyRelease || e->type == MotionNotify) - event_handle_user_input(client, e); + used = event_handle_user_input(client, e); + + if (prompt && !used) + used = event_handle_prompt(prompt, e); /* if something happens and it's not from an XEvent, then we don't know the time */ @@ -1802,14 +1809,24 @@ static gboolean event_handle_menu_input(XEvent *ev) else if (ob_keycode_match(keycode, OB_KEY_LEFT)) { /* Left goes to the parent menu */ - if (frame->parent) + if (frame->parent) { + /* remove focus from the child */ menu_frame_select(frame, NULL, TRUE); + /* and put it in the parent */ + menu_frame_select(frame->parent, frame->parent->selected, + TRUE); + } ret = TRUE; } else if (ob_keycode_match(keycode, OB_KEY_RIGHT)) { /* Right goes to the selected submenu */ - if (frame->child) menu_frame_select_next(frame->child); + if (frame->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) + { + /* make sure it is visible */ + menu_frame_select(frame, frame->selected, TRUE); + menu_frame_select_next(frame->child); + } ret = TRUE; } @@ -1822,6 +1839,16 @@ static gboolean event_handle_menu_input(XEvent *ev) menu_frame_select_next(frame); ret = TRUE; } + + else if (ob_keycode_match(keycode, OB_KEY_HOME)) { + menu_frame_select_first(frame); + ret = TRUE; + } + + else if (ob_keycode_match(keycode, OB_KEY_END)) { + menu_frame_select_last(frame); + ret = TRUE; + } } /* Use KeyRelease events for running things so that the key release @@ -1903,6 +1930,15 @@ static gboolean event_handle_menu_input(XEvent *ev) return ret; } +static Bool event_look_for_menu_enter(Display *d, XEvent *ev, XPointer arg) +{ + ObMenuFrame *f = (ObMenuFrame*)arg; + ObMenuEntryFrame *e; + return ev->type == EnterNotify && + (e = g_hash_table_lookup(menu_frame_map, &ev->xcrossing.window)) && + !e->ignore_enters && e->frame == f; +} + static void event_handle_menu(ObMenuFrame *frame, XEvent *ev) { ObMenuFrame *f; @@ -1925,22 +1961,23 @@ static void event_handle_menu(ObMenuFrame *frame, XEvent *ev) if (ev->xcrossing.detail == NotifyInferior) break; - if ((e = g_hash_table_lookup(menu_frame_map, &ev->xcrossing.window)) && - (f = find_active_menu()) && f->selected == e && - e->entry->type != OB_MENU_ENTRY_TYPE_SUBMENU) + if ((e = g_hash_table_lookup(menu_frame_map, &ev->xcrossing.window))) { - ObMenuEntryFrame *u = menu_entry_frame_under(ev->xcrossing.x_root, - ev->xcrossing.y_root); - /* if we're just going from one entry in the menu to the next, - don't unselect stuff first */ - if (!u || e->frame != u->frame) + XEvent ce; + + /* check if an EnterNotify event is coming, and if not, then select + nothing in the menu */ + if (XCheckIfEvent(obt_display, &ce, event_look_for_menu_enter, + (XPointer)e->frame)) + XPutBackEvent(obt_display, &ce); + else menu_frame_select(e->frame, NULL, FALSE); } break; } } -static void event_handle_user_input(ObClient *client, XEvent *e) +static gboolean event_handle_user_input(ObClient *client, XEvent *e) { g_assert(e->type == ButtonPress || e->type == ButtonRelease || e->type == MotionNotify || e->type == KeyPress || @@ -1951,29 +1988,32 @@ static void event_handle_user_input(ObClient *client, XEvent *e) /* don't use the event if the menu used it, but if the menu didn't use it and it's a keypress that is bound, it will close the menu and be used */ - return; + return TRUE; } /* if the keyboard interactive action uses the event then dont use it for bindings. likewise is moveresize uses the event. */ - if (!actions_interactive_input_event(e) && !moveresize_event(e)) { - if (moveresize_in_progress) - /* make further actions work on the client being - moved/resized */ - client = moveresize_client; - - if (e->type == ButtonPress || - e->type == ButtonRelease || - e->type == MotionNotify) - { - /* the frame may not be "visible" but they can still click on it - in the case where it is animating before disappearing */ - if (!client || !frame_iconify_animating(client->frame)) - mouse_event(client, e); - } else - keyboard_event((focus_cycle_target ? focus_cycle_target : - (client ? client : focus_client)), e); - } + if (actions_interactive_input_event(e) || moveresize_event(e)) + return TRUE; + + if (moveresize_in_progress) + /* make further actions work on the client being + moved/resized */ + client = moveresize_client; + + if (e->type == ButtonPress || + e->type == ButtonRelease || + e->type == MotionNotify) + { + /* the frame may not be "visible" but they can still click on it + in the case where it is animating before disappearing */ + if (!client || !frame_iconify_animating(client->frame)) + return mouse_event(client, e); + } else + return keyboard_event((focus_cycle_target ? focus_cycle_target : + (client ? client : focus_client)), e); + + return FALSE; } static void focus_delay_dest(gpointer data)