Files
itgmania212121/src/DisplaySpec.h
T
Drew Barbarello 557be7cf1b 5 1 new backport x11 fs rework (#1485)
* Use XRandR 1.2 to set fullscreen resolution for single output

Squash of roothorick's PR #497
(also includes Kyzentun's CMake changes from PR #716)

* Cherry-pick json c++1x stuff (b9e3d7174e)

* Cherry-pick c++11 support from 5bba5c0038 and 9f8b045309

* rework Linux (X11) fullscreen, improve display-related Graphics Options

Implement option to select between monitors for exclusive fullscreen mode
on X11 (using XRandR 1.2), or use a fullscreen borderless window.

Reimplement resolution/refresh rate/display mode-related option rows
using Lua, update choices dynamically so only known-good groupings of
resolution/refresh rate/aspect ratio can be selected.

Minimally update Windows/MacOS LowLevelWindow implementations to support
changes made for Linux side. Fullscreen Borderless Window/multi monitor
support from X11 not implemented for those in this commit.

* allow forcibly disabling xinerama use on Linux

When libXinerama is available, SM tries to use it to find the proper
monitor indexes to use to set _NET_WM_FULLSCREEN_MONITORS (on borderless
fullscreen). xfwm4 seems to assume that monitors are numbered in increasing
order from left to right (rather than using the Xinerama-assigned numbers),
so _NET_WM_FULLSCREEN_MONITORS misbehaves on Xfce.

This commit bypasses use of libXinerama, and instead forces SM to induce fullscreen
on the desired monitor in the backup, hacky way: remove all window hints, move window
to desired monitor, then add _NET_WM_STATE_FULLSCREEN hint. This works on
mutter and Xfce.

* Remove multiple warnings on redundant define.

This used to be hard-coded due to pthread related items, but now it's dynamically determined.

* fix _fallback menu behavior for unrecognized aspect ratios

* Fix error recreating existing FS texture

* Bump deployment target to 10.7 to use libc++ on XCode 8

* Add explicit casts to please clang

* Update changelog
2017-06-18 08:55:16 -07:00

204 lines
6.2 KiB
C++

#ifndef DisplaySpec_H
#define DisplaySpec_H
#include <set>
#include "RageTypes.h"
struct DisplayMode {
// Width (in pixels) of the display in this mode
unsigned int width;
// Height (in pixels) of the display in this mode
unsigned int height;
/** Refresh rate, in hz, of the display for the given mode
* MacOS Quartz Display Services provides rate as double,
* winapi DEVMODE uses 32bit unsigned int (still gives rate as hz),
* RandR gives 32 bit pixel clock, which is then divided by width*height.
*/
double refreshRate;
/*
* Bits-per-pixel is *not* a property of the DisplayMode for our purposes:
* bit-depth is going to be a property of the OpenGL/D3D context, not a display
* configuration
*/
bool operator<( const DisplayMode &other ) const
{
/** @brief A quick way to compare the two DisplayResolutions. */
#define COMPARE(x) if( x != other.x ) return x < other.x;
COMPARE( width );
COMPARE( height );
COMPARE( refreshRate );
#undef COMPARE
return false;
}
// Lua
void PushSelf( lua_State *L );
};
/** @brief The dimensions of the program. */
class DisplaySpec
{
public:
/*
* Construct a specification for the display with the given ID, which supports the given modes,
* and is currently using the specified mode with the specified logical screen bounds
*/
DisplaySpec(const std::string &id,
const std::string &name,
const std::set<DisplayMode> &modes,
const DisplayMode &curMode,
const RectI &curBounds,
const bool isVirtual=false):
m_sId( id ), m_sName( name ),
m_sModes( modes ), m_bCurModeActive( true ), m_CurMode( curMode ),
m_rectBounds( curBounds ), m_bIsVirtual( isVirtual )
{
if ( m_sModes.find( curMode ) == m_sModes.end() )
{
// This is an error, make a failing assertion with a descriptive error message
std::stringstream msgStream;
msgStream << "DisplaySpec current mode (" << curMode.width << "x" <<
curMode.height << "@" << curMode.refreshRate << ") not in given list of supported modes: ";
for ( auto &m : modes )
{
msgStream << m.width << "x" << m.height << "@" << m.refreshRate << ", ";
}
auto msg = msgStream.str();
// Drop the trailing ", "
msg.resize( msg.size() - 2 );
ASSERT_M( false, msg.c_str() );
}
}
/*
* Construct a specification for the display with the given ID, which supports the given modes,
* and is currently disabled (has no active mode)
*/
DisplaySpec(const std::string id,
const std::string name,
const std::set<DisplayMode> modes,
const bool isVirtual=false):
m_sId( id ), m_sName( name ),
m_sModes( modes ), m_bCurModeActive( false ), m_CurMode( { } ),
m_bIsVirtual( isVirtual )
{
}
// Create a specification for a display supporting a single (and currently active) mode
DisplaySpec(std::string id, std::string name, DisplayMode mode) : m_sId( id ), m_sName( name ), m_bIsVirtual( false ),
m_bCurModeActive( true ), m_CurMode( mode )
{
m_sModes.insert( mode );
m_rectBounds = RectI( 0, 0, mode.width, mode.height );
}
DisplaySpec( const DisplaySpec &other ) = default;
std::string name() const
{
return m_sName;
}
std::string id() const
{
return m_sId;
}
const std::set<DisplayMode> &supportedModes() const
{
return m_sModes;
}
/*
* Return a pointer to the currently active display mode, or NULL if
* display is inactive
*
* Note that inactive *does not* necessarily mean unusable. E.g., in X11,
* an output can be enabled/disabled by an application by connecting/disconnecting
* a crtc
*/
const DisplayMode *currentMode() const
{
return m_bCurModeActive ? &m_CurMode : nullptr;
}
const RectI &currentBounds() const
{
return m_rectBounds;
}
bool isVirtual() const
{
return m_bIsVirtual;
}
/**
* @brief Determine if one DisplaySpec compares less than the other.
*
* Used to enforce a consistent ordering of displays, e.g. for consistent option
* presentation. Also allows DisplaySpec to be placed in a std::set
*
* @param other the other DisplaySpec to check.
* @return true if this DisplaySpec is less than the other, or false otherwise. */
bool operator<( const DisplaySpec &other ) const
{
return m_sId < other.id();
}
// Lua
void PushSelf( lua_State *L );
private:
// Unique identifier of the display
std::string m_sId;
// "Human-readable" display name
std::string m_sName;
// Modes supported by this display
std::set<DisplayMode> m_sModes;
// currently configured mode, if available
bool m_bCurModeActive;
DisplayMode m_CurMode;
// The current bounds of this display in global display coordinate space
RectI m_rectBounds;
// Flag is "true" when display represents a logical display like an X screen
// or the Win32 "Virtual screen"
bool m_bIsVirtual;
};
/** @brief The collection of DisplaySpec available within the program. */
typedef std::set<DisplaySpec> DisplaySpecs;
//Lua
DisplaySpecs *pushDisplaySpecs(lua_State *L, const DisplaySpecs &specs);
#endif
/**
* @file
* @author Chris Danford (c) 2001-2005
* @section LICENSE
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/