-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Windows] add is highcontrast (#153)
- Loading branch information
Showing
11 changed files
with
99 additions
and
7 deletions.
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
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,8 @@ | ||
#pragma once | ||
|
||
namespace jwm { | ||
class Theme { | ||
public: | ||
bool isHighContrast(); | ||
}; | ||
} // namespace jwm |
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,24 @@ | ||
package io.github.humbleui.jwm; | ||
|
||
import org.jetbrains.annotations.*; | ||
import io.github.humbleui.jwm.impl.*; | ||
|
||
public class Theme { | ||
|
||
/** | ||
* <p>>Check whether OS currently uses high contrast mode.</p> | ||
* | ||
* @return bool; | ||
*/ | ||
public static boolean isHighContrast() { | ||
assert _onUIThread(); | ||
return _nIsHighContrast(); | ||
} | ||
|
||
|
||
@ApiStatus.Internal public static boolean _onUIThread() { | ||
return App._onUIThread(); | ||
} | ||
|
||
@ApiStatus.Internal public static native boolean _nIsHighContrast(); | ||
} |
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
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,36 @@ | ||
#include "ThemeWin32.hh" | ||
|
||
#include <Uxtheme.h> | ||
#include <impl/Library.hh> | ||
#include <AppWin32.hh> | ||
#include <VersionHelpers.h> | ||
#include <WinUser.h> | ||
#include <stdio.h> | ||
#include <Log.hh> | ||
#include <PlatformWin32.hh> | ||
#include "Theme.hh" | ||
|
||
|
||
bool jwm::ThemeWin32::isHighContrast() { | ||
HIGHCONTRASTA highContrast; | ||
highContrast.cbSize = sizeof(HIGHCONTRASTA); | ||
highContrast.dwFlags = 0; | ||
highContrast.lpszDefaultScheme = nullptr; | ||
bool isOk = SystemParametersInfoA(SPI_GETHIGHCONTRAST, 0, &highContrast, 0); | ||
if (!isOk) { | ||
JWM_VERBOSE("Failed to get SystemParametersInfoA for high contrast"); | ||
return false; | ||
} | ||
JWM_VERBOSE("is HighContrast? '" | ||
<< ((HCF_HIGHCONTRASTON & highContrast.dwFlags) == 1) << "'"); | ||
return (HCF_HIGHCONTRASTON & highContrast.dwFlags) == 1; | ||
} | ||
|
||
// JNI | ||
|
||
extern "C" JNIEXPORT bool JNICALL Java_io_github_humbleui_jwm_Theme__1nIsHighContrast | ||
(JNIEnv* env, jclass jclass) { | ||
jwm::AppWin32& app = jwm::AppWin32::getInstance(); | ||
jwm::ThemeWin32& theme = app.getTheme(); | ||
return theme.isHighContrast(); | ||
} |
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,17 @@ | ||
#pragma once | ||
#include <PlatformWin32.hh> | ||
|
||
#include "Theme.hh" | ||
#include "ThemeWin32.hh" | ||
|
||
namespace jwm { | ||
|
||
class ThemeWin32 final : public Theme { | ||
public: | ||
ThemeWin32() = default; | ||
~ThemeWin32() = default; | ||
|
||
bool isHighContrast(); | ||
|
||
}; | ||
} // namespace jwm |
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