[Libreoffice-commits] .: Branch 'feature/gtk3' - 2 commits - vcl/inc vcl/Library_vclplug_gen.mk vcl/source vcl/unx vcl/win
Michael Meeks
michael at kemper.freedesktop.org
Mon Aug 1 01:22:40 PDT 2011
vcl/Library_vclplug_gen.mk | 4
vcl/inc/svdata.hxx | 2
vcl/inc/unx/gtk/gtkdata.hxx | 18 -
vcl/inc/unx/gtk/gtkframe.hxx | 3
vcl/inc/unx/gtk/gtkgdi.hxx | 4
vcl/inc/unx/gtk/gtkinst.hxx | 32 --
vcl/inc/unx/gtk/gtksys.hxx | 63 +++++
vcl/inc/unx/saldisp.hxx | 1
vcl/inc/unx/salsys.h | 22 -
vcl/inc/unx/x11/x11sys.hxx | 60 ++++
vcl/source/window/dialog.cxx | 10
vcl/unx/generic/app/saldisp.cxx | 21 -
vcl/unx/generic/app/salsys.cxx | 129 ----------
vcl/unx/gtk/app/gtkdata.cxx | 94 -------
vcl/unx/gtk/app/gtksys.cxx | 322 +++++++++++++------------
vcl/unx/gtk/window/gtkframe.cxx | 461 +++++++++++++++----------------------
vcl/unx/x11/x11sys.cxx | 174 +++++++++++++
vcl/win/source/app/salinfo.cxx | 6
vcl/win/source/window/salframe.cxx | 9
19 files changed, 720 insertions(+), 715 deletions(-)
New commits:
commit f3411fbb45051c64c46a134a317e6babd568dcac
Author: Michael Meeks <michael.meeks at novell.com>
Date: Thu Jul 28 14:18:26 2011 +0100
re-write gtksys to use the cleaner GdkScreen API avoiding X & Xinerama
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index 8f5a2eb..7f9c1e6 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -114,8 +114,12 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
vcl/unx/generic/window/FWS \
vcl/unx/generic/window/salframe \
vcl/unx/generic/window/salobj \
+ vcl/unx/x11/x11sys \
))
+# ultimately we want to split the x11 dependencies out
+# into their own library I think.
+
$(eval $(call gb_Library_add_defs,vclplug_gen,\
-D_XSALSET_LIBNAME=\"$(call gb_Library_get_runtime_filename,spa)\" \
-DVCLPLUG_GEN_IMPLEMENTATION \
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 0e3ea5b..3aced67 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -182,7 +182,6 @@ struct ImplSVAppData
ImeStatusWindowMode meShowImeStatusWindow;
DECL_STATIC_LINK( ImplSVAppData, ImplQuitMsg, void* );
-
};
@@ -395,6 +394,7 @@ long ImplCallEvent( NotifyEvent& rEvt );
extern VCL_PLUGIN_PUBLIC ImplSVData* pImplSVData;
inline VCL_PLUGIN_PUBLIC ImplSVData* ImplGetSVData() { return pImplSVData; }
inline ImplSVData* ImplGetAppSVData() { return ImplGetSVData(); }
+VCL_PLUGIN_PUBLIC void ImplHideSplash();
bool ImplInitAccessBridge( sal_Bool bAllowCancel, sal_Bool &rCancelled );
diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index eb062ba..2b7949e 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -37,6 +37,7 @@
#include <unx/saldisp.hxx>
#include <unx/saldata.hxx>
+#include <unx/gtk/gtksys.hxx>
#include <vcl/ptrstyle.hxx>
#include <osl/conditn.h>
@@ -143,6 +144,7 @@ class GtkSalDisplay
class GtkSalDisplay : public SalDisplay
#endif
{
+ GtkSalSystem* m_pSys;
GdkDisplay* m_pGdkDisplay;
GdkCursor *m_aCursors[ POINTER_COUNT ];
bool m_bStartupCompleted;
@@ -159,9 +161,12 @@ public:
virtual void deregisterFrame( SalFrame* pFrame );
GdkCursor *getCursor( PointerStyle ePointerStyle );
virtual int CaptureMouse( SalFrame* pFrame );
- virtual void initScreen( int nScreen ) const;
- virtual int GetDefaultMonitorNumber() const;
+ bool IsXinerama() { return !m_pSys->IsMultiDisplay(); }
+ int GetDefaultScreenNumber() { return m_pSys->GetDefaultDisplayNumber(); }
+ int GetScreenCount() { return m_pSys->GetDisplayScreenCount(); }
+ Size GetScreenSize( int screen );
+ virtual void initScreen( int nScreen ) const;
GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event,
GdkEvent* event );
@@ -180,14 +185,9 @@ public:
#if !GTK_CHECK_VERSION(3,0,0)
virtual long Dispatch( XEvent *pEvent );
#else
- bool IsXinerama() { return false; }
- int GetDefaultScreenNumber() const { return 0; }
- int GetScreenCount() const { return 1; }
- std::vector<Rectangle> GetXineramaScreens() { return std::vector<Rectangle>(); }
- Size GetScreenSize( int screen );
void SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT );
- void CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent );
- bool DispatchInternalEvent();
+ void CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent );
+ bool DispatchInternalEvent();
SalFrame *m_pCapture;
sal_Bool MouseCaptured( const SalFrame *pFrameData ) const
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 7c47020..f5f3654 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -298,6 +298,7 @@ class GtkSalFrame : public SalFrame, basebmp::BitmapDeviceDamageTracker
void AllocateFrame();
void updateWMClass();
+ void SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSize = NULL );
DECL_LINK( ImplDelayedFullScreenHdl, void* );
public:
@@ -329,8 +330,6 @@ public:
void popIgnoreDamage();
void renderArea( cairo_t *cr, cairo_rectangle_t *src );
- void moveToScreen( int nScreen );
-
virtual ~GtkSalFrame();
// SalGraphics or NULL, but two Graphics for all SalFrames
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index be7c46c..8e76d52 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -45,7 +45,8 @@
#define GTK_GRAPHICS_DISABLED
class GtkSalFrame;
-class GtkSalGraphics : public SvpSalGraphics {
+class GtkSalGraphics : public SvpSalGraphics
+{
GtkSalFrame *mpFrame;
public:
GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
@@ -53,6 +54,7 @@ public:
long nSrcX, long nSrcY,
long nSrcWidth, long nSrcHeight,
sal_uInt16 /*nFlags*/ );
+ void updateSettings( AllSettings& rSettings );
};
#else
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 1175cd3..13a0d91 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -115,38 +115,6 @@ public:
virtual bool AnyInput( sal_uInt16 nType );
};
-#if GTK_CHECK_VERSION(3,0,0)
-class GtkSalSystem : public SalSystem
-{
-public:
- GtkSalSystem() : SalSystem() {}
-#else
-class GtkSalSystem : public X11SalSystem
-{
-public:
- GtkSalSystem() : X11SalSystem() {}
-#endif
- virtual ~GtkSalSystem();
-
-#if GTK_CHECK_VERSION(3,0,0)
- virtual unsigned int GetDisplayScreenCount();
- virtual bool IsMultiDisplay();
- virtual unsigned int GetDefaultDisplayNumber();
- virtual Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen );
- virtual Rectangle GetDisplayWorkAreaPosSizePixel( unsigned int nScreen );
- virtual rtl::OUString GetScreenName( unsigned int nScreen );
- virtual int ShowNativeMessageBox( const String& rTitle,
- const String& rMessage,
- int nButtonCombination,
- int nDefaultButton);
-#endif
-
- virtual int ShowNativeDialog( const String& rTitle,
- const String& rMessage,
- const std::list< String >& rButtons,
- int nDefButton );
-};
-
#endif // _VCL_GTKINST_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/unx/gtk/gtksys.hxx b/vcl/inc/unx/gtk/gtksys.hxx
new file mode 100644
index 0000000..05e58f5
--- /dev/null
+++ b/vcl/inc/unx/gtk/gtksys.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Michael Meeks <michael.meeks at novell.com>
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Major Contributor(s):
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef _VCL_GTKSYS_HXX_
+#define _VCL_GTKSYS_HXX_
+
+#include "unx/salsys.h"
+#include <gtk/gtk.h>
+
+class GtkSalSystem : public UnxSalSystem
+{
+ GdkDisplay *mpDisplay;
+public:
+ GtkSalSystem();
+ virtual ~GtkSalSystem();
+ static GtkSalSystem *GetSingleton();
+
+ virtual bool IsMultiDisplay();
+ virtual unsigned int GetDisplayScreenCount();
+ virtual unsigned int GetDefaultDisplayNumber();
+ virtual rtl::OUString GetScreenName (unsigned int nScreen);
+ virtual Rectangle GetDisplayScreenPosSizePixel (unsigned int nScreen);
+ virtual Rectangle GetDisplayWorkAreaPosSizePixel (unsigned int nScreen);
+ virtual int ShowNativeDialog (const String& rTitle,
+ const String& rMessage,
+ const std::list< String >& rButtons,
+ int nDefButton);
+
+ // We have a 'screen' number that is combined from screen-idx + monitor-idx
+ static int getScreenIdxFromPtr (GdkDisplay *pDisplay, GdkScreen *pScreen);
+ static int getScreenMonitorIdx (GdkDisplay *pDisplay, GdkScreen *pScreen, int nX, int nY);
+ static GdkScreen *getScreenMonitorFromIdx (GdkDisplay *pDisplay, int nIdx, gint &nMonitor);
+};
+
+#endif // _VCL_GTKSYS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx
index b209cde..d60f1d3 100644
--- a/vcl/inc/unx/saldisp.hxx
+++ b/vcl/inc/unx/saldisp.hxx
@@ -448,7 +448,6 @@ public:
XLIB_Window GetDrawable( int nScreen ) const { return getDataForScreen( nScreen ).m_aRefWindow; }
Display *GetDisplay() const { return pDisp_; }
int GetDefaultScreenNumber() const { return m_nDefaultScreen; }
- virtual int GetDefaultMonitorNumber() const { return 0; }
const Size& GetScreenSize( int nScreen ) const { return getDataForScreen( nScreen ).m_aSize; }
srv_vendor_t GetServerVendor() const { return meServerVendor; }
void SetServerVendor() { meServerVendor = sal_GetServerVendor(pDisp_); }
diff --git a/vcl/inc/unx/salsys.h b/vcl/inc/unx/salsys.h
index e4ce898..cd87738 100644
--- a/vcl/inc/unx/salsys.h
+++ b/vcl/inc/unx/salsys.h
@@ -30,31 +30,19 @@
#ifndef _SV_SALSYS_H
#define _SV_SALSYS_H
-#include <vcl/sv.h>
-#include <osl/mutex.hxx>
-#include <osl/thread.hxx>
#include <salsys.hxx>
#include <vclpluginapi.h>
-
#include <list>
-class VCLPLUG_GEN_PUBLIC X11SalSystem : public SalSystem
+class VCLPLUG_GEN_PUBLIC UnxSalSystem : public SalSystem
{
-public:
- X11SalSystem() {}
- virtual ~X11SalSystem();
-
- // overload pure virtual methods
- virtual unsigned int GetDisplayScreenCount();
- virtual bool IsMultiDisplay();
- virtual unsigned int GetDefaultDisplayNumber();
- virtual Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen );
- virtual Rectangle GetDisplayWorkAreaPosSizePixel( unsigned int nScreen );
- virtual rtl::OUString GetScreenName( unsigned int nScreen );
+ public:
+ UnxSalSystem();
+ virtual ~UnxSalSystem();
virtual int ShowNativeDialog( const String& rTitle,
const String& rMessage,
const std::list< String >& rButtons,
- int nDefButton );
+ int nDefButton ) = 0;
virtual int ShowNativeMessageBox( const String& rTitle,
const String& rMessage,
int nButtonCombination,
diff --git a/vcl/inc/unx/x11/x11sys.hxx b/vcl/inc/unx/x11/x11sys.hxx
new file mode 100644
index 0000000..a438534
--- /dev/null
+++ b/vcl/inc/unx/x11/x11sys.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// -=-= includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#ifndef _SV_X11SYS_H
+#define _SV_X11SYS_H
+
+#include <vcl/sv.h>
+#include <osl/mutex.hxx>
+#include <osl/thread.hxx>
+#include <unx/salsys.h>
+#include <vclpluginapi.h>
+
+class VCLPLUG_GEN_PUBLIC X11SalSystem : public UnxSalSystem
+{
+public:
+ X11SalSystem() {}
+ virtual ~X11SalSystem();
+
+ // overload pure virtual methods
+ virtual unsigned int GetDisplayScreenCount();
+ virtual bool IsMultiDisplay();
+ virtual unsigned int GetDefaultDisplayNumber();
+ virtual Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen );
+ virtual Rectangle GetDisplayWorkAreaPosSizePixel( unsigned int nScreen );
+ virtual rtl::OUString GetScreenName( unsigned int nScreen );
+ virtual int ShowNativeDialog( const String& rTitle,
+ const String& rMessage,
+ const std::list< String >& rButtons,
+ int nDefButton );
+};
+
+#endif // _SV_X11SYS_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 5c4c786..e89fb85 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -110,6 +110,16 @@ static sal_Bool ImplIsMnemonicCtrl( Window* pWindow )
// -----------------------------------------------------------------------
+// Called by native error dialog popup implementations
+void ImplHideSplash()
+{
+ ImplSVData* pSVData = ImplGetSVData();
+ if( pSVData->mpIntroWindow )
+ pSVData->mpIntroWindow->Hide();
+}
+
+// -----------------------------------------------------------------------
+
void ImplWindowAutoMnemonic( Window* pWindow )
{
MnemonicGenerator aMnemonicGenerator;
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index ff0f606..e4a8a86 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -576,12 +576,9 @@ void SalDisplay::doDestruct()
pSalData->SetSalDisplay( NULL );
}
-static int DisplayHasEvent( int
-#ifdef DBG_UTIL
-fd
-#endif
-, SalX11Display *pDisplay )
+static int DisplayHasEvent( int fd, SalX11Display *pDisplay )
{
+ (void)fd;
DBG_ASSERT( ConnectionNumber( pDisplay->GetDisplay() ) == fd,
"wrong fd in DisplayHasEvent" );
if( ! pDisplay->IsDisplay() )
@@ -594,12 +591,9 @@ fd
GetSalData()->m_pInstance->GetYieldMutex()->release();
return result;
}
-static int DisplayQueue( int
-#ifdef DBG_UTIL
-fd
-#endif
-, SalX11Display *pDisplay )
+static int DisplayQueue( int fd, SalX11Display *pDisplay )
{
+ (void)fd;
DBG_ASSERT( ConnectionNumber( pDisplay->GetDisplay() ) == fd,
"wrong fd in DisplayHasEvent" );
int result;
@@ -611,12 +605,9 @@ fd
return result;
}
-static int DisplayYield( int
-#ifdef DBG_UTIL
-fd
-#endif
-, SalX11Display *pDisplay )
+static int DisplayYield( int fd, SalX11Display *pDisplay )
{
+ (void)fd;
DBG_ASSERT( ConnectionNumber( pDisplay->GetDisplay() ) == fd,
"wrong fd in DisplayHasEvent" );
diff --git a/vcl/unx/generic/app/salsys.cxx b/vcl/unx/generic/app/salsys.cxx
index ab69cda..9f68512 100644
--- a/vcl/unx/generic/app/salsys.cxx
+++ b/vcl/unx/generic/app/salsys.cxx
@@ -43,139 +43,23 @@
#include <rtl/ustrbuf.hxx>
#include <osl/thread.h>
-
-SalSystem* X11SalInstance::CreateSalSystem()
-{
- return new X11SalSystem();
-}
-
-// -----------------------------------------------------------------------
-
-X11SalSystem::~X11SalSystem()
-{
-}
-
-// for the moment only handle xinerama case
-unsigned int X11SalSystem::GetDisplayScreenCount()
-{
- SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
- return pSalDisp->IsXinerama() ? pSalDisp->GetXineramaScreens().size() : pSalDisp->GetScreenCount();
-}
-
-bool X11SalSystem::IsMultiDisplay()
-{
- SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
- unsigned int nScreenCount = pSalDisp->GetScreenCount();
- return pSalDisp->IsXinerama() ? false : (nScreenCount > 1);
-}
-
-unsigned int X11SalSystem::GetDefaultDisplayNumber()
-{
- SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
- return pSalDisp->IsXinerama() ? pSalDisp->GetDefaultMonitorNumber() : pSalDisp->GetDefaultScreenNumber();
-}
-
-Rectangle X11SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )
-{
- Rectangle aRet;
- SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
- if( pSalDisp->IsXinerama() )
- {
- const std::vector< Rectangle >& rScreens = pSalDisp->GetXineramaScreens();
- if( nScreen < rScreens.size() )
- aRet = rScreens[nScreen];
- }
- else
- {
- const SalDisplay::ScreenData& rScreen = pSalDisp->getDataForScreen( nScreen );
- aRet = Rectangle( Point( 0, 0 ), rScreen.m_aSize );
- }
-
- return aRet;
-}
-
-Rectangle X11SalSystem::GetDisplayWorkAreaPosSizePixel( unsigned int nScreen )
+UnxSalSystem::UnxSalSystem()
{
- // FIXME: workareas
- return GetDisplayScreenPosSizePixel( nScreen );
}
-rtl::OUString X11SalSystem::GetScreenName( unsigned int nScreen )
+UnxSalSystem::~UnxSalSystem()
{
- rtl::OUString aScreenName;
- SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
- if( pSalDisp->IsXinerama() )
- {
- const std::vector< Rectangle >& rScreens = pSalDisp->GetXineramaScreens();
- if( nScreen >= rScreens.size() )
- nScreen = 0;
- rtl::OUStringBuffer aBuf( 256 );
- aBuf.append( rtl::OStringToOUString( rtl::OString( DisplayString( pSalDisp->GetDisplay() ) ), osl_getThreadTextEncoding() ) );
- aBuf.appendAscii( " [" );
- aBuf.append( static_cast<sal_Int32>(nScreen) );
- aBuf.append( sal_Unicode(']') );
- aScreenName = aBuf.makeStringAndClear();
- }
- else
- {
- if( nScreen >= static_cast<unsigned int>(pSalDisp->GetScreenCount()) )
- nScreen = 0;
- rtl::OUStringBuffer aBuf( 256 );
- aBuf.append( rtl::OStringToOUString( rtl::OString( DisplayString( pSalDisp->GetDisplay() ) ), osl_getThreadTextEncoding() ) );
- // search backwards for ':'
- int nPos = aBuf.getLength();
- if( nPos > 0 )
- nPos--;
- while( nPos > 0 && aBuf.charAt( nPos ) != ':' )
- nPos--;
- // search forward to '.'
- while( nPos < aBuf.getLength() && aBuf.charAt( nPos ) != '.' )
- nPos++;
- if( nPos < aBuf.getLength() )
- aBuf.setLength( nPos+1 );
- else
- aBuf.append( sal_Unicode('.') );
- aBuf.append( static_cast<sal_Int32>(nScreen) );
- aScreenName = aBuf.makeStringAndClear();
- }
- return aScreenName;
}
-int X11SalSystem::ShowNativeDialog( const String& rTitle, const String& rMessage, const std::list< String >& rButtons, int nDefButton )
-{
- int nRet = -1;
-
- ImplSVData* pSVData = ImplGetSVData();
- if( pSVData->mpIntroWindow )
- pSVData->mpIntroWindow->Hide();
-
- WarningBox aWarn( NULL, WB_STDWORK, rMessage );
- aWarn.SetText( rTitle );
- aWarn.Clear();
-
- sal_uInt16 nButton = 0;
- for( std::list< String >::const_iterator it = rButtons.begin(); it != rButtons.end(); ++it )
- {
- aWarn.AddButton( *it, nButton+1, nButton == (sal_uInt16)nDefButton ? BUTTONDIALOG_DEFBUTTON : 0 );
- nButton++;
- }
- aWarn.SetFocusButton( (sal_uInt16)nDefButton+1 );
-
- nRet = ((int)aWarn.Execute()) - 1;
-
- // normalize behaviour, actually this should never happen
- if( nRet < -1 || nRet >= int(rButtons.size()) )
- nRet = -1;
-
- return nRet;
-}
-
-int X11SalSystem::ShowNativeMessageBox(const String& rTitle, const String& rMessage, int nButtonCombination, int nDefaultButton)
+int UnxSalSystem::ShowNativeMessageBox(const String& rTitle, const String& rMessage,
+ int nButtonCombination, int nDefaultButton)
{
int nDefButton = 0;
std::list< String > aButtons;
int nButtonIds[5], nBut = 0;
+ ImplHideSplash();
+
if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK ||
nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL )
{
@@ -220,6 +104,7 @@ int X11SalSystem::ShowNativeMessageBox(const String& rTitle, const String& rMess
case SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE: nDefButton = 2;break;
}
}
+
int nResult = ShowNativeDialog( rTitle, rMessage, aButtons, nDefButton );
return nResult != -1 ? nButtonIds[ nResult ] : 0;
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index a0e0055..a3afad2 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -84,6 +84,7 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
#if !GTK_CHECK_VERSION(3,0,0)
SalDisplay( gdk_x11_display_get_xdisplay( pDisplay ) ),
#endif
+ m_pSys( GtkSalSystem::GetSingleton() ),
m_pGdkDisplay( pDisplay ),
m_bStartupCompleted( false )
{
@@ -243,57 +244,20 @@ GdkFilterReturn GtkSalDisplay::filterGdkEvent( GdkXEvent* sys_event,
void GtkSalDisplay::screenSizeChanged( GdkScreen* pScreen )
{
#if !GTK_CHECK_VERSION(3,0,0)
- if( pScreen )
- {
- int nScreen = gdk_screen_get_number( pScreen );
- if( nScreen < static_cast<int>(m_aScreens.size()) )
- {
- ScreenData& rSD = const_cast<ScreenData&>(m_aScreens[nScreen]);
- if( rSD.m_bInit )
- {
- rSD.m_aSize = Size( gdk_screen_get_width( pScreen ),
- gdk_screen_get_height( pScreen ) );
- if( ! m_aFrames.empty() )
- m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
- }
- }
- else
- {
- OSL_FAIL( "unknown screen changed size" );
- }
- }
+ if (pScreen)
+ m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
+#else
+#warning get this right
#endif
}
void GtkSalDisplay::monitorsChanged( GdkScreen* pScreen )
{
#if !GTK_CHECK_VERSION(3,0,0)
- if( pScreen )
- {
- if( gdk_display_get_n_screens(m_pGdkDisplay) == 1 )
- {
- int nScreen = gdk_screen_get_number( pScreen );
- if( nScreen == m_nDefaultScreen ) //To-Do, make m_aXineramaScreens a per-screen thing ?
- {
- gint nMonitors = gdk_screen_get_n_monitors(pScreen);
- m_aXineramaScreens = std::vector<Rectangle>();
- m_aXineramaScreenIndexMap = std::vector<int>(nMonitors);
- for (gint i = 0; i < nMonitors; ++i)
- {
- GdkRectangle dest;
- gdk_screen_get_monitor_geometry(pScreen, i, &dest);
- addXineramaScreenUnique( i, dest.x, dest.y, dest.width, dest.height );
- }
- m_bXinerama = m_aXineramaScreens.size() > 1;
- if( ! m_aFrames.empty() )
- m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
- }
- else
- {
- OSL_FAIL( "monitors for non-default screen changed, extend-me" );
- }
- }
- }
+ if (pScreen)
+ m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
+#else
+#warning get this right
#endif
}
@@ -302,36 +266,6 @@ extern "C"
typedef gint(* screen_get_primary_monitor)(GdkScreen *screen);
}
-int GtkSalDisplay::GetDefaultMonitorNumber() const
-{
- int n = 0;
-#if !GTK_CHECK_VERSION(3,0,0)
- GdkScreen* pScreen = gdk_display_get_screen( m_pGdkDisplay, m_nDefaultScreen );
-#if GTK_CHECK_VERSION(2,20,0)
- n = gdk_screen_get_primary_monitor(pScreen);
-#else
- static screen_get_primary_monitor sym_gdk_screen_get_primary_monitor =
- (screen_get_primary_monitor)osl_getAsciiFunctionSymbol( GetSalData()->m_pPlugin, "gdk_screen_get_primary_monitor" );
- if (sym_gdk_screen_get_primary_monitor)
- n = sym_gdk_screen_get_primary_monitor( pScreen );
-#if GTK_CHECK_VERSION(2,14,0)
- //gdk_screen_get_primary_monitor unavailable, take the first laptop monitor
- //as the default
- gint nMonitors = gdk_screen_get_n_monitors(pScreen);
- for (gint i = 0; i < nMonitors; ++i)
- {
- if (g_ascii_strncasecmp (gdk_screen_get_monitor_plug_name(pScreen, i), "LVDS", 4) == 0)
- return m_aXineramaScreenIndexMap[i];
- }
-#endif
- return 0;
-#endif
- if( n >= 0 && size_t(n) < m_aXineramaScreenIndexMap.size() )
- n = m_aXineramaScreenIndexMap[n];
-#endif
- return n;
-}
-
void GtkSalDisplay::initScreen( int nScreen ) const
{
#if GTK_CHECK_VERSION(3,0,0)
@@ -994,16 +928,6 @@ void GtkSalDisplay::CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt
}
}
-Size GtkSalDisplay::GetScreenSize( int nScreen )
-{
- GdkScreen *pScreen = gdk_display_get_screen (m_pGdkDisplay, nScreen);
- if (!pScreen)
- return Size();
- else
- return Size( gdk_screen_get_width (pScreen),
- gdk_screen_get_height (pScreen) );
-}
-
#endif
// hEventGuard_ held during this invocation
diff --git a/vcl/unx/gtk/app/gtksys.cxx b/vcl/unx/gtk/app/gtksys.cxx
index 67029d3..ae64f0e 100644
--- a/vcl/unx/gtk/app/gtksys.cxx
+++ b/vcl/unx/gtk/app/gtksys.cxx
@@ -1,153 +1,190 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
*
- * OpenOffice.org - a multi-platform office productivity suite
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
*
- * This file is part of OpenOffice.org.
+ * The Initial Developer of the Original Code is
+ * Michael Meeks <michael.meeks at novell.com>
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
*
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
+ * Major Contributor(s):
*
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
+ * For minor contributions see the git repository.
*
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-
-#ifdef AIX
-#define _LINUX_SOURCE_COMPAT
-#include <sys/timer.h>
-#undef _LINUX_SOURCE_COMPAT
-#endif
-
-#include <unx/svunx.h>
-#include <svdata.hxx>
-
-#include <vcl/window.hxx>
-#include <unx/gtk/gtkinst.hxx>
-#include <cstdio>
-#include <gdk/gdk.h>
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#include <string.h>
#include <gtk/gtk.h>
-#include <X11/Xlib.h>
+#include <unx/gtk/gtkinst.hxx>
+#include <unx/gtk/gtksys.hxx>
+
+GtkSalSystem *GtkSalSystem::GetSingleton()
+{
+ static GtkSalSystem *pSingleton = NULL;
+ if (!pSingleton)
+ pSingleton = new GtkSalSystem();
+ return pSingleton;
+}
SalSystem *GtkInstance::CreateSalSystem()
{
- return new GtkSalSystem();
+ return GtkSalSystem::GetSingleton();
}
-GtkSalSystem::~GtkSalSystem()
+GtkSalSystem::GtkSalSystem() : UnxSalSystem()
{
+ mpDisplay = gdk_display_get_default();
}
-#if GTK_CHECK_VERSION(3,0,0)
-unsigned int GtkSalSystem::GetDisplayScreenCount()
+GtkSalSystem::~GtkSalSystem()
{
- return 1;
}
-bool GtkSalSystem::IsMultiDisplay()
+GdkScreen *
+GtkSalSystem::getScreenMonitorFromIdx (GdkDisplay *pDisplay, int nIdx, gint &nMonitor)
{
- return false;
+ GdkScreen *pScreen = NULL;
+ for (gint i = 0; i < gdk_display_get_n_screens (pDisplay); i++)
+ {
+ pScreen = gdk_display_get_screen (pDisplay, i++);
+ if (!pScreen)
+ break;
+ if (nIdx > gdk_screen_get_n_monitors (pScreen))
+ nIdx -= gdk_screen_get_n_monitors (pScreen);
+ else
+ break;
+ }
+ nMonitor = nIdx;
+ return pScreen;
}
-unsigned int GtkSalSystem::GetDefaultDisplayNumber()
+int
+GtkSalSystem::getScreenIdxFromPtr (GdkDisplay *pDisplay, GdkScreen *pScreen)
{
+ int nIdx = 0;
+ for (gint i = 0; i < gdk_display_get_n_screens (pDisplay); i++)
+ {
+ GdkScreen *pCmp = gdk_display_get_screen (pDisplay, i);
+ if (pCmp == pScreen)
+ return nIdx;
+ nIdx += gdk_screen_get_n_monitors (pCmp);
+ }
+ g_warning ("failed to find screen %p", pScreen);
return 0;
}
-Rectangle GtkSalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )
+int GtkSalSystem::getScreenMonitorIdx (GdkDisplay *pDisplay,
+ GdkScreen *pScreen,
+ int nX, int nY)
{
- g_warning ("FIXME: GetDisplayScreenPosSizePixel unimplemented");
- return Rectangle (0, 0, 1024, 768);
+ return getScreenIdxFromPtr (pDisplay, pScreen) +
+ gdk_screen_get_monitor_at_point (pScreen, nX, nY);
}
-Rectangle GtkSalSystem::GetDisplayWorkAreaPosSizePixel( unsigned int nScreen )
+unsigned int GtkSalSystem::GetDisplayScreenCount()
{
- return GetDisplayScreenPosSizePixel( nScreen );
+ gint nMonitor;
+ (void)getScreenMonitorFromIdx (mpDisplay, G_MAXINT, nMonitor);
+ return G_MAXINT - nMonitor;
}
-rtl::OUString GtkSalSystem::GetScreenName( unsigned int nScreen )
+bool GtkSalSystem::IsMultiDisplay()
{
- return rtl::OUString::createFromAscii( "Jim" );
+ return gdk_display_get_n_screens (mpDisplay) > 1;
}
-// FIXME: shocking cut/paste from X11SalSystem ... [!] - push me lower ...
-#include <vcl/msgbox.hxx>
-#include <vcl/button.hxx>
-
-int GtkSalSystem::ShowNativeMessageBox( const String& rTitle,
- const String& rMessage,
- int nButtonCombination,
- int nDefaultButton)
+namespace {
+int _fallback_get_primary_monitor (GdkScreen *pScreen)
{
- int nDefButton = 0;
- std::list< String > aButtons;
- int nButtonIds[5], nBut = 0;
-
- if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK ||
- nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL )
- {
- aButtons.push_back( Button::GetStandardText( BUTTON_OK ) );
- nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK;
- }
- if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL ||
- nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO )
- {
- aButtons.push_back( Button::GetStandardText( BUTTON_YES ) );
- nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_YES;
- aButtons.push_back( Button::GetStandardText( BUTTON_NO ) );
- nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO;
- if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO )
- nDefButton = 1;
- }
- if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL ||
- nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL ||
- nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL )
+ // Use monitor name as primacy heuristic
+ int ret = -1;
+ int max = gdk_screen_get_n_monitors (pScreen);
+ for (int i = 0; i < max && ret < 0; i++)
{
- if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL )
- {
- aButtons.push_back( Button::GetStandardText( BUTTON_RETRY ) );
- nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
- }
- aButtons.push_back( Button::GetStandardText( BUTTON_CANCEL ) );
- nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL;
- if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL )
- nDefButton = aButtons.size()-1;
+ char *name = gdk_screen_get_monitor_plug_name (pScreen, i);
+ if (!g_ascii_strncasecmp (name, "LVDS", 4))
+ ret = i;
+ g_free (name);
}
- if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_ABORT_RETRY_IGNORE )
+ return 0;
+}
+
+int _get_primary_monitor (GdkScreen *pScreen)
+{
+ static int (*get_fn) (GdkScreen *) = NULL;
+#if GTK_CHECK_VERSION(3,0,0)
+ get_fn = gdk_screen_get_primary_monitor;
+#endif
+ // Perhaps we have a newer gtk+ with this symbol:
+ if (!get_fn)
{
- aButtons.push_back( Button::GetStandardText( BUTTON_ABORT ) );
- nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_ABORT;
- aButtons.push_back( Button::GetStandardText( BUTTON_RETRY ) );
- nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
- aButtons.push_back( Button::GetStandardText( BUTTON_IGNORE ) );
- nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE;
- switch( nDefaultButton )
- {
- case SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY: nDefButton = 1;break;
- case SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE: nDefButton = 2;break;
- }
+ GModule *module = g_module_open (NULL, (GModuleFlags) 0);
+ if (!g_module_symbol (module, "gdk_screen_get_primary_monitor",
+ (gpointer *)&get_fn))
+ get_fn = NULL;
+ g_module_close (module);
}
- int nResult = ShowNativeDialog( rTitle, rMessage, aButtons, nDefButton );
+ if (!get_fn)
+ get_fn = _fallback_get_primary_monitor;
- return nResult != -1 ? nButtonIds[ nResult ] : 0;
+ return get_fn (pScreen);
+}
+} // end anonymous namespace
+
+unsigned int GtkSalSystem::GetDefaultDisplayNumber()
+{
+ GdkScreen *pDefault = gdk_display_get_default_screen (mpDisplay);
+ int idx = getScreenIdxFromPtr (mpDisplay, pDefault);
+ return idx + _get_primary_monitor (pDefault);
+}
+
+Rectangle GtkSalSystem::GetDisplayScreenPosSizePixel (unsigned int nScreen)
+{
+ gint nMonitor;
+ GdkScreen *pScreen;
+ GdkRectangle aRect;
+ pScreen = getScreenMonitorFromIdx (mpDisplay, nScreen, nMonitor);
+ if (!pScreen)
+ return Rectangle();
+ gdk_screen_get_monitor_geometry (pScreen, nMonitor, &aRect);
+ return Rectangle (aRect.x, aRect.y, aRect.width, aRect.height);
+}
+
+Rectangle GtkSalSystem::GetDisplayWorkAreaPosSizePixel (unsigned int nScreen)
+{
+ // FIXME: in theory we need extra code here to collect
+ // the work area, ignoring fixed panels etc. on the screen.
+ // surely gtk+ should have API to get this for us (?)
+ return GetDisplayScreenPosSizePixel( nScreen );
+}
+
+rtl::OUString GtkSalSystem::GetScreenName(unsigned int nScreen)
+{
+ gchar *pStr;
+ gint nMonitor;
+ GdkScreen *pScreen;
+ pScreen = getScreenMonitorFromIdx (mpDisplay, nScreen, nMonitor);
+ if (!pScreen)
+ return rtl::OUString();
+ pStr = gdk_screen_get_monitor_plug_name (pScreen, nMonitor);
+ rtl::OUString aRet (pStr, strlen (pStr), RTL_TEXTENCODING_UTF8);
+ g_free (pStr);
+ return aRet;
}
-#endif
// convert ~ to indicate mnemonic to '_'
static rtl::OString MapToGtkAccelerator(const String &rStr)
@@ -157,59 +194,32 @@ static rtl::OString MapToGtkAccelerator(const String &rStr)
return rtl::OUStringToOString(aRet, RTL_TEXTENCODING_UTF8);
}
-int GtkSalSystem::ShowNativeDialog( const String& rTitle,
- const String& rMessage,
- const std::list< String >& rButtons,
- int nDefButton )
+int GtkSalSystem::ShowNativeDialog (const String& rTitle, const String& rMessage,
+ const std::list< String >& rButtonNames,
+ int nDefaultButton)
{
-
- ImplSVData* pSVData = ImplGetSVData();
- if( pSVData->mpIntroWindow )
- pSVData->mpIntroWindow->Hide();
-
-#if OSL_DEBUG_LEVEL > 1
- std::fprintf( stderr, "GtkSalSystem::ShowNativeDialog\n");
-#endif
-
- rtl::OString aTitle(rtl::OUStringToOString(rTitle,
- RTL_TEXTENCODING_UTF8));
- rtl::OString aMessage(rtl::OUStringToOString(rMessage,
- RTL_TEXTENCODING_UTF8));
-
- /* Create the dialogue */
- GtkWidget* mainwin = gtk_message_dialog_new
- ( NULL, (GtkDialogFlags)0, GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE, aMessage.getStr(), NULL );
- gtk_window_set_title( GTK_WINDOW( mainwin ), aTitle.getStr() );
-
- gint nButtons = 0, nResponse;
-
+ rtl::OString aTitle (rtl::OUStringToOString (rTitle, RTL_TEXTENCODING_UTF8));
+ rtl::OString aMessage (rtl::OUStringToOString (rMessage, RTL_TEXTENCODING_UTF8));
+
+ GtkDialog *pDialog = GTK_DIALOG (
+ g_object_new (GTK_TYPE_MESSAGE_DIALOG,
+ "title", aTitle.getStr(),
+ "message-type", (int)GTK_MESSAGE_WARNING,
+ "text", aMessage.getStr(),
+ NULL));
int nButton = 0;
- for( std::list< String >::const_iterator it = rButtons.begin(); it != rButtons.end(); ++it )
- {
- if( nButton == nDefButton )
- {
- gtk_dialog_add_button(GTK_DIALOG( mainwin ),
- MapToGtkAccelerator(*it).getStr(), nButtons);
- gtk_dialog_set_default_response(GTK_DIALOG(mainwin), nButtons);
- }
- else
- {
- rtl::OString aLabel(rtl::OUStringToOString(*it,
- RTL_TEXTENCODING_UTF8));
- gtk_dialog_add_button(GTK_DIALOG(mainwin), aLabel.getStr(),
- nButtons);
- }
- nButtons++;
- }
+ std::list< String >::const_iterator it;
+ for (it = rButtonNames.begin(); it != rButtonNames.end(); ++it)
+ gtk_dialog_add_button (pDialog, MapToGtkAccelerator(*it).getStr(), nButton++);
+ gtk_dialog_set_default_response (pDialog, nDefaultButton);
- nResponse = gtk_dialog_run( GTK_DIALOG(mainwin) );
- if( nResponse == GTK_RESPONSE_NONE || nResponse == GTK_RESPONSE_DELETE_EVENT )
- nResponse = -1;
+ nButton = gtk_dialog_run (pDialog);
+ if (nButton < 0)
+ nButton = -1;
- gtk_widget_destroy( GTK_WIDGET(mainwin) );
+ gtk_widget_destroy (GTK_WIDGET (pDialog));
- return nResponse;
+ return nButton;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index ffa4057..344abbf 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -38,6 +38,7 @@
#include <unx/sm.hxx>
#include <unx/salbmp.h>
#include <unx/salprn.h>
+#include <unx/headless/svpgdi.hxx>
#include <vcl/floatwin.hxx>
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
@@ -567,24 +568,11 @@ ooo_fixed_get_type()
void GtkSalFrame::updateScreenNumber()
{
-#if !GTK_CHECK_VERSION(3,0,0)
- if( getDisplay()->IsXinerama() && getDisplay()->GetXineramaScreens().size() > 1 )
- {
- Point aPoint( maGeometry.nX, maGeometry.nY );
- const std::vector<Rectangle>& rScreenRects( getDisplay()->GetXineramaScreens() );
- size_t nScreens = rScreenRects.size();
- for( size_t i = 0; i < nScreens; i++ )
- {
- if( rScreenRects[i].IsInside( aPoint ) )
- {
- maGeometry.nScreenNumber = static_cast<unsigned int>(i);
- break;
- }
- }
- }
- else
- maGeometry.nScreenNumber = static_cast<unsigned int>(m_nScreen);
-#endif
+ int nScreen = 0;
+ GdkScreen *pScreen = gtk_widget_get_screen( m_pWindow );
+ if( pScreen )
+ nScreen = GtkSalSystem::getScreenMonitorIdx( getGdkDisplay(), pScreen, maGeometry.nX, maGeometry.nY );
+ maGeometry.nScreenNumber = nScreen;
}
void GtkSalFrame::InitCommon()
@@ -1277,39 +1265,24 @@ void GtkSalFrame::Center()
{
nX = ((long)m_pParent->maGeometry.nWidth - (long)maGeometry.nWidth)/2;
nY = ((long)m_pParent->maGeometry.nHeight - (long)maGeometry.nHeight)/2;
-
}
else
{
- long nScreenWidth, nScreenHeight;
- long nScreenX = 0, nScreenY = 0;
+ GdkScreen *pScreen = NULL;
+ gint px, py;
+ GdkModifierType nMask;
+ gdk_display_get_pointer( getGdkDisplay(), &pScreen, &px, &py, &nMask );
+ if( !pScreen )
+ pScreen = gtk_widget_get_screen( m_pWindow );
- Size aScreenSize = GetGtkSalData()->GetDisplay()->GetScreenSize( m_nScreen );
- nScreenWidth = aScreenSize.Width();
- nScreenHeight = aScreenSize.Height();
- if( GetGtkSalData()->GetDisplay()->IsXinerama() )
- {
- // get xinerama screen we are on
- // if there is a parent, use its center for screen determination
- // else use the pointer
- GdkScreen* pScreen;
- gint x, y;
- GdkModifierType aMask;
- gdk_display_get_pointer( getGdkDisplay(), &pScreen, &x, &y, &aMask );
+ gint nMonitor;
+ nMonitor = gdk_screen_get_monitor_at_point( pScreen, px, py );
- const std::vector< Rectangle >& rScreens = GetGtkSalData()->GetDisplay()->GetXineramaScreens();
- for( unsigned int i = 0; i < rScreens.size(); i++ )
- if( rScreens[i].IsInside( Point( x, y ) ) )
- {
- nScreenX = rScreens[i].Left();
- nScreenY = rScreens[i].Top();
- nScreenWidth = rScreens[i].GetWidth();
- nScreenHeight = rScreens[i].GetHeight();
- break;
- }
- }
- nX = nScreenX + (nScreenWidth - (long)maGeometry.nWidth)/2;
- nY = nScreenY + (nScreenHeight - (long)maGeometry.nHeight)/2;
+ GdkRectangle aMonitor;
+ gdk_screen_get_monitor_geometry( pScreen, nMonitor, &aMonitor );
+
+ nX = aMonitor.x + (aMonitor.width - (long)maGeometry.nWidth)/2;
+ nY = aMonitor.y + (aMonitor.height - (long)maGeometry.nHeight)/2;
}
SetPosSize( nX, nY, 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y );
}
@@ -1562,9 +1535,9 @@ void GtkSalFrame::SetMinClientSize( long nWidth, long nHeight )
}
}
-#if GTK_CHECK_VERSION(3,0,0)
void GtkSalFrame::AllocateFrame()
{
+#if GTK_CHECK_VERSION(3,0,0)
basegfx::B2IVector aFrameSize( maGeometry.nWidth, maGeometry.nHeight );
if( ! m_aFrame.get() || m_aFrame->getSize() != aFrameSize )
{
@@ -1576,7 +1549,7 @@ void GtkSalFrame::AllocateFrame()
basebmp::Format::TWENTYFOUR_BIT_TC_MASK,
this );
// basebmp::Format::THIRTYTWO_BIT_TC_MASK_ARGB );
- fprintf( stderr, "allocate m_aFrame size of %dx%d \n",
+ fprintf( stderr, "allocated m_aFrame size of %dx%d \n",
(int)maGeometry.nWidth, (int)maGeometry.nHeight );
#if OSL_DEBUG_LEVEL > 0 // set background to orange
@@ -1584,15 +1557,15 @@ void GtkSalFrame::AllocateFrame()
#endif
// update device in existing graphics
- for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); ++i )
+ for( unsigned int i = 0; i < SAL_N_ELEMENTS( m_aGraphics ); ++i )
{
if( !m_aGraphics[i].pGraphics )
continue;
m_aGraphics[i].pGraphics->setDevice( m_aFrame );
}
}
-}
#endif
+}
void GtkSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags )
{
@@ -1677,10 +1650,8 @@ void GtkSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u
m_bDefaultPos = false;
-#if GTK_CHECK_VERSION(3,0,0)
- if( bSized)
+ if( bSized )
AllocateFrame();
-#endif
if( bSized && ! bMoved )
CallCallback( SALEVENT_RESIZE, NULL );
@@ -1741,10 +1712,12 @@ void GtkSalFrame::SetWindowState( const SalFrameState* pState )
maGeometry.nWidth = pState->mnMaximizedWidth;
maGeometry.nHeight = pState->mnMaximizedHeight;
updateScreenNumber();
+ AllocateFrame();
m_nState = GdkWindowState( m_nState | GDK_WINDOW_STATE_MAXIMIZED );
m_aRestorePosSize = Rectangle( Point( pState->mnX, pState->mnY ),
Size( pState->mnWidth, pState->mnHeight ) );
+ CallCallback( SALEVENT_RESIZE, NULL );
}
else if( pState->mnMask & (SAL_FRAMESTATE_MASK_X | SAL_FRAMESTATE_MASK_Y |
SAL_FRAMESTATE_MASK_WIDTH | SAL_FRAMESTATE_MASK_HEIGHT ) )
@@ -1813,7 +1786,6 @@ sal_Bool GtkSalFrame::GetWindowState( SalFrameState* pState )
}
else
{
-
pState->mnX = maGeometry.nX;
pState->mnY = maGeometry.nY;
pState->mnWidth = maGeometry.nWidth;
@@ -1827,89 +1799,109 @@ sal_Bool GtkSalFrame::GetWindowState( SalFrameState* pState )
return sal_True;
}
-void GtkSalFrame::moveToScreen( int nScreen )
+typedef enum {
+ SET_RETAIN_SIZE,
+ SET_FULLSCREEN,
+ SET_UN_FULLSCREEN
+} SetType;
+
+void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSize )
{
-#if !GTK_CHECK_VERSION(3,0,0)
- if( isChild() )
- return;
-
- if( nScreen < 0 || nScreen >= gdk_display_get_n_screens( getGdkDisplay() ) )
- nScreen = m_nScreen;
- if( nScreen == m_nScreen )
+ if( !m_pWindow )
return;
-
- GdkScreen* pScreen = gdk_display_get_screen( getGdkDisplay(), nScreen );
- if( pScreen )
+
+ gint nMonitor;
+ GdkScreen *pScreen = NULL;
+ pScreen = GtkSalSystem::getScreenMonitorFromIdx( getGdkDisplay(), nNewScreen, nMonitor );
+
+ // 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( nMonitor == nOldMonitor )
+ g_warning( "FIXME: do we get a lot of pointless SetScreens ?" );
+
+ GdkRectangle aOldMonitor, aNewMonitor;
+ gdk_screen_get_monitor_geometry( pScreen, nOldMonitor, &aOldMonitor );
+ gdk_screen_get_monitor_geometry( pScreen, nMonitor, &aNewMonitor );
+
+ 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;
+ maGeometry.nY = aNewMonitor.x;
+ maGeometry.nWidth = aNewMonitor.width;
+ maGeometry.nHeight = aNewMonitor.height;
+ m_nStyle |= SAL_FRAME_STYLE_PARTIAL_FULLSCREEN;
+ bResize = true;
+
+ // #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;
+ }
+
+ if( pSize && eType == SET_UN_FULLSCREEN )
{
- m_nScreen = nScreen;
- gtk_window_set_screen( GTK_WINDOW(m_pWindow), pScreen );
- // realize the window, we need an XWindow id
- gtk_widget_realize( m_pWindow );
- // update system data
- GtkSalDisplay* pDisp = getDisplay();
- m_aSystemData.aWindow = GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow));
+ maGeometry.nX = pSize->Left();
+ maGeometry.nY = pSize->Top();
+ maGeometry.nWidth = pSize->GetWidth();
+ maGeometry.nHeight = pSize->GetHeight();
+ m_nStyle &= ~SAL_FRAME_STYLE_PARTIAL_FULLSCREEN;
+ bResize = true;
+ }
+
+ if (bResize)
+ {
+ // temporarily re-sizeable
+ if( !(m_nStyle & SAL_FRAME_STYLE_SIZEABLE) )
+ gtk_window_set_resizable( GTK_WINDOW(m_pWindow), TRUE );
+ gtk_window_resize( GTK_WINDOW( m_pWindow ), maGeometry.nWidth, maGeometry.nHeight );
+ }
+
+ gtk_window_move( GTK_WINDOW( m_pWindow ), maGeometry.nX, maGeometry.nY );
+
#if !GTK_CHECK_VERSION(3,0,0)
- m_aSystemData.pVisual = pDisp->GetVisual( m_nScreen ).GetVisual();
- m_aSystemData.nDepth = pDisp->GetVisual( m_nScreen ).GetDepth();
- m_aSystemData.aColormap = pDisp->GetColormap( m_nScreen ).GetXColormap();
+ // _NET_WM_STATE_FULLSCREEN (Metacity <-> KWin)
+ if( ! getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() )
#endif
- m_aSystemData.nScreen = nScreen;
- m_aSystemData.pAppContext = NULL;
- m_aSystemData.aShellWindow = m_aSystemData.aWindow;
- // update graphics if necessary
- for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ )
- {
- if( m_aGraphics[i].bInUse )
- m_aGraphics[i].pGraphics->SetDrawable( GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)), m_nScreen );
- }
- updateScreenNumber();
+ {
+ 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 );
- if( m_pParent && m_pParent->m_nScreen != m_nScreen )
+ // FIXME: we should really let gtk+ handle our widget hierarchy ...
+ if( m_pParent && gtk_widget_get_screen( m_pParent->m_pWindow ) != pScreen )
SetParent( NULL );
std::list< GtkSalFrame* > aChildren = m_aChildren;
for( std::list< GtkSalFrame* >::iterator it = aChildren.begin(); it != aChildren.end(); ++it )
- (*it)->moveToScreen( m_nScreen );
-
- // FIXME: SalObjects
-#endif
+ (*it)->SetScreen( nNewScreen, SET_RETAIN_SIZE );
+
+ m_bDefaultPos = m_bDefaultSize = false;
+ updateScreenNumber();
+ CallCallback( SALEVENT_MOVERESIZE, NULL );
+
+ if( bVisible )
+ Show( sal_True );
}
void GtkSalFrame::SetScreenNumber( unsigned int nNewScreen )
{
- if( nNewScreen == maGeometry.nScreenNumber )
- return;
-
- if( m_pWindow && ! isChild() )
- {
- GtkSalDisplay* pDisp = getDisplay();
- if( pDisp->IsXinerama() && pDisp->GetXineramaScreens().size() > 1 )
- {
- if( nNewScreen >= pDisp->GetXineramaScreens().size() )
- return;
-
- Rectangle aOldScreenRect( pDisp->GetXineramaScreens()[maGeometry.nScreenNumber] );
- Rectangle aNewScreenRect( pDisp->GetXineramaScreens()[nNewScreen] );
- bool bVisible = IS_WIDGET_MAPPED(m_pWindow);
- if( bVisible )
- Show( sal_False );
- maGeometry.nX = aNewScreenRect.Left() + (maGeometry.nX - aOldScreenRect.Left());
- maGeometry.nY = aNewScreenRect.Top() + (maGeometry.nY - aOldScreenRect.Top());
-#if !GTK_CHECK_VERSION(3,0,0)
- createNewWindow( None, false, m_nScreen );
-#endif
- gtk_window_move( GTK_WINDOW(m_pWindow), maGeometry.nX, maGeometry.nY );
- if( bVisible )
- Show( sal_True );
- maGeometry.nScreenNumber = nNewScreen;
- }
- else if( sal_Int32(nNewScreen) < pDisp->GetScreenCount() )
- {
- moveToScreen( (int)nNewScreen );
- maGeometry.nScreenNumber = nNewScreen;
- gtk_window_move( GTK_WINDOW(m_pWindow), maGeometry.nX, maGeometry.nY );
- }
- }
+ SetScreen( nNewScreen, SET_RETAIN_SIZE );
}
void GtkSalFrame::updateWMClass()
@@ -1950,101 +1942,23 @@ void GtkSalFrame::SetApplicationID( const rtl::OUString &rWMClass )
void GtkSalFrame::ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nScreen )
{
-#if !GTK_CHECK_VERSION(3,0,0)
- if( m_pWindow && ! isChild() )
+ m_bFullscreen = bFullScreen;
+
+ if( !m_pWindow || isChild() )
+ return;
+
+ if( bFullScreen )
{
- GtkSalDisplay* pDisp = getDisplay();
- // xinerama ?
- if( pDisp->IsXinerama() && pDisp->GetXineramaScreens().size() > 1 )
- {
- if( bFullScreen )
- {
- m_aRestorePosSize = Rectangle( Point( maGeometry.nX, maGeometry.nY ),
- Size( maGeometry.nWidth, maGeometry.nHeight ) );
- bool bVisible = IS_WIDGET_MAPPED(m_pWindow);
- if( bVisible )
- Show( sal_False );
- m_nStyle |= SAL_FRAME_STYLE_PARTIAL_FULLSCREEN;
- createNewWindow( None, false, m_nScreen );
- Rectangle aNewPosSize;
- if( nScreen < 0 || nScreen >= static_cast<int>(pDisp->GetXineramaScreens().size()) )
- aNewPosSize = Rectangle( Point( 0, 0 ), pDisp->GetScreenSize(m_nScreen) );
- else
- aNewPosSize = pDisp->GetXineramaScreens()[ nScreen ];
- gtk_window_resize( GTK_WINDOW(m_pWindow),
- maGeometry.nWidth = aNewPosSize.GetWidth(),
- maGeometry.nHeight = aNewPosSize.GetHeight() );
- gtk_window_move( GTK_WINDOW(m_pWindow),
- maGeometry.nX = aNewPosSize.Left(),
- maGeometry.nY = aNewPosSize.Top() );
- // #i110881# for the benefit of compiz set a max size here
- // else setting to fullscreen fails for unknown reasons
- m_aMaxSize.Width() = aNewPosSize.GetWidth()+100;
- m_aMaxSize.Height() = aNewPosSize.GetHeight()+100;
- // workaround different legacy version window managers have different opinions about
- // _NET_WM_STATE_FULLSCREEN (Metacity <-> KWin)
- if( ! getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() )
- {
- if( !(m_nStyle & SAL_FRAME_STYLE_SIZEABLE) )
- gtk_window_set_resizable( GTK_WINDOW(m_pWindow), sal_True );
- gtk_window_fullscreen( GTK_WINDOW( m_pWindow ) );
- }
- if( bVisible )
- Show( sal_True );
- }
- else
- {
- bool bVisible = IS_WIDGET_MAPPED(m_pWindow);
- if( ! getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() )
- gtk_window_unfullscreen( GTK_WINDOW(m_pWindow) );
- if( bVisible )
- Show( sal_False );
- m_nStyle &= ~SAL_FRAME_STYLE_PARTIAL_FULLSCREEN;
- createNewWindow( None, false, m_nScreen );
- if( ! m_aRestorePosSize.IsEmpty() )
- {
- gtk_window_resize( GTK_WINDOW(m_pWindow),
- maGeometry.nWidth = m_aRestorePosSize.GetWidth(),
- maGeometry.nHeight = m_aRestorePosSize.GetHeight() );
- gtk_window_move( GTK_WINDOW(m_pWindow),
- maGeometry.nX = m_aRestorePosSize.Left(),
- maGeometry.nY = m_aRestorePosSize.Top() );
- m_aRestorePosSize = Rectangle();
- }
- if( bVisible )
- Show( sal_True );
- }
- }
- else
- {
- if( bFullScreen )
- {
- if( !(m_nStyle & SAL_FRAME_STYLE_SIZEABLE) )
- gtk_window_set_resizable( GTK_WINDOW(m_pWindow), TRUE );
- gtk_window_fullscreen( GTK_WINDOW(m_pWindow) );
- moveToScreen( nScreen );
- Size aScreenSize = pDisp->GetScreenSize( m_nScreen );
- maGeometry.nX = 0;
- maGeometry.nY = 0;
- maGeometry.nWidth = aScreenSize.Width();
- maGeometry.nHeight = aScreenSize.Height();
- }
- else
- {
- gtk_window_unfullscreen( GTK_WINDOW(m_pWindow) );
- if( !(m_nStyle & SAL_FRAME_STYLE_SIZEABLE) )
- gtk_window_set_resizable( GTK_WINDOW(m_pWindow), FALSE );
- moveToScreen( nScreen );
- }
- }
- m_bDefaultPos = m_bDefaultSize = false;
- updateScreenNumber();
- CallCallback( SALEVENT_MOVERESIZE, NULL );
+ m_aRestorePosSize = Rectangle( Point( maGeometry.nX, maGeometry.nY ),
+ Size( maGeometry.nWidth, maGeometry.nHeight ) );
+ SetScreen( nScreen, SET_FULLSCREEN );
+ }
+ else
+ {
+ SetScreen( nScreen, SET_UN_FULLSCREEN,
+ !m_aRestorePosSize.IsEmpty() ? &m_aRestorePosSize : NULL );
+ m_aRestorePosSize = Rectangle();
}
- m_bFullscreen = bFullScreen;
-#else
-# warning No fullscreening - fix me !
-#endif
}
/* definitions from xautolock.c (pl15) */
@@ -2055,7 +1969,7 @@ void GtkSalFrame::setAutoLock( bool bLock )
{
if( isChild() )
return;
-
+
GdkScreen *pScreen = gtk_window_get_screen( GTK_WINDOW(m_pWindow) );
GdkDisplay *pDisplay = gdk_screen_get_display( pScreen );
GdkWindow *pRootWin = gdk_screen_get_root_window( pScreen );
@@ -2192,28 +2106,34 @@ void GtkSalFrame::StartPresentation( sal_Bool bStart )
int nTimeout, nInterval, bPreferBlanking, bAllowExposures;
+#if !GTK_CHECK_VERSION(3,0,0)
XGetScreenSaver( pDisplay, &nTimeout, &nInterval,
&bPreferBlanking, &bAllowExposures );
+#endif
if( bStart )
{
if ( nTimeout )
{
m_nSavedScreenSaverTimeout = nTimeout;
+#if !GTK_CHECK_VERSION(3,0,0)
XResetScreenSaver( pDisplay );
XSetScreenSaver( pDisplay, 0, nInterval,
bPreferBlanking, bAllowExposures );
+#endif
}
#ifdef ENABLE_DBUS
- m_nGSMCookie = dbus_inhibit_gsm(g_get_application_name(), "presentation",
+ m_nGSMCookie = dbus_inhibit_gsm(g_get_application_name(), "presentation",
GDK_WINDOW_XID(widget_get_window(m_pWindow)));
#endif
}
else
{
+#if !GTK_CHECK_VERSION(3,0,0)
if( m_nSavedScreenSaverTimeout )
XSetScreenSaver( pDisplay, m_nSavedScreenSaverTimeout,
nInterval, bPreferBlanking,
bAllowExposures );
+#endif
m_nSavedScreenSaverTimeout = 0;
#ifdef ENABLE_DBUS
dbus_uninhibit_gsm(m_nGSMCookie);
@@ -2221,8 +2141,10 @@ void GtkSalFrame::StartPresentation( sal_Bool bStart )
}
}
-void GtkSalFrame::SetAlwaysOnTop( sal_Bool /*bOnTop*/ )
+void GtkSalFrame::SetAlwaysOnTop( sal_Bool bOnTop )
{
+ if( m_pWindow )
+ gtk_window_set_keep_above( GTK_WINDOW( m_pWindow ), bOnTop );
}
void GtkSalFrame::ToTop( sal_uInt16 nFlags )
@@ -2273,7 +2195,7 @@ void GtkSalFrame::SetPointer( PointerStyle ePointerStyle )
GdkCursor *pCursor = getDisplay()->getCursor( ePointerStyle );
gdk_window_set_cursor( widget_get_window(m_pWindow), pCursor );
m_pCurrentCursor = pCursor;
-
+
// #i80791# use grabPointer the same way as CaptureMouse, respective float grab
if( getDisplay()->MouseCaptured( this ) )
grabPointer( sal_True, sal_False );
@@ -2308,7 +2230,7 @@ void GtkSalFrame::grabPointer( sal_Bool bGrab, sal_Bool bOwnerEvents )
if( bUseGdkGrab )
{
const int nMask = ( GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK );
-
+
if( !pEnv || !*pEnv )
gdk_pointer_grab( widget_get_window( m_pWindow ), bOwnerEvents,
(GdkEventMask) nMask, NULL, m_pCurrentCursor,
@@ -2489,6 +2411,16 @@ SalBitmap* GtkSalFrame::SnapShot()
if( !m_pWindow )
return NULL;
+#if GTK_CHECK_VERSION(3,0,0)
+ SvpSalGraphics *pGraphics = static_cast<SvpSalGraphics *>(GetGraphics());
+ if (!pGraphics)
+ return NULL;
+
+ SalBitmap *pRet = pGraphics->getBitmap( 0, 0, maGeometry.nWidth, maGeometry.nHeight );
+ ReleaseGraphics( pGraphics );
+
+ return pRet;
+#else
X11SalBitmap *pBmp = new X11SalBitmap;
GdkWindow *pWin = widget_get_window(m_pWindow);
if( pBmp->SnapShot( GDK_DISPLAY_XDISPLAY( getGdkDisplay() ),
@@ -2496,15 +2428,13 @@ SalBitmap* GtkSalFrame::SnapShot()
return pBmp;
else
delete pBmp;
+#endif
return NULL;
}
void GtkSalFrame::UpdateSettings( AllSettings& rSettings )
{
- (void)rSettings;
-
-#if !GTK_CHECK_VERSION(3,0,0)
if( ! m_pWindow )
return;
@@ -2516,13 +2446,10 @@ void GtkSalFrame::UpdateSettings( AllSettings& rSettings )
bFreeGraphics = true;
}
-#ifndef GTK_GRAPHICS_DISABLED
pGraphics->updateSettings( rSettings );
-#endif
if( bFreeGraphics )
ReleaseGraphics( pGraphics );
-#endif
}
void GtkSalFrame::Beep( SoundType eType )
@@ -2748,6 +2675,7 @@ bool GtkSalFrame::Dispatch( const XEvent* pEvent )
maGeometry.nWidth = pEvent->xconfigure.width;
maGeometry.nHeight = pEvent->xconfigure.height;
setMinMaxSize();
+ AllocateFrame();
getDisplay()->SendInternalEvent( this, NULL, SALEVENT_RESIZE );
}
}
@@ -3044,7 +2972,9 @@ void GtkSalFrame::popIgnoreDamage()
void GtkSalFrame::damaged (const basegfx::B2IRange& rDamageRect)
{
-#if GTK_CHECK_VERSION(3,0,0)
+#if !GTK_CHECK_VERSION(3,0,0)
+ (void)rDamageRect;
+#else
if (m_nDuringRender)
return;
#if OSL_DEBUG_LEVEL > 1
@@ -3290,7 +3220,7 @@ gboolean GtkSalFrame::signalMap( GtkWidget*, GdkEvent*, gpointer frame )
GtkSalFrame* pThis = (GtkSalFrame*)frame;
GTK_YIELD_GRAB();
-
+
if( pThis->m_bFullscreen )
{
/* #i110881# workaorund a gtk issue (see https://bugzilla.redhat.com/show_bug.cgi?id=623191#c8)
@@ -3350,15 +3280,12 @@ gboolean GtkSalFrame::signalConfigure( GtkWidget*, GdkEventConfigure* pEvent, gp
* already exact; even worse: due to the asynchronicity of configure
* events the borderwindow which would evaluate this event
* would size/move based on wrong data if we would actually evaluate
- * this event. So let's swallow it; this is also a performance
- * improvement as one can omit the synchronous XTranslateCoordinates
- * call below.
+ * this event. So let's swallow it.
*/
if( (pThis->m_nStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) &&
pThis->getDisplay()->GetCaptureFrame() == pThis )
return sal_False;
-
/* #i31785# claims we cannot trust the x,y members of the event;
* they are e.g. not set correctly on maximize/demaximize;
* yet the gdkdisplay-x11.c code handling configure_events has
@@ -3378,6 +3305,12 @@ gboolean GtkSalFrame::signalConfigure( GtkWidget*, GdkEventConfigure* pEvent, gp
* - which is not good since the window manager will now size the window back to this
* wrong size at some point.
*/
+ fprintf (stderr, "configure %d %d %d (%d) %d, %d diff? %d\n",
+ (int)pThis->m_bFullscreen, (pThis->m_nStyle & (SAL_FRAME_STYLE_SIZEABLE | SAL_FRAME_STYLE_PLUG)), SAL_FRAME_STYLE_SIZEABLE,
+ !!( pThis->m_bFullscreen || (pThis->m_nStyle & (SAL_FRAME_STYLE_SIZEABLE | SAL_FRAME_STYLE_PLUG)) == SAL_FRAME_STYLE_SIZEABLE ),
+ pEvent->width, pEvent->height,
+ !!(pEvent->width != (int)pThis->maGeometry.nWidth || pEvent->height != (int)pThis->maGeometry.nHeight)
+ );
if( pThis->m_bFullscreen || (pThis->m_nStyle & (SAL_FRAME_STYLE_SIZEABLE | SAL_FRAME_STYLE_PLUG)) == SAL_FRAME_STYLE_SIZEABLE )
{
if( pEvent->width != (int)pThis->maGeometry.nWidth || pEvent->height != (int)pThis->maGeometry.nHeight )
@@ -3406,8 +3339,11 @@ gboolean GtkSalFrame::signalConfigure( GtkWidget*, GdkEventConfigure* pEvent, gp
pThis->maGeometry.nRightDecoration = 0;
}
- GTK_YIELD_GRAB();
pThis->updateScreenNumber();
+ if( bSized )
+ pThis->AllocateFrame();
+
+ GTK_YIELD_GRAB();
if( bMoved && bSized )
pThis->CallCallback( SALEVENT_MOVERESIZE, NULL );
else if( bMoved )
@@ -4226,6 +4162,11 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
{
}
+void GtkSalGraphics::updateSettings( AllSettings& rSettings )
+{
+ g_warning ("unimplemented GtkSalGraphics update");
+}
+
static void print_cairo_region (cairo_region_t *region, const char *msg)
{
if (!region) {
@@ -4307,3 +4248,13 @@ void GtkSalGraphics::copyArea( long nDestX, long nDestY,
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
+Size GtkSalDisplay::GetScreenSize( int nScreen )
+{
+ GdkScreen *pScreen = gdk_display_get_screen (m_pGdkDisplay, nScreen);
+ if (!pScreen)
+ return Size();
+ else
+ return Size( gdk_screen_get_width (pScreen),
+ gdk_screen_get_height (pScreen) );
+}
diff --git a/vcl/unx/x11/x11sys.cxx b/vcl/unx/x11/x11sys.cxx
new file mode 100644
index 0000000..e3d51b4
--- /dev/null
+++ b/vcl/unx/x11/x11sys.cxx
@@ -0,0 +1,174 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <unx/salunx.h>
+#include <unx/saldata.hxx>
+#include <unx/salinst.h>
+#include <unx/saldisp.hxx>
+#include <unx/x11/x11sys.hxx>
+
+#include <vcl/msgbox.hxx>
+#include <vcl/button.hxx>
+
+#include <svdata.hxx>
+
+#include <rtl/ustrbuf.hxx>
+#include <osl/thread.h>
+
+
+SalSystem* X11SalInstance::CreateSalSystem()
+{
+ return new X11SalSystem();
+}
+
+// -----------------------------------------------------------------------
+
+X11SalSystem::~X11SalSystem()
+{
+}
+
+// for the moment only handle xinerama case
+unsigned int X11SalSystem::GetDisplayScreenCount()
+{
+ SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
+ return pSalDisp->IsXinerama() ? pSalDisp->GetXineramaScreens().size() : pSalDisp->GetScreenCount();
+}
+
+bool X11SalSystem::IsMultiDisplay()
+{
+ SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
+ unsigned int nScreenCount = pSalDisp->GetScreenCount();
+ return pSalDisp->IsXinerama() ? false : (nScreenCount > 1);
+}
+
+unsigned int X11SalSystem::GetDefaultDisplayNumber()
+{
+ SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
+ return pSalDisp->GetDefaultScreenNumber();
+}
+
+Rectangle X11SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )
+{
+ Rectangle aRet;
+ SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
+ if( pSalDisp->IsXinerama() )
+ {
+ const std::vector< Rectangle >& rScreens = pSalDisp->GetXineramaScreens();
+ if( nScreen < rScreens.size() )
+ aRet = rScreens[nScreen];
+ }
+ else
+ {
+ const SalDisplay::ScreenData& rScreen = pSalDisp->getDataForScreen( nScreen );
+ aRet = Rectangle( Point( 0, 0 ), rScreen.m_aSize );
+ }
+
+ return aRet;
+}
+
+Rectangle X11SalSystem::GetDisplayWorkAreaPosSizePixel( unsigned int nScreen )
+{
+ // FIXME: workareas
+ return GetDisplayScreenPosSizePixel( nScreen );
+}
+
+rtl::OUString X11SalSystem::GetScreenName( unsigned int nScreen )
+{
+ rtl::OUString aScreenName;
+ SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
+ if( pSalDisp->IsXinerama() )
+ {
+ const std::vector< Rectangle >& rScreens = pSalDisp->GetXineramaScreens();
+ if( nScreen >= rScreens.size() )
+ nScreen = 0;
+ rtl::OUStringBuffer aBuf( 256 );
+ aBuf.append( rtl::OStringToOUString( rtl::OString( DisplayString( pSalDisp->GetDisplay() ) ), osl_getThreadTextEncoding() ) );
+ aBuf.appendAscii( " [" );
+ aBuf.append( static_cast<sal_Int32>(nScreen) );
+ aBuf.append( sal_Unicode(']') );
+ aScreenName = aBuf.makeStringAndClear();
+ }
+ else
+ {
+ if( nScreen >= static_cast<unsigned int>(pSalDisp->GetScreenCount()) )
+ nScreen = 0;
+ rtl::OUStringBuffer aBuf( 256 );
+ aBuf.append( rtl::OStringToOUString( rtl::OString( DisplayString( pSalDisp->GetDisplay() ) ), osl_getThreadTextEncoding() ) );
+ // search backwards for ':'
+ int nPos = aBuf.getLength();
+ if( nPos > 0 )
+ nPos--;
+ while( nPos > 0 && aBuf.charAt( nPos ) != ':' )
+ nPos--;
+ // search forward to '.'
+ while( nPos < aBuf.getLength() && aBuf.charAt( nPos ) != '.' )
+ nPos++;
+ if( nPos < aBuf.getLength() )
+ aBuf.setLength( nPos+1 );
+ else
+ aBuf.append( sal_Unicode('.') );
+ aBuf.append( static_cast<sal_Int32>(nScreen) );
+ aScreenName = aBuf.makeStringAndClear();
+ }
+ return aScreenName;
+}
+
+int X11SalSystem::ShowNativeDialog( const String& rTitle, const String& rMessage, const std::list< String >& rButtons, int nDefButton )
+{
+ int nRet = -1;
+
+ ImplSVData* pSVData = ImplGetSVData();
+ if( pSVData->mpIntroWindow )
+ pSVData->mpIntroWindow->Hide();
+
+ WarningBox aWarn( NULL, WB_STDWORK, rMessage );
+ aWarn.SetText( rTitle );
+ aWarn.Clear();
+
+ sal_uInt16 nButton = 0;
+ for( std::list< String >::const_iterator it = rButtons.begin(); it != rButtons.end(); ++it )
+ {
+ aWarn.AddButton( *it, nButton+1, nButton == (sal_uInt16)nDefButton ? BUTTONDIALOG_DEFBUTTON : 0 );
+ nButton++;
+ }
+ aWarn.SetFocusButton( (sal_uInt16)nDefButton+1 );
+
+ nRet = ((int)aWarn.Execute()) - 1;
+
+ // normalize behaviour, actually this should never happen
+ if( nRet < -1 || nRet >= int(rButtons.size()) )
+ nRet = -1;
+
+ return nRet;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/source/app/salinfo.cxx b/vcl/win/source/app/salinfo.cxx
index f5f149b..d61af97 100644
--- a/vcl/win/source/app/salinfo.cxx
+++ b/vcl/win/source/app/salinfo.cxx
@@ -249,11 +249,7 @@ int WinSalSystem::ShowNativeMessageBox(const String& rTitle, const String& rMess
nDefaultButton <= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO)
nFlags |= DEFAULT_BTN_MAPPING_TABLE[nButtonCombination][nDefaultButton];
- //#107209 hide the splash screen if active
- ImplSVData* pSVData = ImplGetSVData();
- if (pSVData->mpIntroWindow)
- pSVData->mpIntroWindow->Hide();
-
+ ImplHideSplash();
return MessageBoxW(
0,
reinterpret_cast<LPCWSTR>(rMessage.GetBuffer()),
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index f9db19b..e846021 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -5754,9 +5754,7 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lP
if ( WM_USER_SYSTEM_WINDOW_ACTIVATED == nMsg )
{
- if (pSVData->mpIntroWindow)
- pSVData->mpIntroWindow->Hide();
-
+ ImplHideSplash();
return 0;
}
@@ -5942,10 +5940,7 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lP
ImplSVData* pSVData = ImplGetSVData();
pSVData->maAppData.mnModalMode++;
- // #106431#, hide SplashScreen
- if( pSVData->mpIntroWindow )
- pSVData->mpIntroWindow->Hide();
-
+ ImplHideSplash();
if( pWin )
{
pWin->EnableInput( FALSE, TRUE, TRUE, NULL );
commit 21fb1f43c7287f650a3b33d923ab76b23afaf0df
Author: Michael Meeks <michael.meeks at novell.com>
Date: Thu Jul 28 11:24:12 2011 +0100
remove obsolete pieces, and erroneous conditional
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 354f25a..ffa4057 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -473,9 +473,9 @@ GtkSalFrame::~GtkSalFrame()
if( m_pParent )
m_pParent->m_aChildren.remove( this );
-
+
getDisplay()->deregisterFrame( this );
-
+
if( m_pRegion )
{
#if GTK_CHECK_VERSION(3,0,0)
@@ -630,11 +630,10 @@ void GtkSalFrame::InitCommon()
m_ePointerStyle = 0xffff;
m_bSetFocusOnMap = false;
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_app_paintable( m_pWindow, sal_True );
+ gtk_widget_set_app_paintable( m_pWindow, TRUE );
gtk_widget_set_double_buffered( m_pWindow, FALSE );
gtk_widget_set_redraw_on_allocate( m_pWindow, FALSE );
-#endif
+
gtk_widget_add_events( m_pWindow,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
@@ -669,7 +668,6 @@ void GtkSalFrame::InitCommon()
m_aSystemData.aShellWindow = m_aSystemData.aWindow;
m_aSystemData.pShellWidget = m_aSystemData.pWidget;
-
// fake an initial geometry, gets updated via configure event or SetPosSize
if( m_bDefaultPos || m_bDefaultSize )
{
@@ -1366,7 +1364,7 @@ void GtkSalFrame::Show( sal_Bool bVisible, sal_Bool bNoActivate )
if( m_pWindow )
{
#if !GTK_CHECK_VERSION(3,0,0)
- if( m_pParent && (m_pParent->m_nStyle & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN)
+ if( m_pParent && (m_pParent->m_nStyle & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN)
&& getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() )
gtk_window_set_keep_above( GTK_WINDOW(m_pWindow), bVisible );
#endif
@@ -1374,7 +1372,7 @@ void GtkSalFrame::Show( sal_Bool bVisible, sal_Bool bNoActivate )
{
initClientId();
getDisplay()->startupNotificationCompleted();
-
+
if( m_bDefaultPos )
Center();
if( m_bDefaultSize )
@@ -1722,13 +1720,13 @@ void GtkSalFrame::SetWindowState( const SalFrameState* pState )
{
if( ! m_pWindow || ! pState || isChild( true, false ) )
return;
-
+
const sal_uLong nMaxGeometryMask =
SAL_FRAMESTATE_MASK_X | SAL_FRAMESTATE_MASK_Y |
SAL_FRAMESTATE_MASK_WIDTH | SAL_FRAMESTATE_MASK_HEIGHT |
SAL_FRAMESTATE_MASK_MAXIMIZED_X | SAL_FRAMESTATE_MASK_MAXIMIZED_Y |
SAL_FRAMESTATE_MASK_MAXIMIZED_WIDTH | SAL_FRAMESTATE_MASK_MAXIMIZED_HEIGHT;
-
+
if( (pState->mnMask & SAL_FRAMESTATE_MASK_STATE) &&
! ( m_nState & GDK_WINDOW_STATE_MAXIMIZED ) &&
(pState->mnState & SAL_FRAMESTATE_MAXIMIZED) &&
@@ -3361,22 +3359,11 @@ gboolean GtkSalFrame::signalConfigure( GtkWidget*, GdkEventConfigure* pEvent, gp
return sal_False;
-#if !GTK_CHECK_VERSION(3,0,0)
- // in child case the coordinates are not root coordinates,
- // need to transform
-
- /* #i31785# sadly one cannot really trust the x,y members of the event;
- * they are e.g. not set correctly on maximize/demaximize; this rather
- * sounds like a bug in gtk we have to workaround.
+ /* #i31785# claims we cannot trust the x,y members of the event;
+ * they are e.g. not set correctly on maximize/demaximize;
+ * yet the gdkdisplay-x11.c code handling configure_events has
+ * done this XTranslateCoordinates work since the day ~zero.
*/
- XLIB_Window aChild;
- XTranslateCoordinates( pThis->getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW(widget_get_window(GTK_WIDGET(pThis->m_pWindow))),
- pThis->getDisplay()->GetRootWindow( pThis->getDisplay()->GetDefaultScreenNumber() ),
- 0, 0,
- &x, &y,
- &aChild );
-
if( x != pThis->maGeometry.nX || y != pThis->maGeometry.nY )
{
bMoved = true;
@@ -3400,7 +3387,7 @@ gboolean GtkSalFrame::signalConfigure( GtkWidget*, GdkEventConfigure* pEvent, gp
pThis->maGeometry.nHeight = pEvent->height;
}
}
-
+
// update decoration hints
if( ! (pThis->m_nStyle & SAL_FRAME_STYLE_PLUG) )
{
@@ -3428,7 +3415,6 @@ gboolean GtkSalFrame::signalConfigure( GtkWidget*, GdkEventConfigure* pEvent, gp
else if( bSized )
pThis->CallCallback( SALEVENT_RESIZE, NULL );
-#endif
return sal_False;
}
@@ -3503,7 +3489,7 @@ gboolean GtkSalFrame::signalKey( GtkWidget*, GdkEventKey* pEvent, gpointer frame
// except Mac OS X
case GDK_Meta_L:
case GDK_Super_L:
- nExtModMask = MODKEY_LMOD3;
+ nExtModMask = MODKEY_LMOD3;
nModMask = KEY_MOD3;
break;
case GDK_Meta_R:
More information about the Libreoffice-commits
mailing list