Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High Contrast Management #433

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

malisipi
Copy link
Collaborator

@malisipi malisipi commented Jun 24, 2024

To get more information about why it's required, you can browse #432.

  • Support to enable/disable default browser behavior about high contrast.
    • Chrome (Using --disable-features=ForcedColors command line flag)
    • Edge (Using --disable-features=ForcedColors command line flag)
    • Firefox (Using browser.display.document_color_use=1 on WebUI-NoHC profile)
  • Detect high contrast theme enabled
    • Windows (Using HKEY_CURRENT_USER\Control Panel\Accessibility\HighContrast -> Flags)
    • Linux (Using gsettings get org.gnome.desktop.a11y.interface high-contrast)
    • MacOS (I have not a Mac computer)
  • API to check OS high contrast theme from
    • Backend
    • Frontend

@malisipi malisipi marked this pull request as ready for review June 24, 2024 20:03
@malisipi
Copy link
Collaborator Author

I am not much knowledge about WebUI Frontend API. So I couldn't implement the API however since backend is exist of API, it should not be hard.
Also I have not a Mac computer, so I can not implement detecting on MacOS.

@hassandraga hassandraga merged commit 6b539c3 into webui-dev:main Jun 25, 2024
24 checks passed
@hassandraga
Copy link
Member

Thank you @malisipi for this new feature, I will try to implement the macOS and frontend part later.

@hassandraga
Copy link
Member

Backend (acc77ce).
Frontend (88cd5f3).

Thank you @malisipi for the idea of frontend, now, we have an easy mechanism to internally call any core API from Bridge:

Bridge:

async isHighContrast(): Promise<boolean> {
    // Call a core function and wait for response
    const response = await this.callCore("_YOUR_CORE_SHORT_ID_HERE_") as boolean; // Any datatype
    if (this.#log) console.log(`Core Response: [${response}]`);
    return response;
}

webui.c:

static void _webui_bridge_api_handler(webui_event_t* e) {
    // ...

    if (strcmp(api_name, "_YOUR_CORE_SHORT_ID_HERE_") == 0) {
        webui_return_bool(e, webui_is_high_contrast()); // Any API
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants