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

Swift rewrite #2

Merged
merged 7 commits into from
Jul 24, 2023
Merged

Swift rewrite #2

merged 7 commits into from
Jul 24, 2023

Conversation

Bright-Shard
Copy link
Member

@Bright-Shard Bright-Shard commented Jun 27, 2023

A rewrite of all the Swift code, which minimises calls to NSApp.sendEvent (a method which causes random hangs/pauses while we're trying to handle events).

Bugs

  • The stoplight buttons on the window aren't coloured right on hover. I can't figure out a way to get just the icon to appear, without changing the background.
  • The hit targets for resizing the window might not be the right size. I'm having to manually program window resizes, so I don't know what they normally are sized at, and went for ~7px.
  • The mouse cursor doesn't always reset correctly to the arrow cursor after resizing the window. As far as I can tell, this is an issue with NSCursor (like a race condition from setting the cursor twice or something), not my code, but it's still an issue.
  • Not all events currently implemented.
  • (As noted by Spey) Sometimes the cursor changes to a resize cursor, but dragging doesn't actually resize the window
  • macOS doesn't differentiate middle mouse clicks from other mouse buttons. Need to figure out what button number represents the middle mouse button, and use that for middle mouse events.

@Bright-Shard
Copy link
Member Author

Bright-Shard commented Jun 28, 2023

Features to implement:
  • 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

Events to support:
  • 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.

@Speykious
Copy link
Member

I discovered another bug: while resizing, move the cursor very fast to try to shrink the window to 0. The window disappears and never reappears again.

@Bright-Shard
Copy link
Member Author

Bright-Shard commented Jul 6, 2023

@Bright-Shard
Copy link
Member Author

Source for keycodes: https://developer.mozilla.org/en-US/docs/web/api/ui_events/keyboard_event_code_values#code_values_on_mac

This may be useable for other platforms as well.

@Bright-Shard Bright-Shard marked this pull request as ready for review July 24, 2023 23:35
@Bright-Shard
Copy link
Member Author

Moved progress tracking to #3

@Bright-Shard Bright-Shard merged commit 31ce6ee into main Jul 24, 2023
@Bright-Shard Bright-Shard deleted the swift-rewrite branch November 7, 2023 15:50
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