Kaydet (Commit) c53f1d1f authored tarafından Michael Meeks's avatar Michael Meeks

fdo#62815 - tolerate crazy / out-of-bound ScreenNumbers for FullScreen

Thus making the gtk+ backend more similar to the generic backend
in this regard; also be more strict about invalid monitors -> empty
screens.

Change-Id: Ia4f2e1205cb1d309fb1bb01f9631167339a3478e
üst 341ff124
...@@ -70,6 +70,13 @@ struct GdkRectangleEqual ...@@ -70,6 +70,13 @@ struct GdkRectangleEqual
} }
/**
* GtkSalSystem::countScreenMonitors()
*
* This method builds the vector which allows us to map from VCL's
* idea of linear integer ScreenNumber to to gtk+'s rather more
* complicated screen + monitor concept.
*/
void void
GtkSalSystem::countScreenMonitors() GtkSalSystem::countScreenMonitors()
{ {
...@@ -134,6 +141,11 @@ GtkSalSystem::getScreenMonitorFromIdx (int nIdx, gint &nMonitor) ...@@ -134,6 +141,11 @@ GtkSalSystem::getScreenMonitorFromIdx (int nIdx, gint &nMonitor)
break; break;
} }
nMonitor = nIdx; nMonitor = nIdx;
// handle invalid monitor indexes as non-existent screens
if (nMonitor < 0 || (pScreen && nMonitor >= gdk_screen_get_n_monitors (pScreen)))
pScreen = NULL;
return pScreen; return pScreen;
} }
......
...@@ -2038,7 +2038,15 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz ...@@ -2038,7 +2038,15 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz
return; return;
gint nMonitor; gint nMonitor;
bool bSameMonitor = false;
GdkScreen *pScreen = getDisplay()->getSystem()->getScreenMonitorFromIdx( nNewScreen, nMonitor ); GdkScreen *pScreen = getDisplay()->getSystem()->getScreenMonitorFromIdx( nNewScreen, nMonitor );
if (!pScreen)
{
g_warning ("Attempt to move GtkSalFrame to invalid screen %d => "
"fallback to current\n", nNewScreen);
pScreen = gtk_widget_get_screen( m_pWindow );
bSameMonitor = true;
}
// Heavy lifting, need to move screen ... // Heavy lifting, need to move screen ...
if( pScreen != gtk_widget_get_screen( m_pWindow )) if( pScreen != gtk_widget_get_screen( m_pWindow ))
...@@ -2046,6 +2054,9 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz ...@@ -2046,6 +2054,9 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz
gint nOldMonitor = gdk_screen_get_monitor_at_window( gint nOldMonitor = gdk_screen_get_monitor_at_window(
pScreen, widget_get_window( m_pWindow ) ); pScreen, widget_get_window( m_pWindow ) );
if (bSameMonitor)
nMonitor = nOldMonitor;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
if( nMonitor == nOldMonitor ) if( nMonitor == nOldMonitor )
g_warning( "An apparently pointless SetScreen - should we elide it ?" ); g_warning( "An apparently pointless SetScreen - should we elide it ?" );
......
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