forked from owncloud/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Utility: Implement hasDarkSystray_private on Windows
Fixes: owncloud#7356
- Loading branch information
1 parent
07f1e50
commit f8e7669
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) by Hannah von Reth <hannah.vonreth@owncloud.com> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include "winrthelper.h" | ||
|
||
#include <wrl.h> | ||
#include <Windows.UI.ViewManagement.h> | ||
|
||
#include <algorithm> | ||
|
||
namespace { | ||
|
||
ABI::Windows::UI::Color GetThemeColor(ABI::Windows::UI::ViewManagement::UIColorType type, bool *ok) | ||
{ | ||
*ok = false; | ||
ABI::Windows::UI::Color color; | ||
Microsoft::WRL::ComPtr<ABI::Windows::UI::ViewManagement::IUISettings3> settings; | ||
if (SUCCEEDED(Windows::Foundation::ActivateInstance(Microsoft::WRL::Wrappers::HStringReference( | ||
RuntimeClass_Windows_UI_ViewManagement_UISettings).Get(), &settings)) ) | ||
{ | ||
settings->GetColorValue(type, &color); | ||
*ok = true; | ||
} | ||
return color; | ||
} | ||
} | ||
|
||
namespace WinRtHelper { | ||
bool hasDarkSystray() | ||
{ | ||
bool ok; | ||
const auto color = GetThemeColor(ABI::Windows::UI::ViewManagement::UIColorType::UIColorType_Background, &ok); | ||
if (ok) | ||
{ | ||
const auto lightness = 0.5 * (std::max(color.R, std::max(color.G, color.B)) + std::min(color.R, std::min(color.G, color.B))) / 255.0; | ||
return lightness < 0.5; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) by Hannah von Reth <hannah.vonreth@owncloud.com> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#ifndef WINRTHELPER_H | ||
#define WINRTHELPER_H | ||
|
||
|
||
namespace WinRtHelper | ||
{ | ||
bool hasDarkSystray(); | ||
}; | ||
|
||
#endif // WINRTHELPER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters