* 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:
@@ -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
|
/*! This method assumes that you already reverted to the correct number
|
||||||
of workspaces.
|
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
|
int32
|
||||||
ScreenMode::CountModes()
|
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
|
bool
|
||||||
ScreenMode::_GetDisplayMode(const screen_mode& mode, display_mode& displayMode)
|
ScreenMode::_GetDisplayMode(const screen_mode& mode, display_mode& displayMode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005, Haiku.
|
* Copyright 2005-2011, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -38,40 +38,50 @@ struct screen_mode {
|
|||||||
|
|
||||||
class ScreenMode {
|
class ScreenMode {
|
||||||
public:
|
public:
|
||||||
ScreenMode(BWindow* window);
|
ScreenMode(BWindow* window);
|
||||||
~ScreenMode();
|
~ScreenMode();
|
||||||
|
|
||||||
status_t Set(const screen_mode& mode, int32 workspace = ~0);
|
status_t Set(const screen_mode& mode,
|
||||||
status_t Get(screen_mode& mode, int32 workspace = ~0) const;
|
int32 workspace = ~0);
|
||||||
status_t GetOriginalMode(screen_mode &mode,
|
status_t Get(screen_mode& mode,
|
||||||
int32 workspace = ~0) const;
|
int32 workspace = ~0) const;
|
||||||
|
status_t GetOriginalMode(screen_mode &mode,
|
||||||
|
int32 workspace = ~0) const;
|
||||||
|
|
||||||
status_t Revert();
|
status_t Set(const display_mode& mode,
|
||||||
void UpdateOriginalModes();
|
int32 workspace = ~0);
|
||||||
|
status_t Get(display_mode& mode,
|
||||||
|
int32 workspace = ~0) const;
|
||||||
|
|
||||||
bool SupportsColorSpace(const screen_mode& mode,
|
status_t Revert();
|
||||||
color_space space);
|
void UpdateOriginalModes();
|
||||||
status_t GetRefreshLimits(const screen_mode& mode,
|
|
||||||
float& min, float& max);
|
|
||||||
status_t GetMonitorInfo(monitor_info& info,
|
|
||||||
float* _diagonalInches = NULL);
|
|
||||||
|
|
||||||
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);
|
status_t GetDeviceInfo(accelerant_device_info& info);
|
||||||
int32 CountModes();
|
|
||||||
|
screen_mode ModeAt(int32 index);
|
||||||
|
const display_mode& DisplayModeAt(int32 index);
|
||||||
|
int32 CountModes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _GetDisplayMode(const screen_mode& mode,
|
bool _GetDisplayMode(const screen_mode& mode,
|
||||||
display_mode& displayMode);
|
display_mode& displayMode);
|
||||||
|
|
||||||
BWindow* fWindow;
|
private:
|
||||||
display_mode* fModeList;
|
BWindow* fWindow;
|
||||||
uint32 fModeCount;
|
display_mode* fModeList;
|
||||||
|
uint32 fModeCount;
|
||||||
|
|
||||||
bool fUpdatedModes;
|
bool fUpdatedModes;
|
||||||
display_mode fOriginalDisplayMode[32];
|
display_mode fOriginalDisplayMode[32];
|
||||||
screen_mode fOriginal[32];
|
screen_mode fOriginal[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* SCREEN_MODE_H */
|
#endif /* SCREEN_MODE_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user