static void ntf_libnotify_update_modal (void) { NtfTray *tray = ntf_overlay_get_tray (TRUE); MetaPlugin *plugin = dawati_netbook_get_plugin_singleton (); if (ntf_tray_get_n_notifications (tray) > 0) { if (!overlay_focused) { MetaScreen *screen = meta_plugin_get_screen (plugin); ClutterActor *stage = meta_get_stage_for_screen (screen); MxFocusManager *manager = mx_focus_manager_get_for_stage (CLUTTER_STAGE (stage)); dawati_netbook_stash_window_focus (plugin, CurrentTime); mx_focus_manager_push_focus (manager, MX_FOCUSABLE (tray)); overlay_focused = TRUE; } } else { if (overlay_focused) { dawati_netbook_unstash_window_focus (plugin, CurrentTime); overlay_focused = FALSE; } } }
static void mx_menu_show (ClutterActor *actor) { ClutterAnimation *animation = NULL; ClutterStage *stage; /* set reactive and opacity, since these may have been set by the fade-out * animation (e.g. from captured_event_handler or button_release_cb) */ if ((animation = clutter_actor_get_animation (actor))) { clutter_animation_completed (animation); } clutter_actor_set_reactive (actor, TRUE); clutter_actor_set_opacity (actor, 0xff); /* chain up to run show after re-setting properties above */ CLUTTER_ACTOR_CLASS (mx_menu_parent_class)->show (actor); clutter_actor_grab_key_focus (actor); stage = (ClutterStage*) clutter_actor_get_stage (actor); mx_focus_manager_push_focus (mx_focus_manager_get_for_stage (stage), MX_FOCUSABLE (actor)); }
static gboolean mex_player_set_controls_visible (MexPlayer *player, gboolean visible) { MexPlayerPrivate *priv = player->priv; gfloat pos; ClutterStage *stage; MxFocusManager *fmanager; stage = (ClutterStage*) clutter_actor_get_stage (CLUTTER_ACTOR (player)); fmanager = mx_focus_manager_get_for_stage (stage); pos = clutter_actor_get_height (priv->controls); if (visible) { priv->controls_prev_visible = FALSE; priv->controls_visible = TRUE; mx_widget_set_disabled (MX_WIDGET (priv->controls), FALSE); clutter_actor_animate (priv->controls, CLUTTER_EASE_IN_SINE, 250, "opacity", 0xff, "anchor-y", 0.0, NULL); mex_player_restart_timer (player); if (priv->related_tile) { mx_focus_manager_push_focus_with_hint (fmanager, MX_FOCUSABLE (priv->related_tile), MX_FOCUS_HINT_PRIOR); g_object_unref (priv->related_tile); priv->related_tile = NULL; } else { mx_focus_manager_push_focus (fmanager, MX_FOCUSABLE (priv->controls)); } } if (!visible) { priv->controls_visible = FALSE; clutter_actor_animate (priv->controls, CLUTTER_EASE_IN_SINE, 250, "opacity", 0x00, "anchor-y", -pos, NULL); if (priv->hide_controls_source) { g_source_remove (priv->hide_controls_source); priv->hide_controls_source = 0; } } return TRUE; }
static void mex_content_box_notify_open_cb (MexExpanderBox *box, GParamSpec *pspec) { GList *actions; ClutterStage *stage = CLUTTER_STAGE ( clutter_actor_get_stage (CLUTTER_ACTOR (box))); MxFocusManager *fmanager = mx_focus_manager_get_for_stage (stage); MexActionManager *manager = mex_action_manager_get_default (); MexContentBoxPrivate *priv = MEX_CONTENT_BOX (box)->priv; gboolean open = mex_expander_box_get_open (box); if (!open) { /* If the action list has focus, push it back onto the tile */ if (mex_actor_has_focus (fmanager, priv->action_list)) mx_focus_manager_push_focus (fmanager, MX_FOCUSABLE (priv->tile)); return; } /* Refresh the info panel and the action list */ mex_content_view_set_content (MEX_CONTENT_VIEW (priv->panel), priv->content); mex_action_list_refresh (MEX_ACTION_LIST (priv->action_list)); /* See if we have any actions */ actions = mex_action_manager_get_actions_for_content (manager, priv->content); /* Push focus onto the action list if we have actions, otherwise onto * the tile. */ if (actions) { clutter_actor_show (priv->action_list); mx_focus_manager_push_focus (fmanager, MX_FOCUSABLE (priv->action_list)); g_list_free (actions); } else { clutter_actor_hide (priv->action_list); mx_focus_manager_push_focus (fmanager, MX_FOCUSABLE (priv->tile)); } }
int main (int argc, char *argv[]) { ClutterActor *button, *box, *stage; MxApplication *application; MxWindow *window; application = mx_application_new (&argc, &argv, "Test Mx focus handling", MX_APPLICATION_SINGLE_INSTANCE); window = mx_application_create_window (application); stage = (ClutterActor *)mx_window_get_clutter_stage (window); box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL); mx_window_set_child (window, box); button = mx_button_new_with_label ("button #1 (activate to remove)"); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL); mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1); mx_focus_manager_push_focus (mx_focus_manager_get_for_stage (CLUTTER_STAGE (stage)), MX_FOCUSABLE (button)); button = mx_button_new_with_label ("button #2 (activate to remove)"); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL); mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1); button = mx_button_new_with_label ("button #3 (activate to remove)"); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL); mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1); button = mx_button_new_with_label ("button #4 (activate to remove)"); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL); mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1); clutter_actor_show (stage); mx_application_run (application); return EXIT_SUCCESS; }
static void mx_menu_show (ClutterActor *actor) { ClutterStage *stage; clutter_actor_set_reactive (actor, TRUE); clutter_actor_set_opacity (actor, 0xff); /* chain up to run show after re-setting properties above */ CLUTTER_ACTOR_CLASS (mx_menu_parent_class)->show (actor); clutter_actor_grab_key_focus (actor); stage = (ClutterStage*) clutter_actor_get_stage (actor); mx_focus_manager_push_focus (mx_focus_manager_get_for_stage (stage), MX_FOCUSABLE (actor)); }
static void mex_telepathy_channel_on_video_shown (ClutterActor *actor, gpointer user_data) { MexTelepathyChannel *self = MEX_TELEPATHY_CHANNEL (user_data); MexTelepathyChannelPrivate *priv = self->priv; ClutterStage *stage; MxFocusManager *fmanager; clutter_actor_hide (CLUTTER_ACTOR (priv->full_frame) ); stage = CLUTTER_STAGE (clutter_actor_get_stage (CLUTTER_ACTOR (actor))); if (stage) { fmanager = mx_focus_manager_get_for_stage (stage); mx_focus_manager_push_focus (fmanager, MX_FOCUSABLE (priv->end_button)); } }
static gboolean mx_menu_button_enter_event_cb (ClutterActor *box, ClutterEvent *event, gpointer user_data) { MxMenuPrivate *priv = MX_MENU (user_data)->priv; ClutterStage *stage; /* each menu item grabs focus when hovered */ stage = (ClutterStage *) clutter_actor_get_stage (box); /* ensure the menu is not closed when focus is pushed to another actor */ priv->internal_focus_push = TRUE; mx_focus_manager_push_focus (mx_focus_manager_get_for_stage (stage), MX_FOCUSABLE (box)); /* prevent the hover pseudo-class from being applied */ return TRUE; }
void mex_epg_grid_add_events (MexEpgGrid *grid, MexChannel *channel, GPtrArray *events) { MexEpgGridPrivate *priv; MexChannelManager *channel_manager; MxFocusManager *focus_manager; GPtrArray *row; gint position; guint i; g_return_if_fail (MEX_IS_EPG_GRID (grid)); g_return_if_fail (MEX_IS_CHANNEL (channel)); g_return_if_fail (events); priv = grid->priv; channel_manager = mex_channel_manager_get_default (); position = mex_channel_manager_get_channel_position (channel_manager, channel); if (G_UNLIKELY (position == -1)) { MEX_WARN (EPG, "Could not find position of channel %s", mex_channel_get_name (channel)); return; } /* no events for this channel */ if (G_UNLIKELY (events->len == 0)) { /* signal that we won't have data for that row */ row_loaded (grid, position); return; } /* we insert tiles in bulk, removing the existing tiles if needed */ row = g_ptr_array_index (priv->rows, position); /* If we already have data for that row, we assume the caller wants to * replace the data. If we don't we signal that a new row is loaded */ if (row) remove_row (grid, position); else row_loaded (grid, position); row = g_ptr_array_new (); g_ptr_array_set_size (row, events->len); /* We are adding events, it's a good time to check if we have a valid * current date */ if (priv->current_date == NULL) priv->current_date = g_date_time_new_now_local (); for (i = 0; i < events->len; i++) { MexEpgEvent *event = g_ptr_array_index (events, i); ClutterActor *tile; tile = mex_epg_tile_new_with_event (event); g_signal_connect (tile, "clicked", G_CALLBACK (on_tile_clicked), grid); clutter_actor_set_parent (tile, CLUTTER_ACTOR (grid)); g_ptr_array_index (row, i) = tile; #if 0 /* Disabled because we don't need to style differently the events that * are occuring now in the current design, might come back though */ if (mex_epg_event_is_date_in_between (event, priv->current_date)) mx_stylable_set_style_class (MX_STYLABLE (tile), "EpgTileNow"); #endif } g_ptr_array_index (priv->rows, position) = row; /* If the EpgGrid had the focus before we had a chance to add events, * it's a good time to push the focus to one of the EpgTile */ /* FIXME: default to the channel we are watching, not row 0 */ if (priv->has_focus_but_no_tile && position == 0 && row->len > 0) { ClutterActor *focused_tile = g_ptr_array_index (row, 0); ClutterActor *stage; stage = clutter_actor_get_stage (focused_tile); focus_manager = mx_focus_manager_get_for_stage (CLUTTER_STAGE (stage)); mx_focus_manager_push_focus (focus_manager, MX_FOCUSABLE (focused_tile)); g_signal_emit (grid, signals[SIGNAL_ROW_SELECTED], 0, 0); priv->has_focus_but_no_tile = FALSE; } /* We have a new row, relayout */ clutter_actor_queue_relayout (CLUTTER_ACTOR (grid)); }