Kaydet (Commit) 9f308fbc authored tarafından Keith Curtis's avatar Keith Curtis Kaydeden (comit) Caolán McNamara

Simplify resolution calculation

Removed unnecessary complexity with resolutions because X in 2014 isn't
telling the truth about the size of the screen. My brand-new 13" laptop
with the latest X and everything apparently has a 33" x 18" monitor. So
if the data isn't reliable, just use 96 dpi anyway which is a very
reasonable default.

Also got rid of exact resolution member variable. LibreOffice can just
always think it has exact resolution. If it doesn't, then it just means
the code needs to be smarter, not that we need a flag about whether the
data we have is "exact" or not.

Change-Id: Ic41bdc3a82dbd1fdb6a987d6dc49adad8194ce14
Reviewed-on: https://gerrit.libreoffice.org/8166Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst ff6f3164
...@@ -252,7 +252,6 @@ protected: ...@@ -252,7 +252,6 @@ protected:
std::vector< ScreenData > m_aScreens; std::vector< ScreenData > m_aScreens;
ScreenData m_aInvalidScreenData; ScreenData m_aInvalidScreenData;
Pair aResolution_; // [dpi] Pair aResolution_; // [dpi]
bool mbExactResolution;
sal_uLong nMaxRequestSize_; // [byte] sal_uLong nMaxRequestSize_; // [byte]
srv_vendor_t meServerVendor; srv_vendor_t meServerVendor;
...@@ -353,7 +352,6 @@ public: ...@@ -353,7 +352,6 @@ public:
const SalVisual& GetVisual( SalX11Screen nXScreen ) const { return getDataForScreen(nXScreen).m_aVisual; } const SalVisual& GetVisual( SalX11Screen nXScreen ) const { return getDataForScreen(nXScreen).m_aVisual; }
RenderEntryMap& GetRenderEntries( SalX11Screen nXScreen ) const { return getDataForScreen(nXScreen).m_aRenderData; } RenderEntryMap& GetRenderEntries( SalX11Screen nXScreen ) const { return getDataForScreen(nXScreen).m_aRenderData; }
const Pair &GetResolution() const { return aResolution_; } const Pair &GetResolution() const { return aResolution_; }
bool GetExactResolution() const { return mbExactResolution; }
sal_uLong GetProperties() const { return PROPERTY_DEFAULT; } sal_uLong GetProperties() const { return PROPERTY_DEFAULT; }
sal_uLong GetMaxRequestSize() const { return nMaxRequestSize_; } sal_uLong GetMaxRequestSize() const { return nMaxRequestSize_; }
XLIB_Time GetLastUserEventTime( bool bAlwaysReget = false ) const; XLIB_Time GetLastUserEventTime( bool bAlwaysReget = false ) const;
......
...@@ -540,7 +540,7 @@ void SalDisplay::Init() ...@@ -540,7 +540,7 @@ void SalDisplay::Init()
int nDisplayScreens = ScreenCount( pDisp_ ); int nDisplayScreens = ScreenCount( pDisp_ );
m_aScreens = std::vector<ScreenData>(nDisplayScreens); m_aScreens = std::vector<ScreenData>(nDisplayScreens);
mbExactResolution = false; bool bExactResolution = false;
/* #i15507# /* #i15507#
* Xft resolution should take precedence since * Xft resolution should take precedence since
* it is what modern desktops use. * it is what modern desktops use.
...@@ -554,27 +554,12 @@ void SalDisplay::Init() ...@@ -554,27 +554,12 @@ void SalDisplay::Init()
if( (nDPI >= 50) && (nDPI <= 500) ) if( (nDPI >= 50) && (nDPI <= 500) )
{ {
aResolution_ = Pair( nDPI, nDPI ); aResolution_ = Pair( nDPI, nDPI );
mbExactResolution = true; bExactResolution = true;
} }
} }
if( mbExactResolution == false ) if( bExactResolution == false )
{ {
int nDisplayWidth = DisplayWidthMM ( pDisp_, m_nXDefaultScreen.getXScreen() ); aResolution_ = Pair( 96, 96 );
int nDisplayHeight = DisplayHeightMM( pDisp_, m_nXDefaultScreen.getXScreen() );
if (nDisplayHeight == 0 || nDisplayWidth == 0)
{
aResolution_ = Pair( 96, 96 );
SAL_WARN("vcl", "screen width/height reported as 0!, using fallback 96dpi");
}
else
{
aResolution_ =
Pair( DPI( WidthOfScreen( DefaultScreenOfDisplay( pDisp_ ) ),
nDisplayWidth ),
DPI( HeightOfScreen( DefaultScreenOfDisplay( pDisp_ ) ),
nDisplayHeight ) );
}
} }
nMaxRequestSize_ = XExtendedMaxRequestSize( pDisp_ ) * 4; nMaxRequestSize_ = XExtendedMaxRequestSize( pDisp_ ) * 4;
......
...@@ -484,12 +484,8 @@ void X11SalGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) // cons ...@@ -484,12 +484,8 @@ void X11SalGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) // cons
rDPIX = pDisplay->GetResolution().A(); rDPIX = pDisplay->GetResolution().A();
rDPIY = pDisplay->GetResolution().B(); rDPIY = pDisplay->GetResolution().B();
if( !pDisplay->GetExactResolution() && rDPIY < 96 )
{ if ( rDPIY > 200 )
rDPIX = Divide( rDPIX * 96, rDPIY );
rDPIY = 96;
}
else if ( rDPIY > 200 )
{ {
rDPIX = Divide( rDPIX * 200, rDPIY ); rDPIX = Divide( rDPIX * 200, rDPIY );
rDPIY = 200; rDPIY = 200;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment