Skip to content

Commit

Permalink
Update display validation, a display is now valid when it has active …
Browse files Browse the repository at this point in the history
…bound information
  • Loading branch information
cklosters committed Jun 7, 2022
1 parent fcd3910 commit 35b9f6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
7 changes: 3 additions & 4 deletions modules/naprender/src/renderservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2445,10 +2445,9 @@ namespace nap
nap::Display::Display(int index) : mIndex(index)
{
assert(index < SDL::getDisplayCount());
int dr = SDL::getDisplayDPI(index, &mDDPI, &mHDPI, &mVDPI);
bool name = SDL::getDisplayName(index, mName);
int br = SDL::getDisplayBounds(index, mMin, mMax);
mValid = (br == 0);
SDL::getDisplayDPI(index, &mDDPI, &mHDPI, &mVDPI);
SDL::getDisplayName(index, mName);
mValid = SDL::getDisplayBounds(index, mMin, mMax) == 0;
}


Expand Down
18 changes: 11 additions & 7 deletions modules/naprender/src/renderservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ namespace nap
{
public:
/**
* Extracts display information.
* Index must be >= 0 && < SDL::getDisplayCount()
* Extracts display information. Index must be >= 0 && < SDL::getDisplayCount()
* @param index display index
*/
Display(int index);
Expand All @@ -150,22 +149,26 @@ namespace nap
int getIndex() const { return mIndex; }

/**
* @return diagonal dpi
* Returns diagonal dots per inch. 0 if diagonal DPI not available.
* @return diagonal dots per inch. 0 if diagonal DPI not available.
*/
float getDiagonalDPI() const { return mDDPI; }

/**
* @return horizontal dpi
* Returns horizontal dots per inch. 0 if horizontal DPI not available.
* @return horizontal dots per inch. 0 if horizontal DPI not available.
*/
float getHorizontalDPI() const { return mHDPI; }

/**
* @return vertical dpi
* Returns vertical dots per inch. 0 if vertical DPI not available.
* @return vertical dots per inch. 0 if vertical DPI not available.
*/
float getVerticalDPI() const { return mVDPI; }

/**
* @return display name
* Returns display name, empty if not available.
* @return display name, empty if not available.
*/
const std::string& getName() const { return mName; }

Expand All @@ -185,7 +188,8 @@ namespace nap
math::Rect getBounds() const;

/**
* @return if display information was extracted successfully on construction
* Returns if this display has valid bounds.
* @return if this display has valid bounds.
*/
bool isValid() const { return mValid; }

Expand Down

0 comments on commit 35b9f6d

Please sign in to comment.