Back to index

unity  6.0.0
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes
unity::launcher::Controller Class Reference

#include <LauncherController.h>

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

List of all members.

Classes

class  Impl

Public Types

typedef std::shared_ptr
< Controller
Ptr
typedef std::vector
< nux::ObjectPtr< Launcher > > 
LauncherList
typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 Controller (Display *display)
 ~Controller ()
Launcherlauncher () const
LauncherListlaunchers () const
Window LauncherWindowId (int launcher) const
Window KeyNavLauncherInputWindowId () const
void UpdateNumWorkspaces (int workspaces)
std::vector< char > GetAllShortcuts () const
std::vector
< AbstractLauncherIcon::Ptr
GetAltTabIcons (bool current) const
void PushToFront ()
void SetShowDesktopIcon (bool show_desktop_icon)
bool AboutToShowDash (int was_tap, int when) const
void HandleLauncherKeyPress (int when)
void HandleLauncherKeyRelease (bool was_tap, int when)
bool HandleLauncherKeyEvent (Display *display, unsigned int key_sym, unsigned long key_code, unsigned long key_state, char *key_string)
void KeyNavActivate ()
void KeyNavGrab ()
void KeyNavTerminate (bool activate=true)
void KeyNavNext ()
void KeyNavPrevious ()
bool KeyNavIsActive () const
bool IsOverlayOpen () const
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

nux::Property< Options::Ptroptions
nux::Property< bool > multiple_launchers

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 Attributes

std::unique_ptr< Implpimpl

Detailed Description

Definition at line 39 of file LauncherController.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.

typedef std::vector<nux::ObjectPtr<Launcher> > unity::launcher::Controller::LauncherList

Definition at line 43 of file LauncherController.h.

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

Definition at line 42 of file LauncherController.h.


Constructor & Destructor Documentation

Definition at line 858 of file LauncherController.cpp.

 : options(Options::Ptr(new Options()))
 , multiple_launchers(true)
 , pimpl(new Impl(display, this))
{
  multiple_launchers.changed.connect([&](bool value) -> void {
    UScreen* uscreen = UScreen::GetDefault();
    auto monitors = uscreen->GetMonitors();
    int primary = uscreen->GetPrimaryMonitor();
    pimpl->EnsureLaunchers(primary, monitors);
    options()->show_for_all = !value;
  });
}

Here is the call graph for this function:

Definition at line 872 of file LauncherController.cpp.

{}

Member Function Documentation

bool unity::launcher::Controller::AboutToShowDash ( int  was_tap,
int  when 
) const

Definition at line 1005 of file LauncherController.cpp.

