* Added methods to work with display_modes directly.

* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42735 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2011-09-11 11:04:43 +00:00
parent c9e95a67dc
commit df9db7862b
2 changed files with 81 additions and 26 deletions
+45
View File
@@ -242,6 +242,36 @@ ScreenMode::GetOriginalMode(screen_mode& mode, int32 workspace) const
}
status_t
ScreenMode::Set(const display_mode& mode, int32 workspace)
{
if (!fUpdatedModes)
UpdateOriginalModes();
BScreen screen(fWindow);
if (workspace == ~0)
workspace = current_workspace();
// BScreen::SetMode() needs a non-const display_mode
display_mode nonConstMode;
memcpy(&nonConstMode, &mode, sizeof(display_mode));
return screen.SetMode(workspace, &nonConstMode, true);
}
status_t
ScreenMode::Get(display_mode& mode, int32 workspace) const
{
BScreen screen(fWindow);
if (workspace == ~0)
workspace = current_workspace();
return screen.GetMode(workspace, &mode);
}
/*! This method assumes that you already reverted to the correct number
of workspaces.
*/
@@ -558,6 +588,18 @@ ScreenMode::ModeAt(int32 index)
}
const display_mode&
ScreenMode::DisplayModeAt(int32 index)
{
if (index < 0)
index = 0;
else if (index >= (int32)fModeCount)
index = fModeCount - 1;
return fModeList[index];
}
int32
ScreenMode::CountModes()
{
@@ -565,6 +607,9 @@ ScreenMode::CountModes()
}
/*! Searches for a similar mode in the reported mode list, and if that does not
find a matching mode, it will compute the mode manually using the GTF.
*/
bool
ScreenMode::_GetDisplayMode(const screen_mode& mode, display_mode& displayMode)
{
+36 -26
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2005, Haiku.
* Copyright 2005-2011, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -38,40 +38,50 @@ struct screen_mode {
class ScreenMode {
public:
ScreenMode(BWindow* window);
~ScreenMode();
ScreenMode(BWindow* window);
~ScreenMode();
status_t Set(const screen_mode& mode, int32 workspace = ~0);
status_t Get(screen_mode& mode, int32 workspace = ~0) const;
status_t GetOriginalMode(screen_mode &mode,
int32 workspace = ~0) const;
status_t Set(const screen_mode& mode,
int32 workspace = ~0);
status_t Get(screen_mode& mode,
int32 workspace = ~0) const;
status_t GetOriginalMode(screen_mode &mode,
int32 workspace = ~0) const;
status_t Revert();
void UpdateOriginalModes();
status_t Set(const display_mode& mode,
int32 workspace = ~0);
status_t Get(display_mode& mode,
int32 workspace = ~0) const;
bool SupportsColorSpace(const screen_mode& mode,
color_space space);
status_t GetRefreshLimits(const screen_mode& mode,
float& min, float& max);
status_t GetMonitorInfo(monitor_info& info,
float* _diagonalInches = NULL);
status_t Revert();
void UpdateOriginalModes();
status_t GetDeviceInfo(accelerant_device_info& info);
bool SupportsColorSpace(const screen_mode& mode,
color_space space);
status_t GetRefreshLimits(const screen_mode& mode,
float& min, float& max);
status_t GetMonitorInfo(monitor_info& info,
float* _diagonalInches = NULL);
screen_mode ModeAt(int32 index);
int32 CountModes();
status_t GetDeviceInfo(accelerant_device_info& info);
screen_mode ModeAt(int32 index);
const display_mode& DisplayModeAt(int32 index);
int32 CountModes();
private:
bool _GetDisplayMode(const screen_mode& mode,
display_mode& displayMode);
bool _GetDisplayMode(const screen_mode& mode,
display_mode& displayMode);
BWindow* fWindow;
display_mode* fModeList;
uint32 fModeCount;
private:
BWindow* fWindow;
display_mode* fModeList;
uint32 fModeCount;
bool fUpdatedModes;
display_mode fOriginalDisplayMode[32];
screen_mode fOriginal[32];
bool fUpdatedModes;
display_mode fOriginalDisplayMode[32];
screen_mode fOriginal[32];
};
#endif /* SCREEN_MODE_H */