~ted/ubuntu-app-launch/user-tools

« back to all changes in this revision

Viewing changes to libubuntu-app-launch/jobs-base.cpp

  • Committer: Bileto Bot
  • Author(s): Ken VanDine
  • Date: 2017-02-15 15:09:13 UTC
  • mfrom: (249.6.32 ual_focus_app)
  • Revision ID: ci-train-bot@canonical.com-20170215150913-s2nw6er5n94nsj9u
Adds Application::Instance::focus and Application::findInstance(pid_t) API

Approved by: Ted Gould

Show diffs side-by-side

added added

removed removed

Lines of Context:
497
497
    pidListToDbus(registry_, appId_, instance_, pids, "ApplicationResumed");
498
498
}
499
499
 
 
500
/** Focuses this application by sending SIGCONT to all the PIDs in the
 
501
    cgroup and tells the Shell to focus the application. */
 
502
void Base::focus()
 
503
{
 
504
    g_debug("Focusing application: %s", std::string(appId_).c_str());
 
505
 
 
506
    GError* error = nullptr;
 
507
    GVariantBuilder params;
 
508
    g_variant_builder_init(&params, G_VARIANT_TYPE_TUPLE);
 
509
    g_variant_builder_add_value(&params, g_variant_new_string(std::string(appId_).c_str()));
 
510
    g_variant_builder_add_value(&params, g_variant_new_string(instance_.c_str()));
 
511
    g_dbus_connection_emit_signal(registry_->impl->_dbus.get(),    /* bus */
 
512
                                  nullptr,                         /* destination */
 
513
                                  "/",                             /* path */
 
514
                                  "com.canonical.UbuntuAppLaunch", /* interface */
 
515
                                  "UnityFocusRequest",             /* signal */
 
516
                                  g_variant_builder_end(&params),  /* params */
 
517
                                  &error);                         /* error */
 
518
 
 
519
    if (error != nullptr)
 
520
    {
 
521
        g_warning("Unable to emit signal 'UnityFocusRequest' for appid '%s': '%s'", std::string(appId_).c_str(),
 
522
                  error->message);
 
523
        g_error_free(error);
 
524
    }
 
525
    else
 
526
    {
 
527
        g_debug("Emmitted 'UnityFocusRequest' to DBus");
 
528
    }
 
529
}
 
530
 
500
531
/** Go through the list of PIDs calling a function and handling
501
532
    the issue with getting PIDs being a racey condition.
502
533