This is an automated email from the git hooks/post-receive script. nomad pushed a commit to annotated tag 0.2.1 in repository apps/xfdashboard.
commit efa106197145c799d366c6473cd248298e990bc6 Author: Stephan Haller <[email protected]> Date: Wed Jul 16 19:53:11 2014 +0200 Move focus to viewpad (and to search view finally) if a search has started This addresses issue #30. It was requested to select and focus the first item in search view when a search started to visualize the first item in search item which can be selected by pressing ENTER even if search box has not the focus - the "just-type-to-search" feature ;) --- src/focus-manager.c | 14 ++++++++++++++ src/focus-manager.h | 1 + src/search-view.c | 31 +++++++++++++++++++++++++++++-- src/stage.c | 23 +++++++++++++++++------ src/viewpad.c | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 8 deletions(-) diff --git a/src/focus-manager.c b/src/focus-manager.c index feeacbd..2c372a5 100644 --- a/src/focus-manager.c +++ b/src/focus-manager.c @@ -348,6 +348,20 @@ gboolean xfdashboard_focus_manager_is_registered(XfdashboardFocusManager *self, return(FALSE); } +/* Determine if a specific actor has the focus */ +gboolean xfdashboard_focus_manager_has_focus(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable) +{ + XfdashboardFocusManagerPrivate *priv; + + g_return_val_if_fail(XFDASHBOARD_IS_FOCUS_MANAGER(self), FALSE); + g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE); + + priv=self->priv; + + /* Return TRUE if given actor has the focus otherwise return FALSE */ + return(priv->currentFocus==inFocusable ? TRUE : FALSE); +} + /* Get focusable actor which has the focus currently */ XfdashboardFocusable* xfdashboard_focus_manager_get_focus(XfdashboardFocusManager *self) { diff --git a/src/focus-manager.h b/src/focus-manager.h index 313928d..08c1728 100644 --- a/src/focus-manager.h +++ b/src/focus-manager.h @@ -77,6 +77,7 @@ void xfdashboard_focus_manager_unregister(XfdashboardFocusManager *self, Xfdashb GList* xfdashboard_focus_manager_get_registered(XfdashboardFocusManager *self); gboolean xfdashboard_focus_manager_is_registered(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable); +gboolean xfdashboard_focus_manager_has_focus(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable); XfdashboardFocusable* xfdashboard_focus_manager_get_focus(XfdashboardFocusManager *self); void xfdashboard_focus_manager_set_focus(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable); diff --git a/src/search-view.c b/src/search-view.c index 21f1ee9..935b271 100644 --- a/src/search-view.c +++ b/src/search-view.c @@ -482,9 +482,13 @@ static void _xfdashboard_search_view_update_provider_actor_new(gpointer inData, static void _xfdashboard_search_view_update_provider_container(XfdashboardSearchView *self, XfdashboardSearchViewProviderData *inProviderData) { + XfdashboardSearchViewPrivate *priv; + g_return_if_fail(XFDASHBOARD_IS_SEARCH_VIEW(self)); g_return_if_fail(inProviderData); + priv=self->priv; + /* If result set for provider is given then check if we need to create a container * or if we have to update one ... */ @@ -521,6 +525,29 @@ static void _xfdashboard_search_view_update_provider_container(XfdashboardSearch (GFunc)_xfdashboard_search_view_update_provider_actor_destroy, inProviderData->lastResultSet); } + + /* Select first item if nothing is selected */ + if(!priv->selectionProvider || + !xfdashboard_search_result_container_get_current_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(inProviderData->container))) + { + ClutterActor *item; + + /* Set this provider as the selected one */ + priv->selectionProvider=inProviderData; + + /* Set focus to search result container of selected provider */ + xfdashboard_search_result_container_set_focus(XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container), + TRUE); + + /* Get current selectionr and style it */ + item=xfdashboard_search_result_container_set_next_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container), + XFDASHBOARD_SEARCH_RESULT_CONTAINER_SELECTION_STEP_SIZE_BEGIN_END); + if(item && + XFDASHBOARD_IS_STYLABLE(item)) + { + xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(item), "selected"); + } + } } /* ... but if no result set for provider is given then destroy existing container */ else @@ -613,8 +640,8 @@ static gboolean _xfdashboard_search_view_focusable_can_focus(XfdashboardFocusabl XfdashboardFocusableInterface *selfIface; XfdashboardFocusableInterface *parentIface; - g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), CLUTTER_EVENT_PROPAGATE); - g_return_val_if_fail(XFDASHBOARD_IS_SEARCH_VIEW(inFocusable), CLUTTER_EVENT_PROPAGATE); + g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), FALSE); + g_return_val_if_fail(XFDASHBOARD_IS_SEARCH_VIEW(inFocusable), FALSE); self=XFDASHBOARD_SEARCH_VIEW(inFocusable); diff --git a/src/stage.c b/src/stage.c index 63f0191..f9acfc6 100644 --- a/src/stage.c +++ b/src/stage.c @@ -219,15 +219,20 @@ static gboolean xfdashboard_stage_event(ClutterActor *inActor, ClutterEvent *inE result=xfdashboard_focus_manager_handle_key_event(priv->focusManager, inEvent); if(result==CLUTTER_EVENT_STOP) return(result); - /* If even focus manager did not handle this event - * send even to searchbox. - */ + /* If even focus manager did not handle this event send this event to searchbox */ if(priv->searchbox && XFDASHBOARD_IS_FOCUSABLE(priv->searchbox) && xfdashboard_focus_manager_is_registered(priv->focusManager, XFDASHBOARD_FOCUSABLE(priv->searchbox))) { - result=xfdashboard_focusable_handle_key_event(XFDASHBOARD_FOCUSABLE(priv->searchbox), inEvent); - if(result==CLUTTER_EVENT_STOP) return(result); + /* Ask searchbox to handle this event if it has not the focus currently + * because in this case it has already handled the event and we do + * not to do this twice. + */ + if(xfdashboard_focus_manager_get_focus(priv->focusManager)!=XFDASHBOARD_FOCUSABLE(priv->searchbox)) + { + result=xfdashboard_focusable_handle_key_event(XFDASHBOARD_FOCUSABLE(priv->searchbox), inEvent); + if(result==CLUTTER_EVENT_STOP) return(result); + } } /* If we get here there was no searchbox or it could not handle the event @@ -457,8 +462,14 @@ static void _xfdashboard_stage_on_searchbox_text_changed(XfdashboardStage *self, /* Remember current active view to restore it when search ended */ priv->viewBeforeSearch=XFDASHBOARD_VIEW(g_object_ref(xfdashboard_viewpad_get_active_view(XFDASHBOARD_VIEWPAD(priv->viewpad)))); - /* Enable search view */ + /* Enable search view and set focus to viewpad which will show the + * search view so this search view will get the focus finally + */ xfdashboard_view_set_enabled(searchView, TRUE); + if(priv->viewpad && priv->focusManager) + { + xfdashboard_focus_manager_set_focus(priv->focusManager, XFDASHBOARD_FOCUSABLE(priv->viewpad)); + } /* Activate "clear" button on text box */ xfdashboard_stylable_add_class(XFDASHBOARD_STYLABLE(priv->searchbox), "search-active"); diff --git a/src/viewpad.c b/src/viewpad.c index 03768b2..555e88c 100644 --- a/src/viewpad.c +++ b/src/viewpad.c @@ -36,6 +36,7 @@ #include "enums.h" #include "utils.h" #include "focusable.h" +#include "focus-manager.h" /* Define this class in GObject system */ static void _xfdashboard_viewpad_focusable_iface_init(XfdashboardFocusableInterface *iface); @@ -224,6 +225,8 @@ static void _xfdashboard_viewpad_activate_view(XfdashboardViewpad *self, Xfdashb { XfdashboardViewpadPrivate *priv; gfloat x, y; + XfdashboardFocusManager *focusManager; + gboolean hasFocus; g_return_if_fail(XFDASHBOARD_IS_VIEWPAD(self)); g_return_if_fail(inView==NULL || XFDASHBOARD_IS_VIEW(inView)); @@ -249,9 +252,20 @@ static void _xfdashboard_viewpad_activate_view(XfdashboardViewpad *self, Xfdashb return; } + /* Determine if this viewpad has the focus because we have to move focus in this case */ + focusManager=xfdashboard_focus_manager_get_default(); + hasFocus=xfdashboard_focus_manager_has_focus(focusManager, XFDASHBOARD_FOCUSABLE(self)); + /* Deactivate current view */ if(priv->activeView) { + /* Unset focus at current active view if this viewpad has the focus */ + if(hasFocus) + { + xfdashboard_focusable_unset_focus(XFDASHBOARD_FOCUSABLE(priv->activeView)); + g_debug("Viewpad has focus so unset focus from view '%s'", xfdashboard_view_get_name(priv->activeView)); + } + /* Hide current view and emit signal before and after deactivation */ g_signal_emit(self, XfdashboardViewpadSignals[SIGNAL_VIEW_DEACTIVATING], 0, priv->activeView); g_signal_emit_by_name(priv->activeView, "deactivating"); @@ -296,8 +310,34 @@ static void _xfdashboard_viewpad_activate_view(XfdashboardViewpad *self, Xfdashb g_signal_emit_by_name(priv->activeView, "activated"); g_signal_emit(self, XfdashboardViewpadSignals[SIGNAL_VIEW_ACTIVATED], 0, priv->activeView); + + /* Set focus to new active view if this viewpad has the focus */ + if(hasFocus) + { + xfdashboard_focusable_set_focus(XFDASHBOARD_FOCUSABLE(priv->activeView)); + g_debug("Viewpad has focus so set focus to view '%s'", xfdashboard_view_get_name(priv->activeView)); + } } + /* If no view is active at this time move focus to next focusable actor + * if this viewpad has the focus. + */ + if(hasFocus && !priv->activeView) + { + XfdashboardFocusable *newFocusable; + + newFocusable=xfdashboard_focus_manager_get_next_focusable(focusManager, XFDASHBOARD_FOCUSABLE(self)); + if(newFocusable) + { + xfdashboard_focus_manager_set_focus(focusManager, newFocusable); + g_debug("Viewpad has focus but no view is active so move focus to next focusable actor of type '%s'", + G_OBJECT_TYPE_NAME(newFocusable)); + } + } + + /* Release allocated resources */ + if(focusManager) g_object_unref(focusManager); + /* Notify about property change */ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardViewpadProperties[PROP_ACTIVE_VIEW]); } -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list [email protected] https://mail.xfce.org/mailman/listinfo/xfce4-commits
