[Libreoffice-commits] .: vcl/aqua vcl/inc vcl/os2 vcl/source vcl/unx vcl/win

Caolán McNamara caolan at kemper.freedesktop.org
Thu Oct 28 01:09:25 PDT 2010


 vcl/aqua/inc/salframe.h              |    1 
 vcl/aqua/source/window/salframe.cxx  |    4 ++
 vcl/inc/vcl/salframe.hxx             |    2 +
 vcl/inc/vcl/syswin.hxx               |    2 +
 vcl/os2/inc/salframe.h               |    1 
 vcl/os2/source/window/salframe.cxx   |    4 ++
 vcl/source/window/syswin.cxx         |    7 +++-
 vcl/unx/gtk/window/gtkframe.cxx      |   53 ++++++++++++++++++++++++-----------
 vcl/unx/headless/svpframe.hxx        |    1 
 vcl/unx/inc/plugins/gtk/gtkframe.hxx |    4 ++
 vcl/unx/inc/salframe.h               |    5 +++
 vcl/unx/source/window/salframe.cxx   |   45 +++++++++++++++++++++--------
 vcl/win/inc/salframe.h               |    1 
 vcl/win/source/window/salframe.cxx   |    4 ++
 14 files changed, 105 insertions(+), 29 deletions(-)

New commits:
commit 8bb4853fe6d4e858f89616c9294d9f5ae00e2e79
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Oct 27 23:05:06 2010 +0100

    fdo#632229# provide some support for a per-windowframe ApplicationID/WM_CLASS

diff --git a/vcl/aqua/inc/salframe.h b/vcl/aqua/inc/salframe.h
index 731b04e..d8880f0 100644
--- a/vcl/aqua/inc/salframe.h
+++ b/vcl/aqua/inc/salframe.h
@@ -159,6 +159,7 @@ public:
     virtual void                SetExtendedFrameStyle( SalExtStyle );
     virtual void                SetBackgroundBitmap( SalBitmap* );
     virtual void                SetScreenNumber(unsigned int);
+    virtual void                SetApplicationID( const rtl::OUString &rApplicationID );
 
     // shaped system windows
     // set clip region to none (-> rectangular windows, normal state)
diff --git a/vcl/aqua/source/window/salframe.cxx b/vcl/aqua/source/window/salframe.cxx
index 4652b12..eb1ed95 100644
--- a/vcl/aqua/source/window/salframe.cxx
+++ b/vcl/aqua/source/window/salframe.cxx
@@ -664,6 +664,10 @@ void AquaSalFrame::SetScreenNumber(unsigned int nScreen)
     }
 }
 
+void AquaSalFrame::SetApplicationID( const rtl::OUString &/*rApplicationID*/ )
+{
+}
+
 // -----------------------------------------------------------------------
 
 void AquaSalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 nDisplay )
diff --git a/vcl/inc/vcl/salframe.hxx b/vcl/inc/vcl/salframe.hxx
index f822b37..3e4671d 100644
--- a/vcl/inc/vcl/salframe.hxx
+++ b/vcl/inc/vcl/salframe.hxx
@@ -266,6 +266,8 @@ public:
     // move the frame to a new screen
     virtual void                SetScreenNumber( unsigned int nScreen ) = 0;
 
+    virtual void                SetApplicationID( const rtl::OUString &rApplicationID) = 0;
+
     // shaped system windows
     // set clip region to none (-> rectangular windows, normal state)
     virtual void					ResetClipRegion() = 0;
diff --git a/vcl/inc/vcl/syswin.hxx b/vcl/inc/vcl/syswin.hxx
index aae5c64..db240c1 100644
--- a/vcl/inc/vcl/syswin.hxx
+++ b/vcl/inc/vcl/syswin.hxx
@@ -277,6 +277,8 @@ public:
     @see GetScreenNumber
     */
     void            SetScreenNumber( unsigned int nNewScreen );
+
+    void            SetApplicationID( const rtl::OUString &rApplicationID );
 };
 
 #endif // _SV_SYSWIN_HXX
diff --git a/vcl/os2/inc/salframe.h b/vcl/os2/inc/salframe.h
index 5461c3c..7685629 100644
--- a/vcl/os2/inc/salframe.h
+++ b/vcl/os2/inc/salframe.h
@@ -158,6 +158,7 @@ public:
     virtual bool				SetPluginParent( SystemParentData* pNewParent );
     virtual void                SetBackgroundBitmap( SalBitmap* );
     virtual void                SetScreenNumber( unsigned int );
