1 /* 2 * focus-manager: Single-instance managing focusable actors 3 * for keyboard navigation 4 * 5 * Copyright 2012-2020 Stephan Haller <nomad@froevel.de> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 20 * MA 02110-1301, USA. 21 * 22 * 23 */ 24 25 #ifndef __LIBXFDASHBOARD_FOCUS_MANAGER__ 26 #define __LIBXFDASHBOARD_FOCUS_MANAGER__ 27 28 #if !defined(__LIBXFDASHBOARD_H_INSIDE__) && !defined(LIBXFDASHBOARD_COMPILATION) 29 #error "Only <libxfdashboard/libxfdashboard.h> can be included directly." 30 #endif 31 32 #include <glib-object.h> 33 34 #include <libxfdashboard/focusable.h> 35 36 G_BEGIN_DECLS 37 38 #define XFDASHBOARD_TYPE_FOCUS_MANAGER (xfdashboard_focus_manager_get_type()) 39 #define XFDASHBOARD_FOCUS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFDASHBOARD_TYPE_FOCUS_MANAGER, XfdashboardFocusManager)) 40 #define XFDASHBOARD_IS_FOCUS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFDASHBOARD_TYPE_FOCUS_MANAGER)) 41 #define XFDASHBOARD_FOCUS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XFDASHBOARD_TYPE_FOCUS_MANAGER, XfdashboardFocusManagerClass)) 42 #define XFDASHBOARD_IS_FOCUS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), XFDASHBOARD_TYPE_FOCUS_MANAGER)) 43 #define XFDASHBOARD_FOCUS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XFDASHBOARD_TYPE_FOCUS_MANAGER, XfdashboardFocusManagerClass)) 44 45 typedef struct _XfdashboardFocusManager XfdashboardFocusManager; 46 typedef struct _XfdashboardFocusManagerClass XfdashboardFocusManagerClass; 47 typedef struct _XfdashboardFocusManagerPrivate XfdashboardFocusManagerPrivate; 48 49 struct _XfdashboardFocusManager 50 { 51 /*< private >*/ 52 /* Parent instance */ 53 GObject parent_instance; 54 55 /* Private structure */ 56 XfdashboardFocusManagerPrivate *priv; 57 }; 58 59 struct _XfdashboardFocusManagerClass 60 { 61 /*< private >*/ 62 /* Parent class */ 63 GObjectClass parent_class; 64 65 /*< public >*/ 66 /* Virtual functions */ 67 void (*registered)(XfdashboardFocusManager *self, XfdashboardFocusable *inActor); 68 void (*unregistered)(XfdashboardFocusManager *self, XfdashboardFocusable *inActor); 69 70 void (*changed)(XfdashboardFocusManager *self, 71 XfdashboardFocusable *oldActor, 72 XfdashboardFocusable *newActor); 73 74 /* Binding actions */ 75 gboolean (*focus_move_first)(XfdashboardFocusManager *self, 76 XfdashboardFocusable *inSource, 77 const gchar *inAction, 78 ClutterEvent *inEvent); 79 gboolean (*focus_move_last)(XfdashboardFocusManager *self, 80 XfdashboardFocusable *inSource, 81 const gchar *inAction, 82 ClutterEvent *inEvent); 83 gboolean (*focus_move_next)(XfdashboardFocusManager *self, 84 XfdashboardFocusable *inSource, 85 const gchar *inAction, 86 ClutterEvent *inEvent); 87 gboolean (*focus_move_previous)(XfdashboardFocusManager *self, 88 XfdashboardFocusable *inSource, 89 const gchar *inAction, 90 ClutterEvent *inEvent); 91 }; 92 93 /* Public API */ 94 GType xfdashboard_focus_manager_get_type(void) G_GNUC_CONST; 95 96 XfdashboardFocusManager* xfdashboard_focus_manager_get_default(void); 97 98 void xfdashboard_focus_manager_register(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable); 99 void xfdashboard_focus_manager_register_after(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable, XfdashboardFocusable *inAfterFocusable); 100 void xfdashboard_focus_manager_unregister(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable); 101 GList* xfdashboard_focus_manager_get_registered(XfdashboardFocusManager *self); 102 gboolean xfdashboard_focus_manager_is_registered(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable); 103 104 GSList* xfdashboard_focus_manager_get_targets(XfdashboardFocusManager *self, const gchar *inTarget); 105 106 gboolean xfdashboard_focus_manager_has_focus(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable); 107 XfdashboardFocusable* xfdashboard_focus_manager_get_focus(XfdashboardFocusManager *self); 108 void xfdashboard_focus_manager_set_focus(XfdashboardFocusManager *self, XfdashboardFocusable *inFocusable); 109 110 XfdashboardFocusable* xfdashboard_focus_manager_get_next_focusable(XfdashboardFocusManager *self, 111 XfdashboardFocusable *inBeginFocusable); 112 XfdashboardFocusable* xfdashboard_focus_manager_get_previous_focusable(XfdashboardFocusManager *self, 113 XfdashboardFocusable *inBeginFocusable); 114 115 gboolean xfdashboard_focus_manager_get_event_targets_and_action(XfdashboardFocusManager *self, 116 const ClutterEvent *inEvent, 117 XfdashboardFocusable *inFocusable, 118 GSList **outTargets, 119 const gchar **outAction); 120 gboolean xfdashboard_focus_manager_handle_key_event(XfdashboardFocusManager *self, 121 const ClutterEvent *inEvent, 122 XfdashboardFocusable *inFocusable); 123 124 G_END_DECLS 125 126 #endif /* __LIBXFDASHBOARD_FOCUS_MANAGER__ */ 127