Back to index

unity  6.0.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
unity::dash::Controller Class Reference

#include <DashController.h>

Inheritance diagram for unity::dash::Controller:
Inheritance graph
[legend]
Collaboration diagram for unity::dash::Controller:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::shared_ptr
< Controller
Ptr
typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 Controller ()
nux::BaseWindow * window () const
gboolean CheckShortcutActivation (const char *key_string)
std::vector< char > GetAllShortcuts ()
void HideDash (bool restore_focus=true)
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

nux::Property< int > launcher_width
nux::Property< bool > use_primary
sigc::signal< void > on_realize

Protected Member Functions

std::string GetName () const
void AddProperties (GVariantBuilder *builder)
virtual std::string GetChildsName () const
 Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Private Member Functions

void EnsureDash ()
void SetupWindow ()
void SetupDashView ()
void SetupRelayoutCallbacks ()
void RegisterUBusInterests ()
nux::Geometry GetIdealWindowGeometry ()
int GetIdealMonitor ()
void Relayout (GdkScreen *screen=NULL)
void OnMouseDownOutsideWindow (int x, int y, unsigned long bflags, unsigned long kflags)
void OnScreenUngrabbed ()
void OnExternalShowDash (GVariant *variant)
void OnExternalHideDash (GVariant *variant)
void OnActivateRequest (GVariant *variant)
void ShowDash ()
void StartShowHideTimeline ()
void OnViewShowHideFrame (double progress)

Static Private Member Functions

static void OnWindowConfigure (int width, int height, nux::Geometry &geo, void *data)

Private Attributes

nux::ObjectPtr< nux::BaseWindow > window_
int monitor_
bool visible_
bool need_show_
DashViewview_
sigc::connection screen_ungrabbed_slot_
glib::SignalManager sig_manager_
glib::TimeoutSeconds ensure_timeout_
Animator timeline_animator_
UBusManager ubus_manager_

Detailed Description

Definition at line 42 of file DashController.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.

typedef std::shared_ptr<Controller> unity::dash::Controller::Ptr

Definition at line 45 of file DashController.h.


Constructor & Destructor Documentation

Definition at line 43 of file DashController.cpp.

  : launcher_width(64)
  , use_primary(false)
  , monitor_(0)
  , visible_(false)
  , need_show_(false)
  , view_(nullptr)
  , ensure_timeout_(PRELOAD_TIMEOUT_LENGTH)
  , timeline_animator_(90)
{
  SetupRelayoutCallbacks();
  RegisterUBusInterests();

  ensure_timeout_.Run([&]() { EnsureDash(); return false; });
  timeline_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame));

  SetupWindow();

  Settings::Instance().changed.connect([&]()
  {
    if (window_ && view_)
    {
      window_->PushToFront();
      window_->SetInputFocus();
      nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus());
    }
  });

  auto spread_cb = sigc::bind(sigc::mem_fun(this, &Controller::HideDash), true);
  PluginAdapter::Default()->initiate_spread.connect(spread_cb);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 78 of file Introspectable.cpp.

{
  _children.push_back(child);
  child->_parents.push_back(this);
}

Here is the caller graph for this function:

void unity::dash::Controller::AddProperties ( GVariantBuilder *  builder) [protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 363 of file DashController.cpp.

{
  variant::BuilderWrapper(builder).add("visible", visible_)
                                  .add("monitor", monitor_);
}

Here is the call graph for this function:

gboolean unity::dash::Controller::CheckShortcutActivation ( const char *  key_string)

Definition at line 334 of file DashController.cpp.

{
  EnsureDash();
  std::string lens_id = view_->GetIdForShortcutActivation(std::string(key_string));
  if (lens_id != "")
  {
    if (PluginAdapter::Default()->IsScaleActive())
      PluginAdapter::Default()->TerminateScale();

    GVariant* args = g_variant_new("(sus)", lens_id.c_str(), dash::GOTO_DASH_URI, "");
    OnActivateRequest(args);
    g_variant_unref(args);
    return true;
  }
  return false;
}

Here is the call graph for this function:

Definition at line 141 of file DashController.cpp.

{
  LOG_DEBUG(logger) << "Initializing Dash";
  if (!window_)
    SetupWindow();

  if (!view_)
  {
    SetupDashView();
    Relayout();
    ensure_timeout_.Remove();

    on_realize.emit();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 351 of file DashController.cpp.

{
  EnsureDash();
  return view_->GetAllShortcuts();
}

Here is the call graph for this function:

std::string unity::debug::Introspectable::GetChildsName ( ) const [protected, virtual, inherited]

Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Definition at line 92 of file Introspectable.cpp.

{
  return "Children";
}

Here is the caller graph for this function:

Definition at line 170 of file DashController.cpp.

{
  UScreen *uscreen = UScreen::GetDefault();
  int primary_monitor;
  if (use_primary)
    primary_monitor = uscreen->GetPrimaryMonitor();
  else
    primary_monitor = uscreen->GetMonitorWithMouse();

  return primary_monitor;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 182 of file DashController.cpp.

{
  UScreen *uscreen = UScreen::GetDefault();
  auto monitor_geo = uscreen->GetMonitorGeometry(GetIdealMonitor());

  // We want to cover as much of the screen as possible to grab any mouse events outside
  // of our window
  panel::Style &panel_style = panel::Style::Instance();
  return nux::Geometry (monitor_geo.x + launcher_width,
                        monitor_geo.y + panel_style.panel_height,
                        monitor_geo.width - launcher_width,
                        monitor_geo.height - panel_style.panel_height);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Introspectable::IntrospectableList unity::debug::Introspectable::GetIntrospectableChildren ( ) [virtual, inherited]

Reimplemented in unity::hud::View, unity::launcher::LauncherModel, unity::QuicklistView, and unity::dash::ResultView.

Definition at line 41 of file Introspectable.cpp.

{
  return _children;
}

Here is the caller graph for this function:

guint64 unity::debug::Introspectable::GetIntrospectionId ( ) const [inherited]

Definition at line 97 of file Introspectable.cpp.

{
  return _id;
}

Here is the caller graph for this function:

std::string unity::dash::Controller::GetName ( ) const [protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 358 of file DashController.cpp.

{
  return "DashController";
}
void unity::dash::Controller::HideDash ( bool  restore_focus = true)

Definition at line 283 of file DashController.cpp.

{
  if (!visible_)
   return;

  screen_ungrabbed_slot_.disconnect();

  EnsureDash();

  view_->AboutToHide();

  window_->CaptureMouseDownAnyWhereElse(false);
  window_->EnableInputWindow(false, dash::window_title, true, false);
  visible_ = false;

  nux::GetWindowCompositor().SetKeyFocusArea(NULL,nux::KEY_NAV_NONE);

  if (restore)
    PluginAdapter::Default ()->restoreInputFocus ();

  StartShowHideTimeline();

  GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_);
  ubus_manager_.SendMessage(UBUS_OVERLAY_HIDDEN, info);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GVariant * unity::debug::Introspectable::Introspect ( ) [inherited]

Definition at line 47 of file Introspectable.cpp.

{
  GVariantBuilder  builder;
  GVariantBuilder  child_builder;
  gint             n_children = 0;

  g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
  g_variant_builder_add(&builder, "{sv}", "id", g_variant_new_uint64(_id));

  AddProperties(&builder);

  g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as"));

  auto children = GetIntrospectableChildren();
  for (auto it = children.begin(); it != children.end(); it++)
  {
    if ((*it)->GetName() != "")
    {
      g_variant_builder_add(&child_builder, "s", (*it)->GetName().c_str());
      n_children++;
    }
  }

  GVariant* child_results = g_variant_builder_end(&child_builder);

  if (n_children > 0)
    g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), child_results);
  return g_variant_builder_end(&builder);
}

Here is the call graph for this function:

void unity::dash::Controller::OnActivateRequest ( GVariant *  variant) [private]

Definition at line 328 of file DashController.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Controller::OnExternalHideDash ( GVariant *  variant) [private]

Definition at line 229 of file DashController.cpp.

{
  EnsureDash();

  if (variant)
  {
    HideDash(g_variant_get_boolean(variant));
  }
  else
  {
    HideDash();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Controller::OnExternalShowDash ( GVariant *  variant) [private]

Definition at line 223 of file DashController.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Controller::OnMouseDownOutsideWindow ( int  x,
int  y,
unsigned long  bflags,
unsigned long  kflags 
) [private]

Definition at line 207 of file DashController.cpp.

{
  HideDash();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 213 of file DashController.cpp.

{
  LOG_DEBUG(logger) << "On Screen Ungrabbed called";
  if (need_show_)
  {
    EnsureDash();
    ShowDash();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Controller::OnViewShowHideFrame ( double  progress) [private]

Definition at line 318 of file DashController.cpp.

{
  window_->SetOpacity(visible_ ? progress : 1.0f - progress);

  if (progress == 1.0f && !visible_)
  {
    window_->ShowWindow(false);
  }
}

Here is the caller graph for this function:

void unity::dash::Controller::OnWindowConfigure ( int  width,
int  height,
nux::Geometry &  geo,
void *  data 
) [static, private]

Definition at line 163 of file DashController.cpp.

{
  Controller* self = static_cast<Controller*>(data);
  geo = self->GetIdealWindowGeometry();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 117 of file DashController.cpp.

{
  ubus_manager_.RegisterInterest(UBUS_DASH_EXTERNAL_ACTIVATION,
                                 sigc::mem_fun(this, &Controller::OnExternalShowDash));
  ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_CLOSE_REQUEST,
                                 sigc::mem_fun(this, &Controller::OnExternalHideDash));
  ubus_manager_.RegisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
                                 sigc::mem_fun(this, &Controller::OnActivateRequest));
  ubus_manager_.RegisterInterest(UBUS_DASH_ABOUT_TO_SHOW,
                                 [&] (GVariant*) { EnsureDash(); });
  ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, [&] (GVariant *data) {
    unity::glib::String overlay_identity;
    gboolean can_maximise = FALSE;
    gint32 overlay_monitor = 0;
    g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING, &overlay_identity, &can_maximise, &overlay_monitor);

    // hide if something else is coming up
    if (overlay_identity.Str() != "dash")
    {
      HideDash(true);
    }
  });
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Controller::Relayout ( GdkScreen *  screen = NULL) [private]

Definition at line 196 of file DashController.cpp.

{
  EnsureDash();

  nux::Geometry geo = GetIdealWindowGeometry();
  window_->SetGeometry(geo);
  view_->Relayout();
  panel::Style &panel_style = panel::Style::Instance();
  view_->SetMonitorOffset(launcher_width, panel_style.panel_height);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 85 of file Introspectable.cpp.

{
  _children.remove(child);
  child->_parents.remove(this);
}

Here is the caller graph for this function:

Definition at line 92 of file DashController.cpp.

{
  view_ = new DashView();
  AddChild(view_);

  nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
  layout->AddView(view_, 1);
  layout->SetContentDistribution(nux::eStackLeft);
  layout->SetVerticalExternalMargin(0);
  layout->SetHorizontalExternalMargin(0);

  window_->SetLayout(layout);
  ubus_manager_.UnregisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 107 of file DashController.cpp.

{
  GdkScreen* screen = gdk_screen_get_default();

  sig_manager_.Add(new glib::Signal<void, GdkScreen*>(screen,
    "monitors-changed", sigc::mem_fun(this, &Controller::Relayout)));
  sig_manager_.Add(new glib::Signal<void, GdkScreen*>(screen,
    "size-changed", sigc::mem_fun(this, &Controller::Relayout)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 75 of file DashController.cpp.

{
  window_ = new nux::BaseWindow(dash::window_title);
  window_->SetBackgroundColor(nux::Color(0.0f, 0.0f, 0.0f, 0.0f));
  window_->SetConfigureNotifyCallback(&Controller::OnWindowConfigure, this);
  window_->ShowWindow(false);
  window_->SetOpacity(0.0f);
  window_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow));

  /* FIXME - first time we load our windows there is a race that causes the input window not to actually get input, this side steps that by causing an input window show and hide before we really need it. */
  auto plugin_adapter = PluginAdapter::Default();
  plugin_adapter->saveInputFocus ();
  window_->EnableInputWindow(true, dash::window_title, true, false);
  window_->EnableInputWindow(false, dash::window_title, true, false);
  plugin_adapter->restoreInputFocus ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 243 of file DashController.cpp.

{
  EnsureDash();
  PluginAdapter* adaptor = PluginAdapter::Default();
  // Don't want to show at the wrong time
  if (visible_ || adaptor->IsExpoActive() || adaptor->IsScaleActive())
    return;

  // We often need to wait for the mouse/keyboard to be available while a plugin
  // is finishing it's animations/cleaning up. In these cases, we patiently wait
  // for the screen to be available again before honouring the request.
  if (adaptor->IsScreenGrabbed())
  {
    screen_ungrabbed_slot_.disconnect();
    screen_ungrabbed_slot_ = PluginAdapter::Default()->compiz_screen_ungrabbed.connect(sigc::mem_fun(this, &Controller::OnScreenUngrabbed));
    need_show_ = true;
    return;
  }
  view_->AboutToShow();

  window_->ShowWindow(true);
  window_->PushToFront();
  if (!Settings::Instance().is_standalone) // in standalone mode, we do not need an input window. we are one.
    window_->EnableInputWindow(true, dash::window_title, true, false);
  window_->SetInputFocus();
  window_->CaptureMouseDownAnyWhereElse(true);
  window_->QueueDraw();

  nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus());

  need_show_ = false;
  visible_ = true;

  StartShowHideTimeline();

  monitor_ = GetIdealMonitor();
  GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_);
  ubus_manager_.SendMessage(UBUS_OVERLAY_SHOWN, info);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 309 of file DashController.cpp.

{
  EnsureDash();

  double current_opacity = window_->GetOpacity();
  timeline_animator_.Stop();
  timeline_animator_.Start(visible_ ? current_opacity : 1.0f - current_opacity);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nux::BaseWindow * unity::dash::Controller::window ( ) const

Definition at line 157 of file DashController.cpp.

{
  return window_.GetPointer();
}

Member Data Documentation

Definition at line 99 of file DashController.h.

Definition at line 54 of file DashController.h.

Definition at line 91 of file DashController.h.

Definition at line 94 of file DashController.h.

Definition at line 57 of file DashController.h.

Definition at line 97 of file DashController.h.

Definition at line 98 of file DashController.h.

Definition at line 100 of file DashController.h.

Definition at line 101 of file DashController.h.

Definition at line 55 of file DashController.h.

Definition at line 95 of file DashController.h.

Definition at line 93 of file DashController.h.

nux::ObjectPtr<nux::BaseWindow> unity::dash::Controller::window_ [private]

Definition at line 90 of file DashController.h.


The documentation for this class was generated from the following files: