Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.49k stars 174 forks source link

Multi-monitor/display not properly supported on Linux #1278

Closed Domarius closed 3 years ago

Domarius commented 3 years ago

Describe the bug On Linux, I have 2 monitors, 1920x1200 and 1680x1050.

On html5 (from vscode debugging), I get only 1 display, but it's of the correct resolution - 1920x1200. When I build, I correctly get 2 displays (from Display.all) but height and width for both is 3600x1200.

Additionally, a segfault occours in build mode if Display.primary is accessed early in the program eg. in main(), before System.start. Accessing Display.primary from the update loop works though.

To Reproduce On Linux, with more than one monitor;

  1. Make a new project, update to latest Kha.
  2. Put "trace(Display.primary.width)" at the top of main(). Build and run. The application quits immediately. Running from the console shows a segfault error.
  3. Move "trace(Display.primary.width)" into the update loop. Build and run. Note that it will be a much larger value than it should be, something close to the combined width of both monitors.

Expected behavior The correct resolution should be reported for Display.width and Display.height for the individual monitors. Also a segfault should not occour when accessing Display.primary from the start of the program, so we can create a full screen window that matches the primary monitor current resolution, using System.start.

Execution Environment:

RobDangerous commented 3 years ago

You generally can not call any Kha API before calling System.start. But there's an exception for the Display API - you can call Display.init and then use if before initializing Kha properly.

Domarius commented 3 years ago

Display.init() now works correctly! Tested on Linux and Windows.