Skip to content

Proposal: Unified Mado API #9

@kkoreilly

Description

@kkoreilly

The README states that the purpose of mado is to be a base layer for Go GUI frameworks. Currently, various Go GUI frameworks depend on go-gl/glfw, which is why one of the goals of mado is to provide a glfw compatible API. However, glfw is not the best basis for an elegant, cross-platform Go library, given that it is a C library written for desktop only. Trying to satisfy the glfw API limits the scope of the mado project and forces GUI frameworks to figure out mobile and web with their own abstractions.

Because of the lack of a unified, cross-platform system API, many Go GUI frameworks like Cogent Core, Fyne, Gio, and Ebiten have written their own versions of the same fundamental API: an interface between messy platform-specific code and a simple, cross-platform Go API. Therefore, significant amounts of time are wasted implementing the same things across the different frameworks, with each one having to figure out each new feature manually. Additionally, this leads to various features being missing in some or all frameworks, including accessibility, push notifications, and IME support, the original motivation for mado.

Instead of each framework individually implementing IME support or waiting for a PR almost nine years old to be merged (glfw/glfw#658), I propose that we collaborate on turning mado into a fully functional, cross-platform, completely glfw-independent API designed specifically for Go GUI frameworks. The core structure behind all of the system app driver implementations is very similar across the different frameworks, and I believe that we can reach a consensus on an API that will work for all of them and reduce the amount of time all of us have to spend writing code in C, Objective-C, and Java.

This is a concrete outline of my proposal for the new structure of mado:

  • Remove all existing directories, including glfw
  • Form the following package structure:
    • mado (the root of the repository) contains cross-platform interfaces like App and Window that importers of mado interact with and platform-specific packages implement
      • windows, mac, x11, wayland, android, ios, web, and offscreen provide platform-specific implementations of the interfaces in the mado package using platform-specific code that extends the base implementations
      • base provides base implementations of the mado interfaces that the platform-specific implementations can extend
      • events provides a comprehensive event system that allows the transmission of various types of events from the system to the consumer of the Go API using an event deque

This structure is based on the structure of goosi, the cross-platform system app interface API that I developed for Cogent Core. It already supports mobile, web, and offscreen without any glfw dependency, and it uses glfw for desktop, but that will be replaced with direct code in this new mado structure. In addition to being based on goosi, this new mado structure would also take code from Gio, Fyne, and glfw, which would allow us to get a fully functional, cross-platform, glfw-independent, IME-supporting Go system app interface API within a couple of weeks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions