[Xfce4-commits] [apps/xfdashboard] 02/05: Split key handling function into "specialized" functions
noreply at xfce.org
noreply at xfce.org
Tue Mar 24 10:25:14 CET 2015
This is an automated email from the git hooks/post-receive script.
nomad pushed a commit to annotated tag 0.2.2
in repository apps/xfdashboard.
commit f63b5d3c88fd575100d6ca11eb633631ae2de744
Author: Stephan Haller <nomad at froevel.de>
Date: Tue Aug 12 20:35:24 2014 +0200
Split key handling function into "specialized" functions
Split key handling function in XfdashboardFocusable into "specialized" functions for 'key-press' and 'key-release' events. This make handling repeative 'key-press' event easier and cleaner (code), e.g. for moving selection when key is pressed and hold pressed. 'key-release' is only called once when pressed key is released.
---
src/applications-view.c | 75 +++++++++------
src/focus-manager.c | 24 ++++-
src/focusable.c | 78 +++++++++++++--
src/focusable.h | 5 +-
src/quicklaunch.c | 104 +++++++++++---------
src/search-view.c | 88 ++++++++++-------
src/text-box.c | 75 ++++++++++-----
src/viewpad.c | 45 ++++++++-
src/windows-view.c | 238 ++++++++++++++++++++++++----------------------
src/workspace-selector.c | 101 ++++++++++++--------
10 files changed, 530 insertions(+), 303 deletions(-)
diff --git a/src/applications-view.c b/src/applications-view.c
index 3ee648b..0abfd2b 100644
--- a/src/applications-view.c
+++ b/src/applications-view.c
@@ -667,8 +667,8 @@ static gboolean _xfdashboard_applications_view_focusable_handle_key_event_at_lis
return(CLUTTER_EVENT_STOP);
}
-static gboolean _xfdashboard_applications_view_focusable_handle_key_event(XfdashboardFocusable *inFocusable,
- const ClutterEvent *inEvent)
+static gboolean _xfdashboard_applications_view_focusable_handle_keypress_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
{
XfdashboardApplicationsView *self;
XfdashboardApplicationsViewPrivate *priv;
@@ -680,40 +680,52 @@ static gboolean _xfdashboard_applications_view_focusable_handle_key_event(Xfdash
self=XFDASHBOARD_APPLICATIONS_VIEW(inFocusable);
priv=self->priv;
- /* Handle key events when key was released */
- if(clutter_event_type(inEvent)==CLUTTER_KEY_RELEASE)
+ /* Move selection if an arrow key was pressed */
+ if(priv->viewMode==XFDASHBOARD_VIEW_MODE_LIST)
{
- /* Start selected application on ENTER */
- switch(inEvent->key.keyval)
+ handledEvent=_xfdashboard_applications_view_focusable_handle_key_event_at_list_mode(self, inEvent);
+ }
+ else
{
- case CLUTTER_KEY_Return:
- case CLUTTER_KEY_KP_Enter:
- case CLUTTER_KEY_ISO_Enter:
- if(priv->selectedItem)
- {
- if(XFDASHBOARD_IS_APPLICATION_BUTTON(priv->selectedItem))
- {
- _xfdashboard_applications_view_on_item_clicked(self, XFDASHBOARD_APPLICATION_BUTTON(priv->selectedItem));
- }
- else if(XFDASHBOARD_IS_BUTTON(priv->selectedItem))
- {
- _xfdashboard_applications_view_on_parent_menu_clicked(self, XFDASHBOARD_BUTTON(priv->selectedItem));
- }
- }
- return(CLUTTER_EVENT_STOP);
+ handledEvent=_xfdashboard_applications_view_focusable_handle_key_event_at_icon_mode(self, inEvent);
}
- /* Move selection if an arrow key was pressed */
- if(priv->viewMode==XFDASHBOARD_VIEW_MODE_LIST)
- {
- handledEvent=_xfdashboard_applications_view_focusable_handle_key_event_at_list_mode(self, inEvent);
- }
- else
+ if(handledEvent==CLUTTER_EVENT_STOP) return(handledEvent);
+
+ /* We did not handle this event */
+ return(CLUTTER_EVENT_PROPAGATE);
+}
+
+static gboolean _xfdashboard_applications_view_focusable_handle_keyrelease_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
+{
+ XfdashboardApplicationsView *self;
+ XfdashboardApplicationsViewPrivate *priv;
+
+ g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(XFDASHBOARD_IS_APPLICATIONS_VIEW(inFocusable), CLUTTER_EVENT_PROPAGATE);
+
+ self=XFDASHBOARD_APPLICATIONS_VIEW(inFocusable);
+ priv=self->priv;
+
+ /* Start selected application on ENTER */
+ switch(inEvent->key.keyval)
+ {
+ case CLUTTER_KEY_Return:
+ case CLUTTER_KEY_KP_Enter:
+ case CLUTTER_KEY_ISO_Enter:
+ if(priv->selectedItem)
{
- handledEvent=_xfdashboard_applications_view_focusable_handle_key_event_at_icon_mode(self, inEvent);
+ if(XFDASHBOARD_IS_APPLICATION_BUTTON(priv->selectedItem))
+ {
+ _xfdashboard_applications_view_on_item_clicked(self, XFDASHBOARD_APPLICATION_BUTTON(priv->selectedItem));
+ }
+ else if(XFDASHBOARD_IS_BUTTON(priv->selectedItem))
+ {
+ _xfdashboard_applications_view_on_parent_menu_clicked(self, XFDASHBOARD_BUTTON(priv->selectedItem));
+ }
}
-
- if(handledEvent==CLUTTER_EVENT_STOP) return(handledEvent);
+ return(CLUTTER_EVENT_STOP);
}
/* We did not handle this event */
@@ -728,7 +740,8 @@ void _xfdashboard_applications_view_focusable_iface_init(XfdashboardFocusableInt
iface->can_focus=_xfdashboard_applications_view_focusable_can_focus;
iface->set_focus=_xfdashboard_applications_view_focusable_set_focus;
iface->unset_focus=_xfdashboard_applications_view_focusable_unset_focus;
- iface->handle_key_event=_xfdashboard_applications_view_focusable_handle_key_event;
+ iface->handle_keypress_event=_xfdashboard_applications_view_focusable_handle_keypress_event;
+ iface->handle_keyrelease_event=_xfdashboard_applications_view_focusable_handle_keyrelease_event;
}
/* IMPLEMENTATION: GObject */
diff --git a/src/focus-manager.c b/src/focus-manager.c
index 27ee3b7..8f623f6 100644
--- a/src/focus-manager.c
+++ b/src/focus-manager.c
@@ -580,7 +580,29 @@ gboolean xfdashboard_focus_manager_handle_key_event(XfdashboardFocusManager *sel
/* Synthesize event for current focused focusable actor */
if(priv->currentFocus)
{
- return(xfdashboard_focusable_handle_key_event(priv->currentFocus, inEvent));
+ gboolean handled;
+
+ handled=CLUTTER_EVENT_PROPAGATE;
+
+ /* Try handler function depending on key event type */
+ switch(clutter_event_type(inEvent))
+ {
+ case CLUTTER_KEY_PRESS:
+ handled=xfdashboard_focusable_handle_keypress_event(priv->currentFocus, inEvent);
+ break;
+
+ case CLUTTER_KEY_RELEASE:
+ handled=xfdashboard_focusable_handle_keyrelease_event(priv->currentFocus, inEvent);
+ break;
+
+ default:
+ /* We should never get here */
+ g_assert_not_reached();
+ break;
+ }
+
+ /* Return handling result */
+ return(handled);
}
/* If we get here there is no focus set */
diff --git a/src/focusable.c b/src/focusable.c
index 9e43752..7f6332b 100644
--- a/src/focusable.c
+++ b/src/focusable.c
@@ -61,8 +61,18 @@ static void _xfdashboard_focusable_real_unset_focus(XfdashboardFocusable *self)
/* By default (if not overidden) do nothing */
}
-/* Default implementation of virtual function "handle_key_event" */
-static gboolean _xfdashboard_focusable_real_handle_key_event(XfdashboardFocusable *self, const ClutterEvent *inEvent)
+/* Default implementation of virtual function "handle_keypress_event" */
+static gboolean _xfdashboard_focusable_real_handle_keypress_event(XfdashboardFocusable *self, const ClutterEvent *inEvent)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(CLUTTER_IS_ACTOR(self), CLUTTER_EVENT_PROPAGATE);
+
+ /* By default synthesize event to focusable actor */
+ return(clutter_actor_event(CLUTTER_ACTOR(self), inEvent, FALSE));
+}
+
+/* Default implementation of virtual function "handle_keyrelease_event" */
+static gboolean _xfdashboard_focusable_real_handle_keyrelease_event(XfdashboardFocusable *self, const ClutterEvent *inEvent)
{
g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), CLUTTER_EVENT_PROPAGATE);
g_return_val_if_fail(CLUTTER_IS_ACTOR(self), CLUTTER_EVENT_PROPAGATE);
@@ -86,7 +96,8 @@ void xfdashboard_focusable_default_init(XfdashboardFocusableInterface *iface)
*/
iface->can_focus=_xfdashboard_focusable_real_can_focus;
iface->unset_focus=_xfdashboard_focusable_real_unset_focus;
- iface->handle_key_event=_xfdashboard_focusable_real_handle_key_event;
+ iface->handle_keypress_event=_xfdashboard_focusable_real_handle_keypress_event;
+ iface->handle_keyrelease_event=_xfdashboard_focusable_real_handle_keyrelease_event;
}
/* Implementation: Public API */
@@ -151,22 +162,71 @@ void xfdashboard_focusable_unset_focus(XfdashboardFocusable *self)
XFDASHBOARD_FOCUSABLE_WARN_NOT_IMPLEMENTED(self, "unset_focus");
}
-/* Call virtual function "handle_key_event" */
+/* Call key handling function depending on key event type */
gboolean xfdashboard_focusable_handle_key_event(XfdashboardFocusable *self, const ClutterEvent *inEvent)
{
+ g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(inEvent, CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(clutter_event_type(inEvent)==CLUTTER_KEY_PRESS ||
+ clutter_event_type(inEvent)==CLUTTER_KEY_RELEASE, CLUTTER_EVENT_PROPAGATE);
+
+ switch(clutter_event_type(inEvent))
+ {
+ case CLUTTER_KEY_PRESS:
+ return(xfdashboard_focusable_handle_keypress_event(self, inEvent));
+
+ case CLUTTER_KEY_RELEASE:
+ return(xfdashboard_focusable_handle_keyrelease_event(self, inEvent));
+
+ default:
+ /* We should never get here */
+ g_assert_not_reached();
+ break;
+ }
+
+ return(CLUTTER_EVENT_PROPAGATE);
+}
+
+/* Call virtual function "handle_keypress_event" */
+gboolean xfdashboard_focusable_handle_keypress_event(XfdashboardFocusable *self, const ClutterEvent *inEvent)
+{
XfdashboardFocusableInterface *iface;
- g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), FALSE);
+ g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(inEvent, CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(clutter_event_type(inEvent)==CLUTTER_KEY_PRESS, CLUTTER_EVENT_PROPAGATE);
iface=XFDASHBOARD_FOCUSABLE_GET_IFACE(self);
/* Call virtual function */
- if(iface->handle_key_event)
+ if(iface->handle_keypress_event)
{
- return(iface->handle_key_event(self, inEvent));
+ return(iface->handle_keypress_event(self, inEvent));
}
/* If we get here the virtual function was not overridden */
- XFDASHBOARD_FOCUSABLE_WARN_NOT_IMPLEMENTED(self, "handle_key_event");
- return(FALSE);
+ XFDASHBOARD_FOCUSABLE_WARN_NOT_IMPLEMENTED(self, "handle_keypress_event");
+ return(CLUTTER_EVENT_PROPAGATE);
+}
+
+/* Call virtual function "handle_keypress_event" */
+gboolean xfdashboard_focusable_handle_keyrelease_event(XfdashboardFocusable *self, const ClutterEvent *inEvent)
+{
+ XfdashboardFocusableInterface *iface;
+
+ g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(self), CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(inEvent, CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(clutter_event_type(inEvent)==CLUTTER_KEY_RELEASE, CLUTTER_EVENT_PROPAGATE);
+
+ iface=XFDASHBOARD_FOCUSABLE_GET_IFACE(self);
+
+ /* Call virtual function */
+ if(iface->handle_keyrelease_event)
+ {
+ return(iface->handle_keyrelease_event(self, inEvent));
+ }
+
+ /* If we get here the virtual function was not overridden */
+ XFDASHBOARD_FOCUSABLE_WARN_NOT_IMPLEMENTED(self, "handle_keyrelease_event");
+ return(CLUTTER_EVENT_PROPAGATE);
}
diff --git a/src/focusable.h b/src/focusable.h
index e75ea1a..c25d86d 100644
--- a/src/focusable.h
+++ b/src/focusable.h
@@ -49,7 +49,8 @@ struct _XfdashboardFocusableInterface
void (*set_focus)(XfdashboardFocusable *self);
void (*unset_focus)(XfdashboardFocusable *self);
- gboolean (*handle_key_event)(XfdashboardFocusable *self, const ClutterEvent *inEvent);
+ gboolean (*handle_keypress_event)(XfdashboardFocusable *self, const ClutterEvent *inEvent);
+ gboolean (*handle_keyrelease_event)(XfdashboardFocusable *self, const ClutterEvent *inEvent);
};
/* Public API */
@@ -60,6 +61,8 @@ void xfdashboard_focusable_set_focus(XfdashboardFocusable *self);
void xfdashboard_focusable_unset_focus(XfdashboardFocusable *self);
gboolean xfdashboard_focusable_handle_key_event(XfdashboardFocusable *self, const ClutterEvent *inEvent);
+gboolean xfdashboard_focusable_handle_keypress_event(XfdashboardFocusable *self, const ClutterEvent *inEvent);
+gboolean xfdashboard_focusable_handle_keyrelease_event(XfdashboardFocusable *self, const ClutterEvent *inEvent);
G_END_DECLS
diff --git a/src/quicklaunch.c b/src/quicklaunch.c
index ea1b55a..eac4c6e 100644
--- a/src/quicklaunch.c
+++ b/src/quicklaunch.c
@@ -1455,9 +1455,9 @@ static void _xfdashboard_quicklaunch_focusable_unset_focus(XfdashboardFocusable
}
}
-/* Virtual function "handle_key_event" was called */
-static gboolean _xfdashboard_quicklaunch_focusable_handle_key_event(XfdashboardFocusable *inFocusable,
- const ClutterEvent *inEvent)
+/* Virtual function "handle_keypress_event" was called */
+static gboolean _xfdashboard_quicklaunch_focusable_handle_keypress_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
{
XfdashboardQuicklaunch *self;
XfdashboardQuicklaunchPrivate *priv;
@@ -1469,17 +1469,35 @@ static gboolean _xfdashboard_quicklaunch_focusable_handle_key_event(XfdashboardF
self=XFDASHBOARD_QUICKLAUNCH(inFocusable);
priv=self->priv;
- /* Handle key events when key was released */
- if(clutter_event_type(inEvent)==CLUTTER_KEY_RELEASE)
+ /* Move selection if an arrow key was pressed which makes sense
+ * for orientation set
+ */
+ if((priv->orientation==CLUTTER_ORIENTATION_VERTICAL && inEvent->key.keyval==CLUTTER_KEY_Up) ||
+ (priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL && inEvent->key.keyval==CLUTTER_KEY_Left))
{
- /* Move selection if an arrow key was pressed which makes sense
- * for orientation set
- */
- if((priv->orientation==CLUTTER_ORIENTATION_VERTICAL && inEvent->key.keyval==CLUTTER_KEY_Up) ||
- (priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL && inEvent->key.keyval==CLUTTER_KEY_Left))
+ /* Find previous item to select and set style to it but also unstyle previous one */
+ newItem=xfdashboard_quicklaunch_get_previous_selectable(self, priv->selectedItem);
+ if(newItem && newItem!=priv->selectedItem)
+ {
+ /* Unset current selected item if any */
+ if(priv->selectedItem)
+ {
+ xfdashboard_stylable_remove_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
+ }
+
+ /* Set new current selected item */
+ priv->selectedItem=newItem;
+ xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
+ }
+
+ /* Event handled */
+ return(CLUTTER_EVENT_STOP);
+ }
+ else if((priv->orientation==CLUTTER_ORIENTATION_VERTICAL && inEvent->key.keyval==CLUTTER_KEY_Down) ||
+ (priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL && inEvent->key.keyval==CLUTTER_KEY_Right))
{
- /* Find previous item to select and set style to it but also unstyle previous one */
- newItem=xfdashboard_quicklaunch_get_previous_selectable(self, priv->selectedItem);
+ /* Find next item to select and set style to it but also unstyle previous one */
+ newItem=xfdashboard_quicklaunch_get_next_selectable(self, priv->selectedItem);
if(newItem && newItem!=priv->selectedItem)
{
/* Unset current selected item if any */
@@ -1496,42 +1514,37 @@ static gboolean _xfdashboard_quicklaunch_focusable_handle_key_event(XfdashboardF
/* Event handled */
return(CLUTTER_EVENT_STOP);
}
- else if((priv->orientation==CLUTTER_ORIENTATION_VERTICAL && inEvent->key.keyval==CLUTTER_KEY_Down) ||
- (priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL && inEvent->key.keyval==CLUTTER_KEY_Right))
- {
- /* Find next item to select and set style to it but also unstyle previous one */
- newItem=xfdashboard_quicklaunch_get_next_selectable(self, priv->selectedItem);
- if(newItem && newItem!=priv->selectedItem)
- {
- /* Unset current selected item if any */
- if(priv->selectedItem)
- {
- xfdashboard_stylable_remove_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
- }
-
- /* Set new current selected item */
- priv->selectedItem=newItem;
- xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
- }
- /* Event handled */
- return(CLUTTER_EVENT_STOP);
- }
+ /* We did not handle this event */
+ return(CLUTTER_EVENT_PROPAGATE);
+}
- /* Activate workspace on ENTER */
- if(inEvent->key.keyval==CLUTTER_KEY_Return ||
- inEvent->key.keyval==CLUTTER_KEY_KP_Enter ||
- inEvent->key.keyval==CLUTTER_KEY_ISO_Enter)
- {
- /* Emit "clicked" signal at selected item */
- if(priv->selectedItem)
- {
- g_signal_emit_by_name(priv->selectedItem, "clicked");
- }
+/* Virtual function "handle_keyrelease_event" was called */
+static gboolean _xfdashboard_quicklaunch_focusable_handle_keyrelease_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
+{
+ XfdashboardQuicklaunch *self;
+ XfdashboardQuicklaunchPrivate *priv;
- /* Event handled */
- return(CLUTTER_EVENT_STOP);
+ g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(XFDASHBOARD_IS_QUICKLAUNCH(inFocusable), CLUTTER_EVENT_PROPAGATE);
+
+ self=XFDASHBOARD_QUICKLAUNCH(inFocusable);
+ priv=self->priv;
+
+ /* Activate selected icon on ENTER */
+ if(inEvent->key.keyval==CLUTTER_KEY_Return ||
+ inEvent->key.keyval==CLUTTER_KEY_KP_Enter ||
+ inEvent->key.keyval==CLUTTER_KEY_ISO_Enter)
+ {
+ /* Emit "clicked" signal at selected item */
+ if(priv->selectedItem)
+ {
+ g_signal_emit_by_name(priv->selectedItem, "clicked");
}
+
+ /* Event handled */
+ return(CLUTTER_EVENT_STOP);
}
/* We did not handle this event */
@@ -1545,7 +1558,8 @@ void _xfdashboard_quicklaunch_focusable_iface_init(XfdashboardFocusableInterface
{
iface->set_focus=_xfdashboard_quicklaunch_focusable_set_focus;
iface->unset_focus=_xfdashboard_quicklaunch_focusable_unset_focus;
- iface->handle_key_event=_xfdashboard_quicklaunch_focusable_handle_key_event;
+ iface->handle_keypress_event=_xfdashboard_quicklaunch_focusable_handle_keypress_event;
+ iface->handle_keyrelease_event=_xfdashboard_quicklaunch_focusable_handle_keyrelease_event;
}
/* IMPLEMENTATION: GObject */
diff --git a/src/search-view.c b/src/search-view.c
index 935b271..de6f6ab 100644
--- a/src/search-view.c
+++ b/src/search-view.c
@@ -754,8 +754,8 @@ static void _xfdashboard_search_view_focusable_unset_focus(XfdashboardFocusable
}
/* Virtual function "handle_key_event" was called */
-static gboolean _xfdashboard_search_view_focusable_handle_key_event(XfdashboardFocusable *inFocusable,
- const ClutterEvent *inEvent)
+static gboolean _xfdashboard_search_view_focusable_handle_keypress_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
{
XfdashboardSearchView *self;
XfdashboardSearchViewPrivate *priv;
@@ -770,38 +770,12 @@ static gboolean _xfdashboard_search_view_focusable_handle_key_event(XfdashboardF
/* Handle key events at container of selected provider */
if(priv->selectionProvider &&
- priv->selectionProvider->container &&
- clutter_event_type(inEvent)==CLUTTER_KEY_RELEASE)
+ priv->selectionProvider->container)
{
- ClutterActor *currentSelection;
ClutterActor *newSelection;
gboolean doGetPrevious;
gint selectionDirection;
- /* Emit click on current selection when ENTER was pressed */
- switch(inEvent->key.keyval)
- {
- case CLUTTER_KEY_Return:
- case CLUTTER_KEY_KP_Enter:
- case CLUTTER_KEY_ISO_Enter:
- /* Get current selection to lookup mapping */
- currentSelection=xfdashboard_search_result_container_get_current_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container));
- if(currentSelection)
- {
- XfdashboardSearchViewProviderItemsMapping *mapping;
-
- /* Get mapping of current selection to determine actor where to emit click action */
- mapping=_xfdashboard_search_view_provider_data_get_mapping_by_actor(priv->selectionProvider, currentSelection);
- if(mapping)
- {
- _xfdashboard_search_view_on_provider_item_actor_clicked(XFDASHBOARD_CLICK_ACTION(mapping->clickAction),
- mapping->actor,
- mapping);
- }
- }
- return(CLUTTER_EVENT_STOP);
- }
-
/* Move selection if an corresponding key was pressed */
switch(inEvent->key.keyval)
{
@@ -835,9 +809,6 @@ static gboolean _xfdashboard_search_view_focusable_handle_key_event(XfdashboardF
if(handledEvent==CLUTTER_EVENT_STOP)
{
- /* Get current selection to determine if selection has changed */
- currentSelection=xfdashboard_search_result_container_get_current_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container));
-
/* Get new selection */
if(doGetPrevious)
{
@@ -916,6 +887,56 @@ static gboolean _xfdashboard_search_view_focusable_handle_key_event(XfdashboardF
return(handledEvent);
}
+/* Virtual function "handle_keyrelease_event" was called */
+static gboolean _xfdashboard_search_view_focusable_handle_keyrelease_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
+{
+ XfdashboardSearchView *self;
+ XfdashboardSearchViewPrivate *priv;
+ gboolean handledEvent;
+
+ 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);
+
+ self=XFDASHBOARD_SEARCH_VIEW(inFocusable);
+ priv=self->priv;
+ handledEvent=CLUTTER_EVENT_PROPAGATE;
+
+ /* Handle key events at container of selected provider */
+ if(priv->selectionProvider &&
+ priv->selectionProvider->container)
+ {
+ ClutterActor *currentSelection;
+
+ /* Emit click on current selection when ENTER was pressed */
+ switch(inEvent->key.keyval)
+ {
+ case CLUTTER_KEY_Return:
+ case CLUTTER_KEY_KP_Enter:
+ case CLUTTER_KEY_ISO_Enter:
+ /* Get current selection to lookup mapping */
+ currentSelection=xfdashboard_search_result_container_get_current_selection(XFDASHBOARD_SEARCH_RESULT_CONTAINER(priv->selectionProvider->container));
+ if(currentSelection)
+ {
+ XfdashboardSearchViewProviderItemsMapping *mapping;
+
+ /* Get mapping of current selection to determine actor where to emit click action */
+ mapping=_xfdashboard_search_view_provider_data_get_mapping_by_actor(priv->selectionProvider, currentSelection);
+ if(mapping)
+ {
+ _xfdashboard_search_view_on_provider_item_actor_clicked(XFDASHBOARD_CLICK_ACTION(mapping->clickAction),
+ mapping->actor,
+ mapping);
+ }
+ }
+ return(CLUTTER_EVENT_STOP);
+ }
+ }
+
+ /* Return result of key handling */
+ return(handledEvent);
+}
+
/* Interface initialization
* Set up default functions
*/
@@ -924,7 +945,8 @@ void _xfdashboard_search_view_focusable_iface_init(XfdashboardFocusableInterface
iface->can_focus=_xfdashboard_search_view_focusable_can_focus;
iface->set_focus=_xfdashboard_search_view_focusable_set_focus;
iface->unset_focus=_xfdashboard_search_view_focusable_unset_focus;
- iface->handle_key_event=_xfdashboard_search_view_focusable_handle_key_event;
+ iface->handle_keypress_event=_xfdashboard_search_view_focusable_handle_keypress_event;
+ iface->handle_keyrelease_event=_xfdashboard_search_view_focusable_handle_keyrelease_event;
}
diff --git a/src/text-box.c b/src/text-box.c
index 1664121..6f4ef3a 100644
--- a/src/text-box.c
+++ b/src/text-box.c
@@ -490,30 +490,6 @@ static gboolean _xfdashboard_text_box_focusable_can_focus(XfdashboardFocusable *
return(FALSE);
}
-/* Virtual function "handle_key_event" was called */
-static gboolean _xfdashboard_text_box_focusable_handle_key_event(XfdashboardFocusable *inFocusable,
- const ClutterEvent *inEvent)
-{
- XfdashboardTextBox *self;
- XfdashboardTextBoxPrivate *priv;
- gboolean result;
-
- g_return_val_if_fail(XFDASHBOARD_IS_TEXT_BOX(inFocusable), CLUTTER_EVENT_PROPAGATE);
-
- self=XFDASHBOARD_TEXT_BOX(inFocusable);
- priv=self->priv;
- result=CLUTTER_EVENT_PROPAGATE;
-
- /* Push event to real text box if available */
- if(priv->actorTextBox)
- {
- result=clutter_actor_event(priv->actorTextBox, inEvent, FALSE);
- }
-
- /* Return event handling result */
- return(result);
-}
-
/* Set focus to actor */
static void _xfdashboard_text_box_focusable_set_focus(XfdashboardFocusable *inFocusable)
{
@@ -584,6 +560,54 @@ static void _xfdashboard_text_box_focusable_unset_focus(XfdashboardFocusable *in
clutter_stage_set_key_focus(stage, NULL);
}
+/* Virtual function "handle_keypress_event" was called */
+static gboolean _xfdashboard_text_box_focusable_handle_keypress_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
+{
+ XfdashboardTextBox *self;
+ XfdashboardTextBoxPrivate *priv;
+ gboolean result;
+
+ g_return_val_if_fail(XFDASHBOARD_IS_TEXT_BOX(inFocusable), CLUTTER_EVENT_PROPAGATE);
+
+ self=XFDASHBOARD_TEXT_BOX(inFocusable);
+ priv=self->priv;
+ result=CLUTTER_EVENT_PROPAGATE;
+
+ /* Push event to real text box if available */
+ if(priv->actorTextBox)
+ {
+ result=clutter_actor_event(priv->actorTextBox, inEvent, FALSE);
+ }
+
+ /* Return event handling result */
+ return(result);
+}
+
+/* Virtual function "handle_keyrelease_event" was called */
+static gboolean _xfdashboard_text_box_focusable_handle_keyrelease_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
+{
+ XfdashboardTextBox *self;
+ XfdashboardTextBoxPrivate *priv;
+ gboolean result;
+
+ g_return_val_if_fail(XFDASHBOARD_IS_TEXT_BOX(inFocusable), CLUTTER_EVENT_PROPAGATE);
+
+ self=XFDASHBOARD_TEXT_BOX(inFocusable);
+ priv=self->priv;
+ result=CLUTTER_EVENT_PROPAGATE;
+
+ /* Push event to real text box if available */
+ if(priv->actorTextBox)
+ {
+ result=clutter_actor_event(priv->actorTextBox, inEvent, FALSE);
+ }
+
+ /* Return event handling result */
+ return(result);
+}
+
/* Interface initialization
* Set up default functions
*/
@@ -592,7 +616,8 @@ void _xfdashboard_text_box_focusable_iface_init(XfdashboardFocusableInterface *i
iface->can_focus=_xfdashboard_text_box_focusable_can_focus;
iface->set_focus=_xfdashboard_text_box_focusable_set_focus;
iface->unset_focus=_xfdashboard_text_box_focusable_unset_focus;
- iface->handle_key_event=_xfdashboard_text_box_focusable_handle_key_event;
+ iface->handle_keypress_event=_xfdashboard_text_box_focusable_handle_keypress_event;
+ iface->handle_keyrelease_event=_xfdashboard_text_box_focusable_handle_keyrelease_event;
}
/* IMPLEMENTATION: GObject */
diff --git a/src/viewpad.c b/src/viewpad.c
index 555e88c..22560d2 100644
--- a/src/viewpad.c
+++ b/src/viewpad.c
@@ -999,9 +999,9 @@ static void _xfdashboard_viewpad_focusable_unset_focus(XfdashboardFocusable *inF
}
}
-/* Virtual function "handle_key_event" was called */
-static gboolean _xfdashboard_viewpad_focusable_handle_key_event(XfdashboardFocusable *inFocusable,
- const ClutterEvent *inEvent)
+/* Virtual function "handle_keypress_event" was called */
+static gboolean _xfdashboard_viewpad_focusable_handle_keypress_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
{
XfdashboardViewpad *self;
XfdashboardViewpadPrivate *priv;
@@ -1026,7 +1026,41 @@ static gboolean _xfdashboard_viewpad_focusable_handle_key_event(XfdashboardFocus
if(priv->activeView &&
XFDASHBOARD_IS_FOCUSABLE(priv->activeView))
{
- handledEvent=xfdashboard_focusable_handle_key_event(XFDASHBOARD_FOCUSABLE(priv->activeView), inEvent);
+ handledEvent=xfdashboard_focusable_handle_keypress_event(XFDASHBOARD_FOCUSABLE(priv->activeView), inEvent);
+ }
+
+ /* Return focusable state */
+ return(handledEvent);
+}
+
+/* Virtual function "handle_keyrelease_event" was called */
+static gboolean _xfdashboard_viewpad_focusable_handle_keyrelease_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
+{
+ XfdashboardViewpad *self;
+ XfdashboardViewpadPrivate *priv;
+ gboolean handledEvent;
+
+ g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(XFDASHBOARD_IS_VIEWPAD(inFocusable), CLUTTER_EVENT_PROPAGATE);
+
+ self=XFDASHBOARD_VIEWPAD(inFocusable);
+ priv=self->priv;
+
+ /* Set handled key eventto CLUTTER_EVENT_PROPAGATE. It might be set to
+ * CLUTTER_EVENT_STOP if current active view is focusable and it handled
+ * the key event by its virtual function.
+ */
+ handledEvent=CLUTTER_EVENT_PROPAGATE;
+
+ /* Viewpad is just a proxy for the current active view.
+ * So check if current active view is focusable and call its
+ * virtual function.
+ */
+ if(priv->activeView &&
+ XFDASHBOARD_IS_FOCUSABLE(priv->activeView))
+ {
+ handledEvent=xfdashboard_focusable_handle_keyrelease_event(XFDASHBOARD_FOCUSABLE(priv->activeView), inEvent);
}
/* Return focusable state */
@@ -1041,7 +1075,8 @@ void _xfdashboard_viewpad_focusable_iface_init(XfdashboardFocusableInterface *if
iface->can_focus=_xfdashboard_viewpad_focusable_can_focus;
iface->set_focus=_xfdashboard_viewpad_focusable_set_focus;
iface->unset_focus=_xfdashboard_viewpad_focusable_unset_focus;
- iface->handle_key_event=_xfdashboard_viewpad_focusable_handle_key_event;
+ iface->handle_keypress_event=_xfdashboard_viewpad_focusable_handle_keypress_event;
+ iface->handle_keyrelease_event=_xfdashboard_viewpad_focusable_handle_keyrelease_event;
}
/* IMPLEMENTATION: GObject */
diff --git a/src/windows-view.c b/src/windows-view.c
index 7eb02a8..171727e 100644
--- a/src/windows-view.c
+++ b/src/windows-view.c
@@ -689,9 +689,9 @@ static void _xfdashboard_windows_view_focusable_unset_focus(XfdashboardFocusable
}
}
-/* Virtual function "handle_key_event" was called */
-static gboolean _xfdashboard_windows_view_focusable_handle_key_event(XfdashboardFocusable *inFocusable,
- const ClutterEvent *inEvent)
+/* Virtual function "handle_keypress_event" was called */
+static gboolean _xfdashboard_windows_view_focusable_handle_keypress_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
{
XfdashboardWindowsView *self;
XfdashboardWindowsViewPrivate *priv;
@@ -702,142 +702,155 @@ static gboolean _xfdashboard_windows_view_focusable_handle_key_event(Xfdashboard
self=XFDASHBOARD_WINDOWS_VIEW(inFocusable);
priv=self->priv;
- /* Handle key events when key was released */
- if(clutter_event_type(inEvent)==CLUTTER_KEY_RELEASE)
+ /* Move selection if an arrow key was pressed */
+ if(inEvent->key.keyval==CLUTTER_KEY_Left ||
+ inEvent->key.keyval==CLUTTER_KEY_Right ||
+ inEvent->key.keyval==CLUTTER_KEY_Up ||
+ inEvent->key.keyval==CLUTTER_KEY_Down)
{
- /* Activate selected window on ENTER or close window on DELETE/BACKSPACE */
- switch(inEvent->key.keyval)
+ gint index;
+ gint newIndex;
+ gint numberChildren;
+ gint rows;
+ gint columns;
+ gint selectionRow;
+ gint selectionColumn;
+ ClutterActorIter iter;
+ ClutterActor *child;
+
+ /* If there is nothing selected, select first actor and return */
+ if(!priv->selectedItem)
{
- case CLUTTER_KEY_Return:
- case CLUTTER_KEY_KP_Enter:
- case CLUTTER_KEY_ISO_Enter:
- if(priv->selectedItem)
- {
- _xfdashboard_windows_view_on_window_clicked(self, XFDASHBOARD_LIVE_WINDOW(priv->selectedItem));
- }
- return(CLUTTER_EVENT_STOP);
+ priv->selectedItem=clutter_actor_get_first_child(CLUTTER_ACTOR(self));
- case CLUTTER_KEY_BackSpace:
- case CLUTTER_KEY_Delete:
- case CLUTTER_KEY_KP_Delete:
- if(priv->selectedItem)
- {
- _xfdashboard_windows_view_on_window_close_clicked(self, XFDASHBOARD_LIVE_WINDOW(priv->selectedItem));
- }
- return(CLUTTER_EVENT_STOP);
+ if(priv->selectedItem)
+ {
+ xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
+ }
+
+ return(CLUTTER_EVENT_STOP);
}
- /* Move selection if an arrow key was pressed */
- if(inEvent->key.keyval==CLUTTER_KEY_Left ||
- inEvent->key.keyval==CLUTTER_KEY_Right ||
- inEvent->key.keyval==CLUTTER_KEY_Up ||
- inEvent->key.keyval==CLUTTER_KEY_Down)
+ /* Get number of rows and columns and also get number of children
+ * of layout manager.
+ */
+ numberChildren=xfdashboard_scaled_table_layout_get_number_children(XFDASHBOARD_SCALED_TABLE_LAYOUT(priv->layout));
+ rows=xfdashboard_scaled_table_layout_get_rows(XFDASHBOARD_SCALED_TABLE_LAYOUT(priv->layout));
+ columns=xfdashboard_scaled_table_layout_get_columns(XFDASHBOARD_SCALED_TABLE_LAYOUT(priv->layout));
+
+ /* Get index of current selection */
+ newIndex=index=0;
+ clutter_actor_iter_init(&iter, CLUTTER_ACTOR(self));
+ while(clutter_actor_iter_next(&iter, &child) &&
+ child!=priv->selectedItem)
{
- gint index;
- gint newIndex;
- gint numberChildren;
- gint rows;
- gint columns;
- gint selectionRow;
- gint selectionColumn;
- ClutterActorIter iter;
- ClutterActor *child;
-
- /* If there is nothing selected, select first actor and return */
- if(!priv->selectedItem)
- {
- priv->selectedItem=clutter_actor_get_first_child(CLUTTER_ACTOR(self));
-
- if(priv->selectedItem)
- {
- xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
- }
+ index++;
+ newIndex++;
+ }
- return(CLUTTER_EVENT_STOP);
- }
+ selectionRow=(index / columns);
+ selectionColumn=(index % columns);
- /* Get number of rows and columns and also get number of children
- * of layout manager.
- */
- numberChildren=xfdashboard_scaled_table_layout_get_number_children(XFDASHBOARD_SCALED_TABLE_LAYOUT(priv->layout));
- rows=xfdashboard_scaled_table_layout_get_rows(XFDASHBOARD_SCALED_TABLE_LAYOUT(priv->layout));
- columns=xfdashboard_scaled_table_layout_get_columns(XFDASHBOARD_SCALED_TABLE_LAYOUT(priv->layout));
-
- /* Get index of current selection */
- newIndex=index=0;
- clutter_actor_iter_init(&iter, CLUTTER_ACTOR(self));
- while(clutter_actor_iter_next(&iter, &child) &&
- child!=priv->selectedItem)
+ /* Determine index of new selection depending on arrow key pressed */
+ if(columns>1 && inEvent->key.keyval==CLUTTER_KEY_Left)
+ {
+ newIndex--;
+ if(newIndex<(selectionRow*columns))
{
- index++;
- newIndex++;
+ newIndex=(selectionRow*columns)+columns-1;
+ if(newIndex>=numberChildren) newIndex=numberChildren-1;
}
+ }
- selectionRow=(index / columns);
- selectionColumn=(index % columns);
-
- /* Determine index of new selection depending on arrow key pressed */
- if(columns>1 && inEvent->key.keyval==CLUTTER_KEY_Left)
+ if(columns>1 && inEvent->key.keyval==CLUTTER_KEY_Right)
+ {
+ newIndex++;
+ if(newIndex>=((selectionRow+1)*columns) ||
+ newIndex>=numberChildren)
{
- newIndex--;
- if(newIndex<(selectionRow*columns))
- {
- newIndex=(selectionRow*columns)+columns-1;
- if(newIndex>=numberChildren) newIndex=numberChildren-1;
- }
+ newIndex=(selectionRow*columns);
}
+ }
- if(columns>1 && inEvent->key.keyval==CLUTTER_KEY_Right)
+ if(rows>1 && inEvent->key.keyval==CLUTTER_KEY_Up)
+ {
+ newIndex-=columns;
+ if(newIndex<0)
{
- newIndex++;
- if(newIndex>=((selectionRow+1)*columns) ||
- newIndex>=numberChildren)
- {
- newIndex=(selectionRow*columns);
- }
+ newIndex=((rows-1)*columns)+selectionColumn;
+ if(newIndex>=numberChildren) newIndex-=columns;
}
+ }
- if(rows>1 && inEvent->key.keyval==CLUTTER_KEY_Up)
- {
- newIndex-=columns;
- if(newIndex<0)
- {
- newIndex=((rows-1)*columns)+selectionColumn;
- if(newIndex>=numberChildren) newIndex-=columns;
- }
- }
+ if(rows>1 && inEvent->key.keyval==CLUTTER_KEY_Down)
+ {
+ newIndex+=columns;
+ if(newIndex>=numberChildren) newIndex=selectionColumn;
+ }
- if(rows>1 && inEvent->key.keyval==CLUTTER_KEY_Down)
- {
- newIndex+=columns;
- if(newIndex>=numberChildren) newIndex=selectionColumn;
- }
+ /* Only change selection and update the affected actors if index of
+ * new and old selection differ.
+ */
+ if(newIndex==index) return(CLUTTER_EVENT_STOP);
- /* Only change selection and update the affected actors if index of
- * new and old selection differ.
- */
- if(newIndex==index) return(CLUTTER_EVENT_STOP);
+ /* Unstyle current selection */
+ xfdashboard_stylable_remove_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
- /* Unstyle current selection */
- xfdashboard_stylable_remove_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
+ /* Get new selection and style it */
+ index=newIndex;
+ clutter_actor_iter_init(&iter, CLUTTER_ACTOR(self));
+ while(clutter_actor_iter_next(&iter, &priv->selectedItem) &&
+ index>0)
+ {
+ index--;
+ }
- /* Get new selection and style it */
- index=newIndex;
- clutter_actor_iter_init(&iter, CLUTTER_ACTOR(self));
- while(clutter_actor_iter_next(&iter, &priv->selectedItem) &&
- index>0)
+ if(priv->selectedItem)
+ {
+ xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
+ }
+
+ /* Event handled */
+ return(CLUTTER_EVENT_STOP);
+ }
+
+ /* We did not handle this event */
+ return(CLUTTER_EVENT_PROPAGATE);
+}
+
+/* Virtual function "handle_key_event" was called */
+static gboolean _xfdashboard_windows_view_focusable_handle_keyrelease_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
+{
+ XfdashboardWindowsView *self;
+ XfdashboardWindowsViewPrivate *priv;
+
+ g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(XFDASHBOARD_IS_WINDOWS_VIEW(inFocusable), CLUTTER_EVENT_PROPAGATE);
+
+ self=XFDASHBOARD_WINDOWS_VIEW(inFocusable);
+ priv=self->priv;
+
+ /* Activate selected window on ENTER or close window on DELETE/BACKSPACE */
+ switch(inEvent->key.keyval)
+ {
+ case CLUTTER_KEY_Return:
+ case CLUTTER_KEY_KP_Enter:
+ case CLUTTER_KEY_ISO_Enter:
+ if(priv->selectedItem)
{
- index--;
+ _xfdashboard_windows_view_on_window_clicked(self, XFDASHBOARD_LIVE_WINDOW(priv->selectedItem));
}
+ return(CLUTTER_EVENT_STOP);
+ case CLUTTER_KEY_BackSpace:
+ case CLUTTER_KEY_Delete:
+ case CLUTTER_KEY_KP_Delete:
if(priv->selectedItem)
{
- xfdashboard_stylable_add_pseudo_class(XFDASHBOARD_STYLABLE(priv->selectedItem), "selected");
+ _xfdashboard_windows_view_on_window_close_clicked(self, XFDASHBOARD_LIVE_WINDOW(priv->selectedItem));
}
-
- /* Event handled */
return(CLUTTER_EVENT_STOP);
- }
}
/* We did not handle this event */
@@ -852,7 +865,8 @@ void _xfdashboard_windows_view_focusable_iface_init(XfdashboardFocusableInterfac
iface->can_focus=_xfdashboard_windows_view_focusable_can_focus;
iface->set_focus=_xfdashboard_windows_view_focusable_set_focus;
iface->unset_focus=_xfdashboard_windows_view_focusable_unset_focus;
- iface->handle_key_event=_xfdashboard_windows_view_focusable_handle_key_event;
+ iface->handle_keypress_event=_xfdashboard_windows_view_focusable_handle_keypress_event;
+ iface->handle_keyrelease_event=_xfdashboard_windows_view_focusable_handle_keyrelease_event;
}
/* IMPLEMENTATION: GObject */
diff --git a/src/workspace-selector.c b/src/workspace-selector.c
index de15bfa..1f12e03 100644
--- a/src/workspace-selector.c
+++ b/src/workspace-selector.c
@@ -801,9 +801,9 @@ static void _xfdashboard_workspace_selector_allocate(ClutterActor *inActor,
/* IMPLEMENTATION: Interface XfdashboardFocusable */
-/* Virtual function "handle_key_event" was called */
-static gboolean _xfdashboard_workspace_selector_focusable_handle_key_event(XfdashboardFocusable *inFocusable,
- const ClutterEvent *inEvent)
+/* Virtual function "handle_keypress_event" was called */
+static gboolean _xfdashboard_workspace_selector_focusable_handle_keypress_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
{
XfdashboardWorkspaceSelector *self;
XfdashboardWorkspaceSelectorPrivate *priv;
@@ -817,22 +817,32 @@ static gboolean _xfdashboard_workspace_selector_focusable_handle_key_event(Xfdas
self=XFDASHBOARD_WORKSPACE_SELECTOR(inFocusable);
priv=self->priv;
- /* Handle key events when key was released */
- if(clutter_event_type(inEvent)==CLUTTER_KEY_RELEASE)
+ /* Get current and last workspace */
+ currentWorkspace=xfdashboard_window_tracker_workspace_get_number(priv->activeWorkspace);
+ maxWorkspace=xfdashboard_window_tracker_get_workspaces_count(priv->windowTracker);
+
+ /* Change workspace if an arrow key was pressed which makes sense
+ * for orientation set
+ */
+ if((priv->orientation==CLUTTER_ORIENTATION_VERTICAL && inEvent->key.keyval==CLUTTER_KEY_Up) ||
+ (priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL && inEvent->key.keyval==CLUTTER_KEY_Left))
{
- /* Get current and last workspace */
- currentWorkspace=xfdashboard_window_tracker_workspace_get_number(priv->activeWorkspace);
- maxWorkspace=xfdashboard_window_tracker_get_workspaces_count(priv->windowTracker);
+ /* Activate previous workspace */
+ currentWorkspace--;
+ if(currentWorkspace<0) currentWorkspace=maxWorkspace-1;
- /* Change workspace if an arrow key was pressed which makes sense
- * for orientation set
- */
- if((priv->orientation==CLUTTER_ORIENTATION_VERTICAL && inEvent->key.keyval==CLUTTER_KEY_Up) ||
- (priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL && inEvent->key.keyval==CLUTTER_KEY_Left))
+ workspace=xfdashboard_window_tracker_get_workspace_by_number(priv->windowTracker, currentWorkspace);
+ xfdashboard_window_tracker_workspace_activate(workspace);
+
+ /* Event handled */
+ return(CLUTTER_EVENT_STOP);
+ }
+ else if((priv->orientation==CLUTTER_ORIENTATION_VERTICAL && inEvent->key.keyval==CLUTTER_KEY_Down) ||
+ (priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL && inEvent->key.keyval==CLUTTER_KEY_Right))
{
- /* Activate previous workspace */
- currentWorkspace--;
- if(currentWorkspace<0) currentWorkspace=maxWorkspace-1;
+ /* Activate next workspace */
+ currentWorkspace++;
+ if(currentWorkspace>=maxWorkspace) currentWorkspace=0;
workspace=xfdashboard_window_tracker_get_workspace_by_number(priv->windowTracker, currentWorkspace);
xfdashboard_window_tracker_workspace_activate(workspace);
@@ -840,35 +850,43 @@ static gboolean _xfdashboard_workspace_selector_focusable_handle_key_event(Xfdas
/* Event handled */
return(CLUTTER_EVENT_STOP);
}
- else if((priv->orientation==CLUTTER_ORIENTATION_VERTICAL && inEvent->key.keyval==CLUTTER_KEY_Down) ||
- (priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL && inEvent->key.keyval==CLUTTER_KEY_Right))
- {
- /* Activate next workspace */
- currentWorkspace++;
- if(currentWorkspace>=maxWorkspace) currentWorkspace=0;
- workspace=xfdashboard_window_tracker_get_workspace_by_number(priv->windowTracker, currentWorkspace);
- xfdashboard_window_tracker_workspace_activate(workspace);
+ /* We did not handle this event */
+ return(CLUTTER_EVENT_PROPAGATE);
+}
- /* Event handled */
- return(CLUTTER_EVENT_STOP);
- }
+/* Virtual function "handle_keyrelease_event" was called */
+static gboolean _xfdashboard_workspace_selector_focusable_handle_keyrelease_event(XfdashboardFocusable *inFocusable,
+ const ClutterEvent *inEvent)
+{
+ XfdashboardWorkspaceSelector *self;
+ XfdashboardWorkspaceSelectorPrivate *priv;
+ gint currentWorkspace;
+ XfdashboardWindowTrackerWorkspace *workspace;
- /* Activate workspace on ENTER */
- if(inEvent->key.keyval==CLUTTER_KEY_Return ||
- inEvent->key.keyval==CLUTTER_KEY_KP_Enter ||
- inEvent->key.keyval==CLUTTER_KEY_ISO_Enter)
- {
- /* Active workspace */
- workspace=xfdashboard_window_tracker_get_workspace_by_number(priv->windowTracker, currentWorkspace);
- xfdashboard_window_tracker_workspace_activate(workspace);
+ g_return_val_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable), CLUTTER_EVENT_PROPAGATE);
+ g_return_val_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(inFocusable), CLUTTER_EVENT_PROPAGATE);
+
+ self=XFDASHBOARD_WORKSPACE_SELECTOR(inFocusable);
+ priv=self->priv;
- /* Quit application */
- xfdashboard_application_quit();
+ /* Activate workspace on ENTER */
+ if(inEvent->key.keyval==CLUTTER_KEY_Return ||
+ inEvent->key.keyval==CLUTTER_KEY_KP_Enter ||
+ inEvent->key.keyval==CLUTTER_KEY_ISO_Enter)
+ {
+ /* Get current workspace */
+ currentWorkspace=xfdashboard_window_tracker_workspace_get_number(priv->activeWorkspace);
- /* Event handled */
- return(CLUTTER_EVENT_STOP);
- }
+ /* Active workspace */
+ workspace=xfdashboard_window_tracker_get_workspace_by_number(priv->windowTracker, currentWorkspace);
+ xfdashboard_window_tracker_workspace_activate(workspace);
+
+ /* Quit application */
+ xfdashboard_application_quit();
+
+ /* Event handled */
+ return(CLUTTER_EVENT_STOP);
}
/* We did not handle this event */
@@ -880,7 +898,8 @@ static gboolean _xfdashboard_workspace_selector_focusable_handle_key_event(Xfdas
*/
void _xfdashboard_workspace_selector_focusable_iface_init(XfdashboardFocusableInterface *iface)
{
- iface->handle_key_event=_xfdashboard_workspace_selector_focusable_handle_key_event;
+ iface->handle_keypress_event=_xfdashboard_workspace_selector_focusable_handle_keypress_event;
+ iface->handle_keyrelease_event=_xfdashboard_workspace_selector_focusable_handle_keyrelease_event;
}
/* IMPLEMENTATION: GObject */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list