mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 03:02:49 +00:00
Cache SetText
Apparently, gtk_button_set_label is very expensive to do. Now it is only called when necessary. This is the culprit for the mysterious high CPU usage and not the Hyprland IPC as said in https://github.com/scorpion-26/gBar/issues/7 and https://github.com/scorpion-26/gBar/issues/8.
This commit is contained in:
parent
6d3f1b64f4
commit
660e690195
1 changed files with 2 additions and 2 deletions
|
@ -524,11 +524,11 @@ void Button::Create()
|
||||||
|
|
||||||
void Button::SetText(const std::string& text)
|
void Button::SetText(const std::string& text)
|
||||||
{
|
{
|
||||||
m_Text = text;
|
if (m_Widget && text != m_Text)
|
||||||
if (m_Widget)
|
|
||||||
{
|
{
|
||||||
gtk_button_set_label((GtkButton*)m_Widget, m_Text.c_str());
|
gtk_button_set_label((GtkButton*)m_Widget, m_Text.c_str());
|
||||||
}
|
}
|
||||||
|
m_Text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::OnClick(Callback<Button>&& callback)
|
void Button::OnClick(Callback<Button>&& callback)
|
||||||
|
|
Loading…
Reference in a new issue