Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

API inconsistency with DPI_AWARE flag

オープン
#93 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
リファクタリング
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
cpp, lua
領域
api, desktop

調査の方向性

まず r_renderer_c::VirtualScreenScaleFactor() と GetScreenSize および GetScaleFactor の API エントリポイントを追跡し、次にレンダー関数が位置とサイズの引数をどのように扱っているかを比較します。PR 44、80、86 の DPI_AWARE に関する変更と、関連する Win32/GLFW のスケーリングコードを確認します。API の契約と実行時のスケーリング動作に一貫性があり、意図した Lua の動作がテストまたは文書化された検証手順によってカバーされていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

The DPI_AWARE flag was introduced with https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic/pull/44/commits/59492a4003ea77c03f9ae62c5e66a13afd02f313 as a way for the Lua code to opt out of the virtualization and get access to physical sizes/positions.

With the recent work on UI scaling in https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic/pull/80 and https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic/pull/86, the API has ended up in an inconsistent state where some functions use physical units if DPI_AWARE is set, but others still use virtual units in its arguments and return values.

For example, GetScreenSize returns physical units (i.e. the pixel size of the framebuffer), while all the other API functions still receive and return virtual units. It looks like PoB Lua code is not ready to deal with physical units, so the screen size is actually mapped right back to virtual units. Maybe PoB just shouldn't set the DPI_AWARE flag yet because everything seems to be done in virtual units at the moment. But that leads us to the second problem(?):

With the current implementation of r_renderer_c::VirtualScreenScaleFactor() and its usage in the API functions, the DPI_AWARE flag seems to serve two different functions:

  1. A way to influence the "API contract" between the Lua code and SimpleGraphic. Setting it tells the API to accept and return positions and sizes in physical units instead of virtual units (this seems to be in line with the original intention of this flag).
  2. To control whether application UI scaling is performed by the runtime. Before the recent changes, VirtualScreenScaleFactor was only used to determine which factor to return to Lua in the GetScaleFactor API function. Currently, it is also being used in the render functions to scale their position/size arguments. Not setting the flag means 1.0 is always returned, effectively turning off scaling.

The second behavior surprised me a bit. This means we cannot unset the flag and only use virtual units between Lua <-> Runtime because it would turn off the scaling entirely.

Here is how i expected it to work:

  • Make the runtime always DPI aware and perform app scaling: I'm not very familiar with the win32 api but it looks like we can tell the OS that our application is per-monitor (v2) DPI aware. Maybe that's already the case? I've also spotted code that checks registry values to decide whether to ignore the scaling factor returned by GLFW. Not sure if that's needed anymore.
  • Have the flag only affect the API contract, meaning physical units are used between Lua and SimpleGraphic if the flag is set, otherwise we only let Lua know about the virtual world. Not setting the flag shouldn't have any effect on whether scaling is performed.
  • If users want to override the scaling factor given by the OS, they can use the newly added scaling factor override in the settings.
  • With these changes, we can unset the DPI_AWARE flag again, since PoB doesn't currently care about the physical world, but still retain the scaling behavior.

If i'm missing something or wrongly interpreted the intention behind the flag, then just ignore my approach. This API inconsistency manifested itself in a very minor problem that I've opted to fix on the Lua side for now: https://github.com/PathOfBuildingCommunity/PathOfBuilding/pull/9373.

主要言語
C++
スター
22
フォーク
62
平均マージ
1日 3時間
マージ済み PR(30日)
4

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic のほかの issue

PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。