Commits

Anonymous committed 173e68c

vcl116: #i96684# optionally do not switch workspaces of WM

Comments (0)

Files changed (2)

vcl/unx/inc/wmadaptor.hxx

     bool                    m_bLegacyPartialFullscreen;
     int						m_nWinGravity;
     int						m_nInitWinGravity;
+    bool                    m_bWMshouldSwitchWorkspace;
+    bool                    m_bWMshouldSwitchWorkspaceInit;
 
     WMAdaptor( SalDisplay * )
 ;
      */
     virtual bool isValid() const;
 
+    bool getWMshouldSwitchWorkspace() const;
 public:
     virtual ~WMAdaptor();
 
     
     /*
      * attemp to switch the desktop to a certain workarea
+     * if bConsiderWM is true, then on some WMs the call will not result in any action
      */
-    void switchToWorkArea( int nWorkArea ) const;
+    void switchToWorkArea( int nWorkArea, bool bConsiderWM = true ) const;
     
     /*
      *  sets window title

vcl/unx/source/app/wmadaptor.cxx

 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sal/alloca.h>
-#include <wmadaptor.hxx>
-#include <saldisp.hxx>
-#include <saldata.hxx>
-#include <salframe.h>
-#include <vcl/salgdi.hxx>
-#include <osl/thread.h>
-#include <rtl/locale.h>
-#include <osl/process.h>
+#include "sal/alloca.h"
+#include "wmadaptor.hxx"
+#include "saldisp.hxx"
+#include "saldata.hxx"
+#include "salframe.h"
+#include "vcl/salgdi.hxx"
+#include "osl/thread.h"
+#include "rtl/locale.h"
+#include "osl/process.h"
+#include "vcl/configsettings.hxx"
 
-#include <tools/prex.h>
+#include "tools/prex.h"
 #include <X11/X.h>
 #include <X11/Xatom.h>
 #include <X11/Xresource.h>
-#include <tools/postx.h>
+#include "tools/postx.h"
 
 #if OSL_DEBUG_LEVEL > 1
 #include <stdio.h>
         m_bEnableAlwaysOnTopWorks( false ),
         m_bLegacyPartialFullscreen( false ),
         m_nWinGravity( StaticGravity ),
-        m_nInitWinGravity( StaticGravity )
+        m_nInitWinGravity( StaticGravity ),
+        m_bWMshouldSwitchWorkspace( true ),
+        m_bWMshouldSwitchWorkspaceInit( false )
 {
     Atom				aRealType	= None;
     int					nFormat		= 8;
     return bNetWM;
 }
 
+bool WMAdaptor::getWMshouldSwitchWorkspace() const
+{
+    if( ! m_bWMshouldSwitchWorkspaceInit )
+    {
+        WMAdaptor * pWMA = const_cast<WMAdaptor*>(this);
+    
+        pWMA->m_bWMshouldSwitchWorkspace = true;
+        vcl::SettingsConfigItem* pItem = vcl::SettingsConfigItem::get();
+        rtl::OUString aSetting( pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WM" ) ),
+                                                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ShouldSwitchWorkspace" ) ) ) );
+        if( aSetting.getLength() == 0 )
+        {
+            if( m_aWMName.EqualsAscii( "awesome" ) )
+            {
+                pWMA->m_bWMshouldSwitchWorkspace = false;
+            }
+        }
+        else
+            pWMA->m_bWMshouldSwitchWorkspace = aSetting.toBoolean();
+        pWMA->m_bWMshouldSwitchWorkspaceInit = true;
+    }
+    return m_bWMshouldSwitchWorkspace;
+}
+
 /*
  *  WMAdaptor::isValid()
  */
  *  WMAdaptor::getCurrentWorkArea
  */
 // fixme: multi screen case
-void WMAdaptor::switchToWorkArea( int nWorkArea ) const
+void WMAdaptor::switchToWorkArea( int nWorkArea, bool bConsiderWM ) const
 {
+    if( bConsiderWM && ! getWMshouldSwitchWorkspace() )
+        return;
+
     if( m_aWMAtoms[ NET_CURRENT_DESKTOP ] )
     {
         XEvent aEvent;