{
  if ((when - pimpl->launcher_key_press_time_) < local::super_tap_duration && was_tap)
    return true;
  return false;
}

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::launcher::Controller::AddProperties ( GVariantBuilder *  builder) [protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 1236 of file LauncherController.cpp.

{
  timespec current;
  clock_gettime(CLOCK_MONOTONIC, &current);

  unity::variant::BuilderWrapper(builder)
  .add("key_nav_is_active", KeyNavIsActive())
  .add("key_nav_launcher_monitor", pimpl->keyboard_launcher_.IsValid() ?  pimpl->keyboard_launcher_->monitor : -1)
  .add("key_nav_selection", pimpl->model_->SelectionIndex())
  .add("key_nav_is_grabbed", pimpl->launcher_grabbed)
  .add("keyboard_launcher", pimpl->CurrentLauncher()->monitor);
}

Here is the call graph for this function:

std::vector< char > unity::launcher::Controller::GetAllShortcuts ( ) const

Definition at line 890 of file LauncherController.cpp.

{
  std::vector<char> shortcuts;
  for (auto icon : *(pimpl->model_))
  {
    // TODO: find out why the icons use guint64 for shortcuts.
    char shortcut = icon->GetShortcut();
    if (shortcut)
      shortcuts.push_back(shortcut);
  }
  return shortcuts;
}

Definition at line 903 of file LauncherController.cpp.

{
  std::vector<AbstractLauncherIcon::Ptr> results;

  results.push_back(pimpl->desktop_icon_);

  for (auto icon : *(pimpl->model_))
  {
    if (icon->ShowInSwitcher(current))
    {
      //otherwise we get two desktop icons in the switcher.
      if (icon->GetIconType() != AbstractLauncherIcon::IconType::TYPE_DESKTOP)
      {
        results.push_back(icon);
      }
    }
  }
  return results;
}
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:

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::launcher::Controller::GetName ( ) const [protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 1230 of file LauncherController.cpp.

{
  return "LauncherController";
}
bool unity::launcher::Controller::HandleLauncherKeyEvent ( Display *  display,
unsigned int  key_sym,
unsigned long  key_code,
unsigned long  key_state,
char *  key_string 
)

Definition at line 1065 of file LauncherController.cpp.

{
  LauncherModel::iterator it;

  // Shortcut to start launcher icons. Only relies on Keycode, ignore modifier
  for (it = pimpl->model_->begin(); it != pimpl->model_->end(); it++)
  {
    if ((XKeysymToKeycode(display, (*it)->GetShortcut()) == key_code) ||
        ((gchar)((*it)->GetShortcut()) == key_string[0]))
    {
      struct timespec last_action_time = (*it)->GetQuirkTime(AbstractLauncherIcon::QUIRK_LAST_ACTION);
      struct timespec current;
      TimeUtil::SetTimeStruct(&current);
      if (TimeUtil::TimeDelta(&current, &last_action_time) > local::ignore_repeat_shortcut_duration)
      {
        if (g_ascii_isdigit((gchar)(*it)->GetShortcut()) && (key_state & ShiftMask))
          (*it)->OpenInstance(ActionArg(ActionArg::LAUNCHER, 0));
        else
          (*it)->Activate(ActionArg(ActionArg::LAUNCHER, 0));
      }

      // disable the "tap on super" check
      pimpl->launcher_key_press_time_ = 0;
      return true;
    }
  }

  return false;
}

Here is the call graph for this function:

Definition at line 970 of file LauncherController.cpp.

{
  pimpl->launcher_key_press_time_ = when;

  auto show_launcher = [&]()
  {
    if (pimpl->keyboard_launcher_.IsNull())
      pimpl->keyboard_launcher_ = pimpl->CurrentLauncher();

    pimpl->sources_.Remove(local::HIDE_TIMEOUT);
    pimpl->keyboard_launcher_->ForceReveal(true);
    pimpl->launcher_open = true;

    return false;
  };
  auto key_timeout = std::make_shared<glib::Timeout>(local::super_tap_duration, show_launcher);
  pimpl->sources_.Add(key_timeout, local::KEYPRESS_TIMEOUT);

  auto show_shortcuts = [&]()
  {
    if (!pimpl->launcher_keynav)
    {
      if (pimpl->keyboard_launcher_.IsNull())
        pimpl->keyboard_launcher_ = pimpl->CurrentLauncher();

      pimpl->keyboard_launcher_->ShowShortcuts(true);
      pimpl->launcher_open = true;
    }

    return false;
  };
  auto labels_timeout = std::make_shared<glib::Timeout>(local::shortcuts_show_delay, show_shortcuts);
  pimpl->sources_.Add(labels_timeout, local::LABELS_TIMEOUT);
}
void unity::launcher::Controller::HandleLauncherKeyRelease ( bool  was_tap,
int  when 
)

Definition at line 1012 of file LauncherController.cpp.

{
  int tap_duration = when - pimpl->launcher_key_press_time_;
  if (tap_duration < local::super_tap_duration && was_tap)
  {
    LOG_DEBUG(logger) << "Quick tap, sending activation request.";
    pimpl->SendHomeActivationRequest();
  }
  else
  {
    LOG_DEBUG(logger) << "Tap too long: " << tap_duration;
  }

  pimpl->sources_.Remove(local::LABELS_TIMEOUT);
  pimpl->sources_.Remove(local::KEYPRESS_TIMEOUT);

  if (pimpl->keyboard_launcher_.IsValid())
  {
    pimpl->keyboard_launcher_->ShowShortcuts(false);

    int ms_since_show = tap_duration;
    if (ms_since_show > local::launcher_minimum_show_duration)
    {
      pimpl->keyboard_launcher_->ForceReveal(false);
      pimpl->launcher_open = false;

      if (!pimpl->launcher_keynav)
        pimpl->keyboard_launcher_.Release();
    }
    else
    {
      int time_left = local::launcher_minimum_show_duration - ms_since_show;

      auto hide_launcher = [&]()
      {
        if (pimpl->keyboard_launcher_.IsValid())
        {
          pimpl->keyboard_launcher_->ForceReveal(false);
          pimpl->launcher_open = false;

          if (!pimpl->launcher_keynav)
            pimpl->keyboard_launcher_.Release();
        }

        return false;
      };

      auto hide_timeout = std::make_shared<glib::Timeout>(time_left, hide_launcher);
      pimpl->sources_.Add(hide_timeout, local::HIDE_TIMEOUT);
    }
  }
}
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:

Definition at line 1219 of file LauncherController.cpp.

{
  for (auto launcher_ptr : pimpl->launchers)
  {
    if (launcher_ptr->IsOverlayOpen())
      return true;
  }
  return false;
}

Definition at line 1113 of file LauncherController.cpp.

{
  if (pimpl->launcher_keynav)
    return;

  pimpl->reactivate_keynav = false;
  pimpl->launcher_keynav = true;
  pimpl->keynav_restore_window_ = true;
  pimpl->keyboard_launcher_ = pimpl->CurrentLauncher();

  pimpl->keyboard_launcher_->EnterKeyNavMode();
  pimpl->model_->SetSelection(0);

  if (pimpl->launcher_grabbed)
  {
    pimpl->ubus.SendMessage(UBUS_LAUNCHER_START_KEY_NAV,
                            g_variant_new_int32(pimpl->keyboard_launcher_->monitor));
  }
  else
  {
    pimpl->ubus.SendMessage(UBUS_LAUNCHER_START_KEY_SWTICHER,
                            g_variant_new_int32(pimpl->keyboard_launcher_->monitor));
  }

  AbstractLauncherIcon::Ptr const& selected = pimpl->model_->Selection();

  if (selected)
  {
    pimpl->ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED,
                            g_variant_new_string(selected->tooltip_text().c_str()));
  }
}

Here is the caller graph for this function:

Definition at line 1101 of file LauncherController.cpp.

{
  pimpl->launcher_grabbed = true;
  KeyNavActivate();
  pimpl->keyboard_launcher_->GrabKeyboard();

  pimpl->launcher_key_press_connection_ =
    pimpl->keyboard_launcher_->key_down.connect(sigc::mem_fun(pimpl.get(), &Controller::Impl::ReceiveLauncherKeyPress));
  pimpl->launcher_event_outside_connection_ =
    pimpl->keyboard_launcher_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(pimpl.get(), &Controller::Impl::ReceiveMouseDownOutsideArea));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1214 of file LauncherController.cpp.

{
  return pimpl->launcher_keynav;
}

Here is the caller graph for this function:

Definition at line 930 of file LauncherController.cpp.

{
  if (KeyNavIsActive())
    return pimpl->keyboard_launcher_->GetParent()->GetInputWindowId();
  return 0;
}

Here is the call graph for this function:

Definition at line 1146 of file LauncherController.cpp.

{
  pimpl->model_->SelectNext();

  AbstractLauncherIcon::Ptr const& selected = pimpl->model_->Selection();

  if (selected)
  {
    pimpl->ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED,
                            g_variant_new_string(selected->tooltip_text().c_str()));
  }
}

