~unity-team/unity/trusty-1332509

« back to all changes in this revision

Viewing changes to unity-shared/UnitySettings.cpp

  • Committer: CI bot
  • Author(s): Stephen M. Webb, Marco Trevisan (Treviño), Andrea Azzarone, Pawel Szubert, Chris Townsend, Andrea Azzarone, Eleni Maria Stea
  • Date: 2014-08-26 13:48:28 UTC
  • mfrom: (3800.1.24 prepare-7.2.3-SRU)
  • Revision ID: ps-jenkins@lists.canonical.com-20140826134828-fkev1oisyfl9kbt3
Prepare fixes for upstream micro-release 7.2.3. Fixes: 1283415, 1292391, 1306211, 1312107, 1320051, 1320071, 1324114, 1339629, 1340171, 1340394, 1340477, 1340992, 1340996, 1342208, 1342731, 1347735

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
const std::string GNOME_TEXT_SCALE_FACTOR = "text-scaling-factor";
60
60
 
61
61
const int DEFAULT_LAUNCHER_WIDTH = 64;
 
62
const int MINIMUM_DESKTOP_HEIGHT = 800;
62
63
const double DEFAULT_DPI = 96.0f;
63
64
}
64
65
 
89
90
    for (unsigned i = 0; i < monitors::MAX; ++i)
90
91
      em_converters_.emplace_back(std::make_shared<EMConverter>());
91
92
 
92
 
    CacheFormFactor();
93
 
    CacheDoubleClickActivate();
94
 
 
95
93
    // The order is important here, DPI is the last thing to be updated
96
94
    UpdateLimSetting();
97
95
    UpdateTextScaleFactor();
99
97
    UpdateFontSize();
100
98
    UpdateDPI();
101
99
 
 
100
    CacheFormFactor();
 
101
    CacheDoubleClickActivate();
 
102
 
102
103
    UScreen::GetDefault()->changed.connect(sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::UpdateDPI))));
103
104
 
104
105
    signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + FORM_FACTOR, [this] (GSettings*, const gchar*) {
162
163
    if (raw_from_factor == 0) //Automatic
163
164
    {
164
165
      auto uscreen = UScreen::GetDefault();
165
 
      int primary_monitor = uscreen->GetMonitorWithMouse();
 
166
      int primary_monitor = uscreen->GetPrimaryMonitor();
166
167
      auto const& geo = uscreen->GetMonitorGeometry(primary_monitor);
 
168
      double monitor_scaling = em(primary_monitor)->DPIScale();
167
169
 
168
 
      new_form_factor = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK;
 
170
      new_form_factor = (geo.height * monitor_scaling) >= MINIMUM_DESKTOP_HEIGHT ? FormFactor::DESKTOP : FormFactor::NETBOOK;
169
171
    }
170
172
    else
171
173
    {
239
241
    cursor_scale_ = g_settings_get_double(ui_settings_, CURSOR_SCALE_FACTOR.c_str());
240
242
  }
241
243
 
 
244
  EMConverter::Ptr const& em(int monitor) const
 
245
  {
 
246
    if (monitor < 0 || monitor >= (int)monitors::MAX)
 
247
    {
 
248
      LOG_ERROR(logger) << "Invalid monitor index: " << monitor << ". Returning index 0 monitor instead.";
 
249
      return em_converters_[0];
 
250
    }
 
251
 
 
252
    return em_converters_[monitor];
 
253
  }
 
254
 
242
255
  void UpdateDPI()
243
256
  {
244
257
    auto* uscreen = UScreen::GetDefault();
361
374
 
362
375
EMConverter::Ptr const& Settings::em(int monitor) const
363
376
{
364
 
  if (monitor < 0 || monitor >= (int)monitors::MAX)
365
 
  {
366
 
    LOG_ERROR(logger) << "Invalid monitor index: " << monitor << ". Returning index 0 monitor instead.";
367
 
    return pimpl->em_converters_[0];
368
 
  }
369
 
 
370
 
  return pimpl->em_converters_[monitor];
 
377
  return pimpl->em(monitor);
371
378
}
372
379
 
373
380
void Settings::SetLauncherWidth(int launcher_width, int monitor)