Repository.mk | 3 include/tools/string.hxx | 9 - scp2/source/ooo/file_library_ooo.scp | 10 + tools/source/string/tustring.cxx | 47 ------- vcl/Module_vcl.mk | 1 vcl/inc/unx/gtk/gtkframe.hxx | 1 vcl/unx/gtk/window/gtksalframe.cxx | 134 +++++++++++++++----- vcl/unx/gtk/window/xid_fullscreen_on_all_monitors.c | 99 ++++++++++++++ 8 files changed, 221 insertions(+), 83 deletions(-)
New commits: commit 14bb85e0a3d95419c484bfa23881f03c54031c5d Author: Caolán McNamara <[email protected]> Date: Thu Oct 17 19:42:35 2013 +0100 Resolves: rhbz#919070 offload set span-all-displays to a gtk3 utility Jaw dropping hack to set a slideshow to span all monitors if gtk3 is available at runtime Change-Id: I363f63c9855d5cb1f92d65d0b34add0c60f7263c diff --git a/Repository.mk b/Repository.mk index 0c60145..4ba21b2 100644 --- a/Repository.mk +++ b/Repository.mk @@ -87,6 +87,9 @@ $(eval $(call gb_Helper_register_executables,OOO, \ $(if $(ENABLE_NPAPI_FROM_BROWSER),pluginapp.bin) \ soffice_bin \ spadmin.bin \ + $(if $(filter $(GUIBASE)$(ENABLE_GTK),unxTRUE), \ + xid-fullscreen-on-all-monitors \ + ) \ $(if $(filter $(GUIBASE)$(ENABLE_TDE),unxTRUE), \ tdefilepicker \ ) \ diff --git a/scp2/source/ooo/file_library_ooo.scp b/scp2/source/ooo/file_library_ooo.scp index 45d2351..3bf6ec9 100644 --- a/scp2/source/ooo/file_library_ooo.scp +++ b/scp2/source/ooo/file_library_ooo.scp @@ -123,6 +123,16 @@ File gid_File_Bin_KdeFilePicker Name = "kdefilepicker"; End #endif + +#ifdef ENABLE_GTK +File gid_File_Bin_XidFullscreen + BIN_FILE_BODY; + Styles = (PACKED); + Dir = gid_Brand_Dir_Program; + Name = "xid-fullscreen-on-all-monitors"; +End +#endif + #endif #ifdef MACOSX diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index d0f8f88..961a958 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -39,6 +39,7 @@ $(eval $(call gb_Module_add_targets,vcl,\ ifneq ($(ENABLE_GTK),) $(eval $(call gb_Module_add_targets,vcl,\ + Executable_xid_fullscreen_on_all_monitors \ Library_vclplug_gtk \ )) endif diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index 16a2cf4..062a198 100644 --- a/vcl/unx/gtk/window/gtksalframe.cxx +++ b/vcl/unx/gtk/window/gtksalframe.cxx @@ -30,6 +30,9 @@ #include <generic/genprn.h> #include <generic/geninst.h> #include <headless/svpgdi.hxx> +#include <osl/file.hxx> +#include <rtl/bootstrap.hxx> +#include <rtl/process.h> #include <vcl/floatwin.hxx> #include <vcl/svapp.hxx> #include <vcl/window.hxx> @@ -90,6 +93,8 @@ #define GSM_DBUS_INTERFACE "org.gnome.SessionManager" #endif +#include <config_folders.h> + // make compile on gtk older than 2.10 #if GTK_MINOR_VERSION < 10 #define GDK_SUPER_MASK (1 << 26) @@ -3528,10 +3533,54 @@ gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer f return sal_False; } +#if !GTK_CHECK_VERSION(3,8,0) +static OString getDisplayString() +{ + int nParams = rtl_getAppCommandArgCount(); + OUString aParam; + for( int i = 0; i < nParams; i++ ) + { + rtl_getAppCommandArg( i, &aParam.pData ); + if( i < nParams-1 && (aParam == "-display" || aParam == "--display" ) ) + { + rtl_getAppCommandArg( i+1, &aParam.pData ); + return OUStringToOString( aParam, osl_getThreadTextEncoding() ); + } + } + return OString(); +} +#endif + gboolean GtkSalFrame::signalMap( GtkWidget *pWidget, GdkEvent*, gpointer frame ) { GtkSalFrame* pThis = (GtkSalFrame*)frame; +#if !GTK_CHECK_VERSION(3,8,0) + //Spawn off a helper program that will attempt to set this fullscreen + //window to span all displays. + if (pThis->m_bFullscreen && pThis->m_bSpanMonitorsWhenFullscreen) + { + GdkWindow* gdkwin = gtk_widget_get_window(pThis->m_pWindow); + if (gdkwin) + { + OUString sProgramURL( "$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER "/xid-fullscreen-on-all-monitors"); + rtl::Bootstrap::expandMacros(sProgramURL); + OUString sProgram; + if (osl::FileBase::getSystemPathFromFileURL(sProgramURL, sProgram) == osl::File::E_None) + { + OString sFinalProgram(OUStringToOString(sProgram, osl_getThreadTextEncoding()) + + " " + OString::number((int)GDK_WINDOW_XID(gdkwin))); + OString sDisplay(getDisplayString()); + if (!sDisplay.isEmpty()) + { + sFinalProgram += "--display " + sDisplay; + } + system(sFinalProgram.getStr()); + } + } + } +#endif + bool bSetFocus = pThis->m_bSetFocusOnMap; pThis->m_bSetFocusOnMap = false; diff --git a/vcl/unx/gtk/window/xid_fullscreen_on_all_monitors.c b/vcl/unx/gtk/window/xid_fullscreen_on_all_monitors.c new file mode 100644 index 0000000..00554b1 --- /dev/null +++ b/vcl/unx/gtk/window/xid_fullscreen_on_all_monitors.c @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <dlfcn.h> +#include <stdlib.h> + +typedef int Window; +typedef union _GdkEvent GdkEvent; +typedef struct _GdkWindow GdkWindow; +typedef struct _GdkDisplay GdkDisplay; +typedef struct _GdkScreen GdkScreen; + +typedef enum +{ + GDK_FULLSCREEN_ON_CURRENT_MONITOR, + GDK_FULLSCREEN_ON_ALL_MONITORS +} GdkFullscreenMode; + +int main(int argc, char *argv[]) +{ + void *handle; + void (*gtk_init)(int*, char***); + GdkWindow* (*gdk_x11_window_foreign_new_for_display)(GdkDisplay*, Window); + GdkDisplay* (*gdk_display_get_default)(void); + GdkEvent* (*gdk_event_get)(void); + void (*gtk_main_do_event)(GdkEvent*); + void (*gdk_event_free)(GdkEvent*); + void (*gdk_window_fullscreen)(GdkWindow *); + void (*gdk_window_set_fullscreen_mode)(GdkWindow *, GdkFullscreenMode); + + GdkEvent *event; + GdkWindow *window; + int windowid; + + handle = dlopen("libgtk-3.so.0", RTLD_LAZY); + if( NULL == handle ) + return -1; + + gtk_init = (void (*) (int*, char***)) + dlsym(handle, "gtk_init"); + gdk_x11_window_foreign_new_for_display = (GdkWindow* (*)(GdkDisplay*, Window)) + dlsym(handle, "gdk_x11_window_foreign_new_for_display"); + gdk_display_get_default = (GdkDisplay* (*)(void)) + dlsym(handle, "gdk_display_get_default"); + gdk_event_get = (GdkEvent* (*)(void)) + dlsym(handle, "gdk_event_get"); + gtk_main_do_event = (void (*)(GdkEvent*)) + dlsym(handle, "gtk_main_do_event"); + gdk_event_free = (void (*)(GdkEvent*)) + dlsym(handle, "gdk_event_free"); + gdk_window_fullscreen = (void (*)(GdkWindow *)) + dlsym(handle, "gdk_window_fullscreen"); + gdk_window_set_fullscreen_mode = (void (*)(GdkWindow *, GdkFullscreenMode)) + dlsym(handle, "gdk_window_set_fullscreen_mode"); + + if (!gtk_init || + !gdk_x11_window_foreign_new_for_display || + !gdk_display_get_default || + !gdk_event_get || + !gtk_main_do_event || + !gdk_event_free || + !gdk_window_fullscreen || + !gdk_window_set_fullscreen_mode) + { + dlclose(handle); + return -1; + } + + gtk_init(&argc, &argv); + + windowid = atoi(argv[1]); + + window = gdk_x11_window_foreign_new_for_display(gdk_display_get_default(), windowid); + if (!window) + { + dlclose(handle); + return -1; + } + + gdk_window_set_fullscreen_mode(window, GDK_FULLSCREEN_ON_ALL_MONITORS); + gdk_window_fullscreen(window); + + while ((event = gdk_event_get()) != NULL) + { + gtk_main_do_event(event); + gdk_event_free(event); + } + + dlclose(handle); + return 0; +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + commit a8dd794356cb62480b2dc12504ad9e0158a0b583 Author: Caolán McNamara <[email protected]> Date: Fri Oct 18 10:04:45 2013 +0100 Related: rhbz#919070 display -1 means span all displays So try to set size to full "screen" size. most window managers will ignore this however unless _NET_WM_FULLSCREEN_MONITORS is set, Under gtk3 we can use gdk_window_set_fullscreen_mode to do that. Its effectively impractical for LibreOffice to itself calculate the right parameters for _NET_WM_FULLSCREEN_MONITORS as far as I can see Change-Id: Ia725f21048bfcec3dbf1478b4303ccd9cfec0b36 diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index c2bb187..4d4eaa6 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -196,6 +196,7 @@ class GtkSalFrame : public SalFrame guint m_nGSMCookie; int m_nWorkArea; bool m_bFullscreen; + bool m_bSpanMonitorsWhenFullscreen; bool m_bDefaultPos; bool m_bDefaultSize; bool m_bSendModChangeOnRelease; diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index ac64628..16a2cf4 100644 --- a/vcl/unx/gtk/window/gtksalframe.cxx +++ b/vcl/unx/gtk/window/gtksalframe.cxx @@ -970,6 +970,7 @@ void GtkSalFrame::InitCommon() m_pCurrentCursor = NULL; m_nKeyModifiers = 0; m_bFullscreen = false; + m_bSpanMonitorsWhenFullscreen = false; m_nState = GDK_WINDOW_STATE_WITHDRAWN; m_nVisibility = GDK_VISIBILITY_FULLY_OBSCURED; m_bSendModChangeOnRelease = false; @@ -2203,43 +2204,68 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz if (maGeometry.nDisplayScreenNumber == nNewScreen && eType == SET_RETAIN_SIZE) return; - gint nMonitor; - bool bSameMonitor = false; - GdkScreen *pScreen = getDisplay()->getSystem()->getScreenMonitorFromIdx( nNewScreen, nMonitor ); - if (!pScreen) + GdkScreen *pScreen; + GdkRectangle aNewMonitor; + + bool bSpanAllScreens = nNewScreen == (unsigned int)-1; + m_bSpanMonitorsWhenFullscreen = bSpanAllScreens && getDisplay()->getSystem()->GetDisplayScreenCount() > 1; + + if (m_bSpanMonitorsWhenFullscreen) //span all screens { - g_warning ("Attempt to move GtkSalFrame to invalid screen %d => " - "fallback to current\n", nNewScreen); pScreen = gtk_widget_get_screen( m_pWindow ); - bSameMonitor = true; + aNewMonitor.x = 0; + aNewMonitor.y = 0; + aNewMonitor.width = gdk_screen_get_width(pScreen); + aNewMonitor.height = gdk_screen_get_height(pScreen); } + else + { + gint nMonitor; + bool bSameMonitor = false; - // Heavy lifting, need to move screen ... - if( pScreen != gtk_widget_get_screen( m_pWindow )) - gtk_window_set_screen( GTK_WINDOW( m_pWindow ), pScreen ); + if (!bSpanAllScreens) + { + pScreen = getDisplay()->getSystem()->getScreenMonitorFromIdx( nNewScreen, nMonitor ); + if (!pScreen) + { + g_warning ("Attempt to move GtkSalFrame to invalid screen %d => " + "fallback to current\n", nNewScreen); + } + } - gint nOldMonitor = gdk_screen_get_monitor_at_window( - pScreen, widget_get_window( m_pWindow ) ); - if (bSameMonitor) - nMonitor = nOldMonitor; + if (!pScreen) + { + pScreen = gtk_widget_get_screen( m_pWindow ); + bSameMonitor = true; + } -#if OSL_DEBUG_LEVEL > 1 - if( nMonitor == nOldMonitor ) - g_warning( "An apparently pointless SetScreen - should we elide it ?" ); -#endif + // Heavy lifting, need to move screen ... + if( pScreen != gtk_widget_get_screen( m_pWindow )) + gtk_window_set_screen( GTK_WINDOW( m_pWindow ), pScreen ); + + 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 ?" ); + #endif - GdkRectangle aOldMonitor, aNewMonitor; - gdk_screen_get_monitor_geometry( pScreen, nOldMonitor, &aOldMonitor ); - gdk_screen_get_monitor_geometry( pScreen, nMonitor, &aNewMonitor ); + GdkRectangle aOldMonitor; + gdk_screen_get_monitor_geometry( pScreen, nOldMonitor, &aOldMonitor ); + gdk_screen_get_monitor_geometry( pScreen, nMonitor, &aNewMonitor ); + + maGeometry.nX = aNewMonitor.x + maGeometry.nX - aOldMonitor.x; + maGeometry.nY = aNewMonitor.y + maGeometry.nY - aOldMonitor.y; + } bool bResize = false; bool bVisible = IS_WIDGET_MAPPED( m_pWindow ); if( bVisible ) Show( sal_False ); - maGeometry.nX = aNewMonitor.x + maGeometry.nX - aOldMonitor.x; - maGeometry.nY = aNewMonitor.y + maGeometry.nY - aOldMonitor.y; - if( eType == SET_FULLSCREEN ) { maGeometry.nX = aNewMonitor.x; @@ -2251,8 +2277,8 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz // #i110881# for the benefit of compiz set a max size here // else setting to fullscreen fails for unknown reasons - m_aMaxSize.Width() = aNewMonitor.width+100; - m_aMaxSize.Height() = aNewMonitor.height+100; + m_aMaxSize.Width() = aNewMonitor.width; + m_aMaxSize.Height() = aNewMonitor.height; } if( pSize && eType == SET_UN_FULLSCREEN ) @@ -2277,14 +2303,19 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz #if !GTK_CHECK_VERSION(3,0,0) // _NET_WM_STATE_FULLSCREEN (Metacity <-> KWin) - if( ! getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) + if( ! getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) #endif { +#if GTK_CHECK_VERSION(3,8,0) + gdk_window_set_fullscreen_mode( gtk_widget_get_window(m_pWindow), m_bSpanMonitorsWhenFullscreen + ? GDK_FULLSCREEN_ON_ALL_MONITORS : GDK_FULLSCREEN_ON_CURRENT_MONITOR ); +#endif if( eType == SET_FULLSCREEN ) gtk_window_fullscreen( GTK_WINDOW( m_pWindow ) ); else if( eType == SET_UN_FULLSCREEN ) gtk_window_unfullscreen( GTK_WINDOW( m_pWindow ) ); } + if( eType == SET_UN_FULLSCREEN && !(m_nStyle & SAL_FRAME_STYLE_SIZEABLE) ) gtk_window_set_resizable( GTK_WINDOW( m_pWindow ), FALSE ); commit 13f383ac919acb36f54c5cf211954a8c032837b4 Author: Caolán McNamara <[email protected]> Date: Thu Oct 17 17:01:22 2013 +0100 Related: fdo#38838 remove String::GetToken Change-Id: Ic5307816dd3f0c74f10eb8a15910a1674713bf9c diff --git a/include/tools/string.hxx b/include/tools/string.hxx index ed3f42e..16f28db 100644 --- a/include/tools/string.hxx +++ b/include/tools/string.hxx @@ -234,9 +234,6 @@ public: xub_StrLen Search( sal_Unicode c, xub_StrLen nIndex = 0 ) const; xub_StrLen Search( const UniString& rStr, xub_StrLen nIndex = 0 ) const; - UniString GetToken( xub_StrLen nToken, sal_Unicode cTok, sal_Int32& rIndex ) const; - UniString GetToken( xub_StrLen nToken, sal_Unicode cTok = ';' ) const; - const sal_Unicode* GetBuffer() const { return mpData->maStr; } friend sal_Bool operator == ( const UniString& rStr1, const UniString& rStr2 ) @@ -258,12 +255,6 @@ inline UniString UniString::Copy( xub_StrLen nIndex, xub_StrLen nCount ) const return UniString( *this, nIndex, nCount ); } -inline UniString UniString::GetToken( xub_StrLen nToken, sal_Unicode cTok ) const -{ - sal_Int32 nTempPos = 0; - return GetToken( nToken, cTok, nTempPos ); -} - template< typename charT, typename traits > std::basic_ostream<charT, traits> & operator <<( std::basic_ostream<charT, traits> & stream, UniString const & string) diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx index e8395b0..40c99cf 100644 --- a/tools/source/string/tustring.cxx +++ b/tools/source/string/tustring.cxx @@ -212,53 +212,6 @@ xub_StrLen STRING::Match( const STRING& rStr ) const return STRING_MATCH; } -STRING STRING::GetToken( xub_StrLen nToken, STRCODE cTok, sal_Int32& rIndex ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - const STRCODE* pStr = mpData->maStr; - xub_StrLen nLen = (xub_StrLen)mpData->mnLen; - xub_StrLen nTok = 0; - sal_Int32 nFirstChar = rIndex; - xub_StrLen i = nFirstChar; - - // Determine token position and length - pStr += i; - while ( i < nLen ) - { - // Increase token count if match - if ( *pStr == cTok ) - { - ++nTok; - - if ( nTok == nToken ) - nFirstChar = i+1; - else - { - if ( nTok > nToken ) - break; - } - } - - ++pStr, - ++i; - } - - if ( nTok >= nToken ) - { - if ( i < nLen ) - rIndex = i+1; - else - rIndex = -1; - return Copy( nFirstChar, i-nFirstChar ); - } - else - { - rIndex = -1; - return STRING(); - } -} - STRING& STRING::Append( STRCODE c ) { DBG_CHKTHIS( STRING, DBGCHECKSTRING );
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