Definition at line 1159 of file LauncherController.cpp.

{
  pimpl->model_->SelectPrevious();

  AbstractLauncherIcon::Ptr const& selected = pimpl->model_->Selection();

  if (selected)
  {
    pimpl->ubus.SendMessage(UBUS_LAUNCHER_SELECTION_CHANGED,
                            g_variant_new_string(selected->tooltip_text().c_str()));
  }
}
void unity::launcher::Controller::KeyNavTerminate ( bool  activate = true)

Definition at line 1172 of file LauncherController.cpp.

{
  if (!pimpl->launcher_keynav)
    return;

  if (activate && pimpl->keynav_restore_window_)
  {
    /* If the selected icon is running, we must not restore the input to the old */
    AbstractLauncherIcon::Ptr const& icon = pimpl->model_->Selection();
    pimpl->keynav_restore_window_ = !icon->GetQuirk(AbstractLauncherIcon::QUIRK_RUNNING);
  }

  pimpl->keyboard_launcher_->ExitKeyNavMode();

  if (pimpl->launcher_grabbed)
  {
    pimpl->keyboard_launcher_->UnGrabKeyboard();
    pimpl->launcher_key_press_connection_.disconnect();
    pimpl->launcher_event_outside_connection_.disconnect();
    pimpl->launcher_grabbed = false;
    pimpl->ubus.SendMessage(UBUS_LAUNCHER_END_KEY_NAV,
                            g_variant_new_boolean(pimpl->keynav_restore_window_));
  }
  else
  {
    pimpl->ubus.SendMessage(UBUS_LAUNCHER_END_KEY_SWTICHER,
                            g_variant_new_boolean(pimpl->keynav_restore_window_));
  }

  if (activate)
  {
    pimpl->sources_.Add(std::make_shared<glib::Idle>([this] {
      pimpl->model_->Selection()->Activate(ActionArg(ActionArg::LAUNCHER, 0));
      return false;
    }));
  }

  pimpl->launcher_keynav = false;
  if (!pimpl->launcher_open)
    pimpl->keyboard_launcher_.Release();
}

