Skip to content

Commit

Permalink
Indicate modes that are not suitable for desktop
Browse files Browse the repository at this point in the history
In the output of "displaymode d", add a "!" to modes where
CGDisplaymodeIsUsableForDesktopGUI returns false.
  • Loading branch information
p00ya committed Apr 4, 2020
1 parent 65b238a commit 44467ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ Display 0:
2560 x 1600 @60.0Hz *
1280 x 800 @60.0Hz
2880 x 1800 @60.0Hz
640 x 480 @60.0Hz !
Display 1:
800 x 600 @75.0Hz *
```

where each row is the width x height in pixels, with an `*` to indicate the current mode. Display 0 is always the main display.
where each row is the width x height in pixels. `*` indicates the current mode, and `!` indicates modes that are not usable for the desktop.

Display 0 is always the main display.

## Other options

Expand Down
5 changes: 4 additions & 1 deletion displaymode.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ void PrintMode(CGDisplayModeRef mode) {
const size_t width = CGDisplayModeGetWidth(mode);
const size_t height = CGDisplayModeGetHeight(mode);
const double refresh_rate = CGDisplayModeGetRefreshRate(mode);
printf("%zu x %zu @%.1fHz", width, height, refresh_rate);
const bool usable_for_desktop =
CGDisplayModeIsUsableForDesktopGUI(mode);
printf("%zu x %zu @%.1fHz%s", width, height, refresh_rate,
usable_for_desktop ? "" : " !");
}

// Prints all display modes for the main display. Returns 0 on success.
Expand Down

0 comments on commit 44467ba

Please sign in to comment.