Giter Site home page Giter Site logo

lokinit's Introduction

Lokinit

The smallest cross-platform native windowing library.   Discord

 

Lokinit is the smallest cross-platform native windowing library for Rust. Its goal is to bring a window to the screen on all major operating systems, with a dependency tree as minimal as it should be, and code that is simple and straightforward.

Cargo may be an amazing package manager, but making projects with hundreds of dependencies nested in a deep tree has some disadvantages:

  • it clogs up compile times by orders of magnitude. Upon a cargo clean, it's very easy to see middle-sized projects take several minutes to build. Miniquad, a very good example of a sizeable project with a minimal dependency tree, on the other hand takes less than 5 seconds in the same situation.
  • we get restricted to what the dependencies can let us do with their goal. The more dependencies we use, the more we'll have to rely on other developers to fix problems that affect us.
  • quite often, the code of such dependencies is much more complex than it needs to be for our use-case, probably as a result of trying to be broad enough for lots of other use-cases. This makes the code less easy to understand, and also harder to debug and optimize.

On the other hand, rolling with our own code may also have its own disadvantages:

  • the burden is placed on the developer to maintain code that they have to write themselves.
  • there is no guarantee that the code written will turn out to be a better solution than one that is battle-tested or simply more mature.

In short, there definitely is a balance to be had when it comes to dependencies. But I believe that balance should be heavily shifted to a place where 100 dependencies is extravagant or niche rather than the norm.

When it comes to native window management, the task at hand is to interact with the relevant system libraries on each operating system to spawn a window on the screen, and manage all the various properties that a window might need: resizing, fullscreen, having a title, binding to a graphics API so we can draw stuff to the screen. We shouldn't need any other dependencies than system ones, and Miniquad has shown that.

However, Miniquad is not a windowing project, it is a cross-platform graphics rendering project that leverages a lot of custom-made code for windowing. The one and most advanced Rust project when it comes to windowing is Winit. It seems to work extremely well so far and has a lot of features under its belt for each OS they support. The problem is that it pulls out a deep nested tree of 60 dependencies for this, just on one OS. It takes several minutes to compile after a cargo clean. To make matters worse, if you need OpenGL, you need to add glutin, glutin-winit and raw-window-handle as hard dependencies too. I am convinced that we can do better than this, and have something that weighs almost nothing in terms of dependencies and compile times. That way, projects using Lokinit won't have to pull in 60 dependencies out of the box.

Status of Lokinit

WIP

See FEATURES.md.

Supported Platforms

We intend to support the 5 major native platforms, desktop and mobile:

  • Desktop
    • Linux
    • MacOS
    • Windows
  • Mobile
    • Android
    • iOS

We don't intend to support Web as a target. The web has vastly different needs and constraints than native systems when it comes to windowing, so if there ever is a need for it, it should probably be in a different crate with a completely different API.

(We may support Redox one day.)

Goals of Lokinit

  • Fast compilation times. Lokinit should compile under 5 seconds after a cargo clean.
  • Minimal dependencies. We shouldn't need more than system library dependencies to do windowing properly. For such a task, 10 dependencies total is already considered too much.
  • Cross-platform. It should support all 5 major native platforms as flawlessly as possible, potentially more OSes in the future like Redox.
  • Focus on windowing. Our feature goals are pretty much the exact same as Winit, to spawn a window on all native platforms.
  • Easy and minimal binding to low-level graphics APIs. People should be able to easily use Lokinit as a dependency and bind whatever graphics API they want: OpenGL, Vulkan, DirectX, Metal, or even a raw framebuffer.

License

Lokinit is dual-licensed under APACHE and MIT. See LICENSE-APACHE and LICENSE-MIT for details.

lokinit's People

Contributors

speykious avatar bright-shard avatar corbanator avatar

Stargazers

Colin Cai avatar  avatar

Watchers

 avatar

lokinit's Issues

Linux (Wayland) support

Progress tracking issue for Linux (Wayland).

Features to add

Specific events:
  • Window resized
  • Window moved
  • Window close requested
  • Window destroyed
  • Redraw requested
  • Focus in
  • Focus out
  • File dropped
  • File hovered
  • File hover cancelled
  • Keyboard events:
    • Key press
    • Key release
    • Key repeat
    • IME commit
  • Mouse events:
    • Pressed
      • Left
      • Middle
      • Right
      • Other
    • Released
      • Left
      • Middle
      • Right
      • Other
    • Moved
    • Entered window
    • Left window
    • Scroll wheel
  • Touch events:
    • Started
    • Moved
    • Ended
    • Cancelled

Taken from the EventKind enum.

Other features:
  • Window initialization
  • Multiple windows
  • OpenGL support
  • Vulkan support
  • Window decorations
  • Window resizing events
  • Window resize increments
  • Window transparency
  • Window max/min-imisation
  • Fullscreen
  • Exclusive Fullscreen
  • HiDPI
  • Popups
  • Monitor info
  • Video mode query
  • Mouse events
  • Set, lock, or confine mouse cursor
  • Custom cursor icon
  • Cursor hittests
  • Touch events
  • Touch pressure
  • Multitouch
  • Keyboard events
  • Drag 'n drop
  • Raw device events
  • Gamepad/joystick events
  • Device movement events

Copypasted from X11 tracking issue

macOS Support

Progress tracking issue for macOS.

Known Bugs

  • Stoplight buttons are miscoloured on hover. I'm having to manually change their state, and ended up putting them in a clicked state instead of a hovered state. Fixed by forwarding more mouse events to macOS instead of trying to set the state myself.
  • On newer versions of macOS, hovering over the fullscreen button shows a tiling prompt. Loki windows don't, presumably because they don't use standard NSApp event handling. Fixed by forwarding more mouse events to macOS instead of trying to set the state myself.
  • Clicking on things in the tiling prompt mentioned above crashes lokinit (and possibly parts of macOS as well, somehow?)
  • The close_window API currently does nothing
  • Stoplight buttons aren't always coloured correctly when a window loses and then gains focus
  • The mouse cursor isn't always set right. I think AppKit is interfering somehow.
  • All events currently return Duration::ZERO instead of an actual time.
  • The keyboard events send a keycode instead of the key that was pressed. The keycode represents what the key would be on a QWERTY keyboard, instead of what was actually pressed in the user's layout.
  • Control keys do not trigger repeat events when held

Features to add

Specific events:
  • Window resized
  • Window moved
  • Window close requested
  • Window destroyed
  • Redraw requested
  • Focus in
  • Focus out
  • File dropped
  • File hovered
  • File hover cancelled
  • Keyboard events:
    • Key press
    • Key release
    • Key repeat
    • IME commit
  • Mouse events:
    • Pressed
      • Left
      • Middle
      • Right
      • Other
    • Released
      • Left
      • Middle
      • Right
      • Other
    • Moved
    • Entered window
    • Left window
    • Scroll wheel
  • Touch events:
    • Started
    • Moved
    • Ended
    • Cancelled

Taken from EventType enum.

Other features:
  • Window initialization
  • Multiple windows
  • OpenGL support
  • Metal support
  • Window deco
  • Window resizing events
  • Window resize increments
  • Window transparency
  • Window max/min-imisation
  • Fullscreen
  • Exclusive Fullscreen
  • HiDPI (All macs are HiDPI, should work out of the box)
  • Popups
  • Monitor info
  • Video mode query
  • Mouse events
  • Set, lock, or confine mouse cursor
  • Custom cursor icon
  • Cursor hittests
  • Touch events
  • Touch pressure
  • Multitouch
  • Keyboard events
  • Drag 'n drop
  • Raw device events
  • Gamepad/joystick events
  • Device movement events

Taken from https://github.com/loki-chat/lokinit/blob/main/FEATURES.md

Notes

  • I'm manually handling window resizing, and because of that, I'm not sure if the hit targets are the right size.

Linux (X11) support

Progress tracking issue for Linux (X11).

Features to add

Specific events:
  • Window resized
  • Window moved
  • Window close requested
  • Window destroyed
  • Redraw requested
  • Focus in
  • Focus out
  • File dropped
  • File hovered
  • File hover cancelled
  • Keyboard events:
    • Key press
    • Key release
    • Key repeat
    • IME commit
  • Mouse events:
    • Pressed
      • Left
      • Middle
      • Right
      • Other
    • Released
      • Left
      • Middle
      • Right
      • Other
    • Moved
    • Entered window
    • Left window
    • Scroll wheel
  • Touch events:
    • Started
    • Moved
    • Ended
    • Cancelled

Taken from the EventKind enum.

Other features:
  • Window initialization
  • Multiple windows
  • OpenGL support
  • Vulkan support
  • Window decorations
  • Window resizing events
  • Window resize increments
  • Window transparency
  • Window max/min-imisation
  • Fullscreen
  • Exclusive Fullscreen
  • HiDPI
  • Popups
  • Monitor info
  • Video mode query
  • Mouse events
  • Set, lock, or confine mouse cursor
  • Custom cursor icon
  • Cursor hittests
  • Touch events
  • Touch pressure
  • Multitouch
  • Keyboard events
  • Drag 'n drop
  • Raw device events
  • Gamepad/joystick events
  • Device movement events

Taken from https://github.com/loki-chat/lokinit/blob/main/FEATURES.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.