Преглед изворни кода

UI: Add HighContrastEnabled() to platform utilities

derrod пре 2 година
родитељ
комит
0a9f1e7391
4 измењених фајлова са 24 додато и 0 уклоњено
  1. 5 0
      UI/platform-osx.mm
  2. 11 0
      UI/platform-windows.cpp
  3. 6 0
      UI/platform-x11.cpp
  4. 2 0
      UI/platform.hpp

+ 5 - 0
UI/platform-osx.mm

@@ -361,3 +361,8 @@ void InstallNSApplicationSubclass()
 {
     [OBSApplication sharedApplication];
 }
+
+bool HighContrastEnabled()
+{
+    return [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldIncreaseContrast];
+}

+ 11 - 0
UI/platform-windows.cpp

@@ -494,3 +494,14 @@ void TaskbarOverlaySetStatus(TaskbarOverlayStatus status)
 	DestroyIcon(hicon);
 	taskbarIcon->Release();
 }
+
+bool HighContrastEnabled()
+{
+	HIGHCONTRAST hc = {};
+	hc.cbSize = sizeof(HIGHCONTRAST);
+
+	if (SystemParametersInfo(SPI_GETHIGHCONTRAST, hc.cbSize, &hc, 0))
+		return hc.dwFlags & HCF_HIGHCONTRASTON;
+
+	return false;
+}

+ 6 - 0
UI/platform-x11.cpp

@@ -269,3 +269,9 @@ bool SetDisplayAffinitySupported(void)
 // Not implemented yet
 void TaskbarOverlayInit() {}
 void TaskbarOverlaySetStatus(TaskbarOverlayStatus) {}
+
+bool HighContrastEnabled()
+{
+	// Note implemented yet
+	return false;
+}

+ 2 - 0
UI/platform.hpp

@@ -36,6 +36,8 @@ void SetAlwaysOnTop(QWidget *window, bool enable);
 
 bool SetDisplayAffinitySupported(void);
 
+bool HighContrastEnabled();
+
 enum TaskbarOverlayStatus {
 	TaskbarOverlayStatusInactive,
 	TaskbarOverlayStatusActive,