Definition at line 880 of file LauncherController.cpp.

{
  return *(pimpl->launcher_);
}

Here is the caller graph for this function:

Definition at line 885 of file LauncherController.cpp.

{
  return pimpl->launchers;
}

Here is the caller graph for this function:

Window unity::launcher::Controller::LauncherWindowId ( int  launcher) const

Definition at line 923 of file LauncherController.cpp.

{
  if (launcher >= (int)pimpl->launchers.size())
    return 0;
  return pimpl->launchers[launcher]->GetParent()->GetInputWindowId();
}

Here is the call graph for this function:

Definition at line 937 of file LauncherController.cpp.

{
  pimpl->launcher_->GetParent()->PushToFront();
}

Definition at line 85 of file Introspectable.cpp.

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

Here is the caller graph for this function:

void unity::launcher::Controller::SetShowDesktopIcon ( bool  show_desktop_icon)

Definition at line 942 of file LauncherController.cpp.

{
  if (pimpl->show_desktop_icon_ == show_desktop_icon)
    return;

  pimpl->show_desktop_icon_ = show_desktop_icon;

  if (pimpl->show_desktop_icon_)
    pimpl->InsertDesktopIcon();
  else
    pimpl->RemoveDesktopIcon();
}

Definition at line 875 of file LauncherController.cpp.

{
  pimpl->UpdateNumWorkspaces(workspaces);
}

Member Data Documentation

Definition at line 46 of file LauncherController.h.

Definition at line 45 of file LauncherController.h.

std::unique_ptr<Impl> unity::launcher::Controller::pimpl [private]

Definition at line 89 of file LauncherController.h.


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