summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2013-04-30 11:19:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-04-30 11:09:45 +0000
commit791a8f2a4ca97302dd89ebda00f1eea83392a8b1 (patch)
treeb517fd5f0aec31b6546e6b3395ec5f60160beb63
parent800b17fd80433163e323775862a528fbebe60a11 (diff)
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 Signed-off-by: Petr Mladek <pmladek@suse.cz> Reviewed-on: https://gerrit.libreoffice.org/3695 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/unx/gtk/app/gtksys.cxx12
-rw-r--r--vcl/unx/gtk/window/gtkframe.cxx11
2 files changed, 23 insertions, 0 deletions
diff --git a/vcl/unx/gtk/app/gtksys.cxx b/vcl/unx/gtk/app/gtksys.cxx
index bc06b25a1ccc..c822fd260993 100644
--- a/vcl/unx/gtk/app/gtksys.cxx
+++ b/vcl/unx/gtk/app/gtksys.cxx
@@ -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
GtkSalSystem::countScreenMonitors()
{
@@ -134,6 +141,11 @@ GtkSalSystem::getScreenMonitorFromIdx (int nIdx, gint &nMonitor)
break;
}
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;
}
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 03f8c59fcad1..61d3f7852d07 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -2059,7 +2059,15 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz
return;
gint nMonitor;
+ bool bSameMonitor = false;
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 ...
if( pScreen != gtk_widget_get_screen( m_pWindow ))
@@ -2067,6 +2075,9 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz
gint nOldMonitor = gdk_screen_get_monitor_at_window(
pScreen, widget_get_window( m_pWindow ) );
+ if (bSameMonitor)
+ nMonitor = nOldMonitor;
+
#if OSL_DEBUG_LEVEL > 1
if( nMonitor == nOldMonitor )
g_warning( "An apparently pointless SetScreen - should we elide it ?" );