Kaydet (Commit) 14bb85e0 authored tarafından Caolán McNamara's avatar Caolán McNamara

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
üst a8dd7943
...@@ -87,6 +87,9 @@ $(eval $(call gb_Helper_register_executables,OOO, \ ...@@ -87,6 +87,9 @@ $(eval $(call gb_Helper_register_executables,OOO, \
$(if $(ENABLE_NPAPI_FROM_BROWSER),pluginapp.bin) \ $(if $(ENABLE_NPAPI_FROM_BROWSER),pluginapp.bin) \
soffice_bin \ soffice_bin \
spadmin.bin \ spadmin.bin \
$(if $(filter $(GUIBASE)$(ENABLE_GTK),unxTRUE), \
xid-fullscreen-on-all-monitors \
) \
$(if $(filter $(GUIBASE)$(ENABLE_TDE),unxTRUE), \ $(if $(filter $(GUIBASE)$(ENABLE_TDE),unxTRUE), \
tdefilepicker \ tdefilepicker \
) \ ) \
......
...@@ -123,6 +123,16 @@ File gid_File_Bin_KdeFilePicker ...@@ -123,6 +123,16 @@ File gid_File_Bin_KdeFilePicker
Name = "kdefilepicker"; Name = "kdefilepicker";
End End
#endif #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 #endif
#ifdef MACOSX #ifdef MACOSX
......
...@@ -39,6 +39,7 @@ $(eval $(call gb_Module_add_targets,vcl,\ ...@@ -39,6 +39,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
ifneq ($(ENABLE_GTK),) ifneq ($(ENABLE_GTK),)
$(eval $(call gb_Module_add_targets,vcl,\ $(eval $(call gb_Module_add_targets,vcl,\
Executable_xid_fullscreen_on_all_monitors \
Library_vclplug_gtk \ Library_vclplug_gtk \
)) ))
endif endif
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#include <generic/genprn.h> #include <generic/genprn.h>
#include <generic/geninst.h> #include <generic/geninst.h>
#include <headless/svpgdi.hxx> #include <headless/svpgdi.hxx>
#include <osl/file.hxx>
#include <rtl/bootstrap.hxx>
#include <rtl/process.h>
#include <vcl/floatwin.hxx> #include <vcl/floatwin.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/window.hxx> #include <vcl/window.hxx>
...@@ -90,6 +93,8 @@ ...@@ -90,6 +93,8 @@
#define GSM_DBUS_INTERFACE "org.gnome.SessionManager" #define GSM_DBUS_INTERFACE "org.gnome.SessionManager"
#endif #endif
#include <config_folders.h>
// make compile on gtk older than 2.10 // make compile on gtk older than 2.10
#if GTK_MINOR_VERSION < 10 #if GTK_MINOR_VERSION < 10
#define GDK_SUPER_MASK (1 << 26) #define GDK_SUPER_MASK (1 << 26)
...@@ -3528,10 +3533,54 @@ gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer f ...@@ -3528,10 +3533,54 @@ gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer f
return sal_False; 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 ) gboolean GtkSalFrame::signalMap( GtkWidget *pWidget, GdkEvent*, gpointer frame )
{ {
GtkSalFrame* pThis = (GtkSalFrame*)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; bool bSetFocus = pThis->m_bSetFocusOnMap;
pThis->m_bSetFocusOnMap = false; pThis->m_bSetFocusOnMap = false;
......
/* -*- 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: */
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