+    virtual void                SetApplicationID( const rtl::OUString &rApplicationID );
     virtual void				ResetClipRegion();
     virtual void				BeginSetClipRegion( ULONG nRects );
     virtual void				UnionClipRegion( long nX, long nY, long nWidth, long nHeight );
diff --git a/vcl/os2/source/window/salframe.cxx b/vcl/os2/source/window/salframe.cxx
index e8b56d3..dc54c6b 100644
--- a/vcl/os2/source/window/salframe.cxx
+++ b/vcl/os2/source/window/salframe.cxx
@@ -1366,6 +1366,10 @@ void Os2SalFrame::SetScreenNumber( unsigned int nNewScreen )
 {
 }
 
+void Os2SalFrame::SetApplicationID( const rtl::OUString &/*rApplicationID*/ )
+{
+}
+
 // -----------------------------------------------------------------------
 
 // native menu implementation - currently empty
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index ef1bc65..dbd52d1 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -1079,9 +1079,14 @@ unsigned int SystemWindow::GetScreenNumber() const
 
 // -----------------------------------------------------------------------
 
-void SystemWindow::SetScreenNumber( unsigned int nScreen)
+void SystemWindow::SetScreenNumber(unsigned int nScreen)
 {
     mpWindowImpl->mpFrame->SetScreenNumber( nScreen );
 }
 
+void SystemWindow::SetApplicationID(const rtl::OUString &rApplicationID)
+{
+    mpWindowImpl->mpFrame->SetApplicationID(rApplicationID);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 2398fbb..43833df 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -798,6 +798,8 @@ void GtkSalFrame::Init( SalFrame* pParent, ULONG nStyle )
 
     // force wm class hint
     m_nExtStyle = ~0;
+    if (m_pParent)
+        m_sWMClass = m_pParent->m_sWMClass;
     SetExtendedFrameStyle( 0 );
 
     if( m_pParent && m_pParent->m_pWindow && ! isChild() )
@@ -981,25 +983,10 @@ void GtkSalFrame::SetExtendedFrameStyle( SalExtStyle nStyle )
     if( nStyle != m_nExtStyle && ! isChild() )
     {
         m_nExtStyle = nStyle;
-        if( GTK_WIDGET_REALIZED( m_pWindow ) )
-        {
-            XClassHint* pClass = XAllocClassHint();
-            rtl::OString aResHint = X11SalData::getFrameResName( m_nExtStyle );
-            pClass->res_name  = const_cast<char*>(aResHint.getStr());
-            pClass->res_class = const_cast<char*>(X11SalData::getFrameClassName());
-            XSetClassHint( getDisplay()->GetDisplay(),
-                           GDK_WINDOW_XWINDOW(m_pWindow->window),
-                           pClass );
-            XFree( pClass );
-        }
-        else
-            gtk_window_set_wmclass( GTK_WINDOW(m_pWindow),
-                                    X11SalData::getFrameResName( m_nExtStyle ),
-                                    X11SalData::getFrameClassName() );
+        updateWMClass();
     }
 }
 
-
 SalGraphics* GtkSalFrame::GetGraphics()
 {
     if( m_pWindow )
@@ -1792,6 +1779,40 @@ void GtkSalFrame::SetScreenNumber( unsigned int nNewScreen )
     }
 }
 
+void GtkSalFrame::updateWMClass()
+{
+    rtl::OString aResClass = rtl::OUStringToOString(m_sWMClass, RTL_TEXTENCODING_ASCII_US);
+    const char *pResClass = aResClass.getLength() ? aResClass.getStr() : X11SalData::getFrameClassName();
+
+    if( GTK_WIDGET_REALIZED( m_pWindow ) )
+    {
+        XClassHint* pClass = XAllocClassHint();
+        rtl::OString aResName = X11SalData::getFrameResName( m_nExtStyle );
+        pClass->res_name  = const_cast<char*>(aResName.getStr());
+        pClass->res_class = const_cast<char*>(pResClass);
+        XSetClassHint( getDisplay()->GetDisplay(),
+                       GDK_WINDOW_XWINDOW(m_pWindow->window),
+                       pClass );
+        XFree( pClass );
+    }
+    else
+        gtk_window_set_wmclass( GTK_WINDOW(m_pWindow),
+                                X11SalData::getFrameResName( m_nExtStyle ),
+                                pResClass );
+}
+
+void GtkSalFrame::SetApplicationID( const rtl::OUString &rWMClass )
+{
+    if( rWMClass != m_sWMClass && ! isChild() )
+    {
+        m_sWMClass = rWMClass;
+        updateWMClass();
+
+        for( std::list< GtkSalFrame* >::iterator it = m_aChildren.begin(); it != m_aChildren.end(); ++it )
+            (*it)->SetApplicationID(rWMClass);
+    }
+}
+
 void GtkSalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 nScreen )
 {
     if( m_pWindow && ! isChild() )
diff --git a/vcl/unx/headless/svpframe.hxx b/vcl/unx/headless/svpframe.hxx
index 796ce7b..7b4f92a 100644
--- a/vcl/unx/headless/svpframe.hxx
+++ b/vcl/unx/headless/svpframe.hxx
@@ -125,6 +125,7 @@ public:
 
     /*TODO: functional implementation */
     virtual void                SetScreenNumber( unsigned int nScreen ) { (void)nScreen; }
+    virtual void                SetApplicationID(const rtl::OUString &rApplicationID) { (void) rApplicationID; }
 };
 #endif // _SVP_SVPFRAME_HXX
 
diff --git a/vcl/unx/inc/plugins/gtk/gtkframe.hxx b/vcl/unx/inc/plugins/gtk/gtkframe.hxx
index a975a3b..350185c 100644
--- a/vcl/unx/inc/plugins/gtk/gtkframe.hxx
+++ b/vcl/unx/inc/plugins/gtk/gtkframe.hxx
@@ -192,6 +192,7 @@ class GtkSalFrame : public SalFrame
     bool                            m_bWindowIsGtkPlug;
     bool                            m_bSetFocusOnMap;
     String                          m_aTitle;
+    rtl::OUString                   m_sWMClass;
     
     IMHandler*                      m_pIMHandler;
     
@@ -269,6 +270,8 @@ class GtkSalFrame : public SalFrame
     void setMinMaxSize();
     void createNewWindow( XLIB_Window aParent, bool bXEmbed, int nScreen );
     void askForXEmbedFocus( sal_Int32 nTimecode );
+
+    void updateWMClass();
     
     DECL_LINK( ImplDelayedFullScreenHdl, void* );
 public:
@@ -387,6 +390,7 @@ public:
     virtual void                SetBackgroundBitmap( SalBitmap* );
 
     virtual void                SetScreenNumber( unsigned int );
+    virtual void                SetApplicationID( const rtl::OUString &rWMClass );
 
     // shaped system windows
     // set clip region to none (-> rectangular windows, normal state)
diff --git a/vcl/unx/inc/salframe.h b/vcl/unx/inc/salframe.h
index 7888d0b..be23d8b 100644
--- a/vcl/unx/inc/salframe.h
+++ b/vcl/unx/inc/salframe.h
@@ -128,6 +128,8 @@ class VCL_DLLPUBLIC X11SalFrame : public SalFrame
     int			    mnIconID;
     
     String          m_aTitle;
+
+    rtl::OUString   m_sWMClass;
     
     SystemChildData maSystemChildData;
     
@@ -171,6 +173,8 @@ class VCL_DLLPUBLIC X11SalFrame : public SalFrame
     
     void            setXEmbedInfo();
     void            askForXEmbedFocus( sal_Int32 i_nTimeCode );
+
+    void            updateWMClass();
 public:
     X11SalFrame( SalFrame* pParent, ULONG nSalFrameStyle, SystemParentData* pSystemParent = NULL );
     virtual ~X11SalFrame();
@@ -261,6 +265,7 @@ public:
     virtual void                SetBackgroundBitmap( SalBitmap* pBitmap );
 
     virtual void                SetScreenNumber( unsigned int );
+    virtual void                SetApplicationID( const rtl::OUString &rWMClass );
     
     // shaped system windows
     // set clip region to none (-> rectangular windows, normal state)
diff --git a/vcl/unx/source/window/salframe.cxx b/vcl/unx/source/window/salframe.cxx
index b1fb134..4739b73 100644
--- a/vcl/unx/source/window/salframe.cxx
+++ b/vcl/unx/source/window/salframe.cxx
@@ -542,11 +542,11 @@ void X11SalFrame::Init( ULONG nSalFrameStyle, int nScreen, SystemParentData* pPa
             a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_TAKE_FOCUS );
         XSetWMProtocols( GetXDisplay(), GetShellWindow(), a, n );
 
-        XClassHint* pClass = XAllocClassHint();
-        pClass->res_name  = const_cast<char*>(X11SalData::getFrameResName());
-        pClass->res_class = const_cast<char*>(X11SalData::getFrameClassName());
-        XSetClassHint( GetXDisplay(), GetShellWindow(), pClass );
-        XFree( pClass );
+        // force wm class hint
+        mnExtStyle = ~0;
+        if (mpParent)
+            m_sWMClass = mpParent->m_sWMClass;
+        SetExtendedFrameStyle( 0 );
 
         XSizeHints* pHints = XAllocSizeHints();
         pHints->flags       = PWinGravity | PPosition;
@@ -849,13 +849,7 @@ void X11SalFrame::SetExtendedFrameStyle( SalExtStyle nStyle )
     if( nStyle != mnExtStyle && ! IsChildWindow() )
     {
         mnExtStyle = nStyle;
-    
-        XClassHint* pClass = XAllocClassHint();
-        rtl::OString aResHint = X11SalData::getFrameResName( mnExtStyle );
-        pClass->res_name  = const_cast<char*>(aResHint.getStr());
-        pClass->res_class = const_cast<char*>(X11SalData::getFrameClassName());
-        XSetClassHint( GetXDisplay(), GetShellWindow(), pClass );
-        XFree( pClass );
+        updateWMClass();
     }
 }
 
@@ -2192,6 +2186,33 @@ void X11SalFrame::SetScreenNumber( unsigned int nNewScreen )
     }
 }
 
+void X11SalFrame::SetApplicationID( const rtl::OUString &rWMClass )
+{
+    if( rWMClass != m_sWMClass && ! IsChildWindow() )
+    {
+        m_sWMClass = rWMClass;
+        updateWMClass();
+        std::list< X11SalFrame* >::const_iterator it;
+        for( it = maChildren.begin(); it != maChildren.end(); ++it )
+            (*it)->SetApplicationID(rWMClass);
+    }
+}
+
+void X11SalFrame::updateWMClass()
+{
+    XClassHint* pClass = XAllocClassHint();
+    rtl::OString aResName = X11SalData::getFrameResName( mnExtStyle );
+    pClass->res_name  = const_cast<char*>(aResName.getStr());
+
+    rtl::OString aResClass = rtl::OUStringToOString(m_sWMClass, RTL_TEXTENCODING_ASCII_US);
+    const char *pResClass = aResClass.getLength() ? aResClass.getStr() : X11SalData::getFrameClassName();
+
+    pClass->res_class = const_cast<char*>(pResClass);
+    XSetClassHint( GetXDisplay(), GetShellWindow(), pClass );
+    XFree( pClass );
+}
+
+
 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 void X11SalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 nScreen )
diff --git a/vcl/win/inc/salframe.h b/vcl/win/inc/salframe.h
index 676a054..62416ce 100644
--- a/vcl/win/inc/salframe.h
+++ b/vcl/win/inc/salframe.h
@@ -141,6 +141,7 @@ public:
     virtual bool				SetPluginParent( SystemParentData* pNewParent );
     virtual void                SetBackgroundBitmap( SalBitmap* );
     virtual void                SetScreenNumber( unsigned int );
+    virtual void                SetApplicationID( const rtl::OUString &rApplicationID );
     virtual void				ResetClipRegion();
     virtual void				BeginSetClipRegion( ULONG nRects );
     virtual void				UnionClipRegion( long nX, long nY, long nWidth, long nHeight );
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index a474073..46a825b 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -2036,6 +2036,10 @@ void WinSalFrame::SetScreenNumber( unsigned int nNewScreen )
     }
 }
 
+void WinSalFrame::SetApplicationID( const rtl::OUString &/*rApplicationID*/ )
+{
+}
+
 // -----------------------------------------------------------------------
 
 void WinSalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 nDisplay )


More information about the Libreoffice-commits mailing list