summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-10-17 19:42:35 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-10-18 11:11:50 +0100
commit14bb85e0a3d95419c484bfa23881f03c54031c5d (patch)
tree0c419a8e92524788208500f2199119342f488329
parenta8dd794356cb62480b2dc12504ad9e0158a0b583 (diff)
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
-rw-r--r--Repository.mk3
-rw-r--r--scp2/source/ooo/file_library_ooo.scp10
-rw-r--r--vcl/Module_vcl.mk1
-rw-r--r--vcl/unx/gtk/window/gtksalframe.cxx49
-rw-r--r--vcl/unx/gtk/window/xid_fullscreen_on_all_monitors.c99
5 files changed, 162 insertions, 0 deletions
diff --git a/Repository.mk b/Repository.mk
index 0c60145a31d7..4ba21b25e8cd 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 45d23513bc67..3bf6ec93333b 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 d0f8f88ec495..961a958b6996 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 16a2cf4ceec9..062a19863450 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 000000000000..00554b1df021
--- /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: */
+