~3v1n0/unity/scale-window-cast-protection

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/IconTexture.cpp

HudController: Fixed geometries for single-launcher mode.

And added tests for multimonitor in HUD, with lock-out support.. Fixes: https://bugs.launchpad.net/bugs/963577. Approved by Thomi Richards.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
}
58
58
 
59
59
IconTexture::IconTexture(std::string const& icon_name, unsigned int size, bool defer_icon_loading)
60
 
  : TextureArea(NUX_TRACKER_LOCATION)
61
 
  , _accept_key_nav_focus(false)
62
 
  , _icon_name(icon_name.empty() ? DEFAULT_ICON : icon_name)
63
 
  , _size(size)
64
 
  , _texture_width(0)
65
 
  , _texture_height(0)
66
 
  , _loading(false)
67
 
  , _opacity(1.0f)
 
60
  : TextureArea(NUX_TRACKER_LOCATION),
 
61
    _accept_key_nav_focus(false),
 
62
    _icon_name(!icon_name.empty() ? icon_name : DEFAULT_ICON),
 
63
    _size(size),
 
64
    _texture_width(0),
 
65
    _texture_height(0),
 
66
    _loading(false),
 
67
    _opacity(1.0f)
68
68
{
69
 
 
70
 
  if (_icon_name != "" && !defer_icon_loading)
 
69
  if (!defer_icon_loading)
71
70
    LoadIcon();
72
71
}
73
72
 
 
73
IconTexture::~IconTexture()
 
74
{}
 
75
 
74
76
void IconTexture::SetByIconName(std::string const& icon_name, unsigned int size)
75
77
{
 
78
  if (_icon_name == icon_name && _size == size)
 
79
    return;
 
80
 
76
81
  _icon_name = icon_name;
77
82
  _size = size;
 
83
 
78
84
  LoadIcon();
79
85
}
80
86
 
 
87
 
81
88
void IconTexture::SetByFilePath(std::string const& file_path, unsigned int size)
82
89
{
83
 
  _icon_name = file_path;
84
 
  _size = size;
85
 
 
86
 
  LoadIcon();
 
90
  SetByIconName(file_path, size);
87
91
}
88
92
 
89
93
void IconTexture::LoadIcon()
90
94
{
91
95
  LOG_DEBUG(logger) << "LoadIcon called (" << _icon_name << ") - loading: " << _loading;
92
 
static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";
93
 
  if (_icon_name.empty())
94
 
    return;
 
96
  static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";
95
97
 
96
98
  if (_loading)
97
99
    return;
 
100
 
98
101
  _loading = true;
99
102
 
100
103
  glib::Object<GIcon> icon(::g_icon_new_for_string(_icon_name.empty() ?  DEFAULT_GICON : _icon_name.c_str(), NULL));
231
234
{
232
235
  unity::variant::BuilderWrapper(builder)
233
236
  .add(GetGeometry())
234
 
  .add("iconname", _icon_name);
 
237
  .add("icon_name", _icon_name);
235
238
}
236
239
 
237
240
//