<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>108961</bug_id>
          
          <creation_ts>2005-07-12 01:41:59 +0000</creation_ts>
          <short_desc>&quot;Disable shorcuts&quot; window-specific setting</short_desc>
          <delta_ts>2006-03-04 15:23:59 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Plasma</classification>
          <product>kwin</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>Gentoo Packages</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>wishlist</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Zachary Jensen">coolguyzak</reporter>
          <assigned_to name="KWin default assignee">kwin-bugs-null</assigned_to>
          <cc>contact</cc>
    
    <cc>kjetil</cc>
    
    <cc>thomas.bettler</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>357219</commentid>
    <comment_count>0</comment_count>
    <who name="Zachary Jensen">coolguyzak</who>
    <bug_when>2005-07-12 01:41:59 +0000</bug_when>
    <thetext>Version:            (using KDE KDE 3.4.1)
Installed from:    Gentoo Packages

Would it be possible to create a window-specific setting that forwards global keyboard shortcuts to the window?

Example: I am trying to use inkscape, and one of it&apos;s commands is alt+drag. But when I do that, kwin interprets it as &quot;Zak is trying to move the window&quot;. Basically, kwin intercepts the signal before inkscape can act on it.

I don&apos;t want to ask you guys to change the default for the application&apos;s sake, but it would be nice if there was a way to disable it. (Maybe there is, using KHotKeys?)

I&apos;ll try the above solution, but it would be nice to have both options available.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>358982</commentid>
    <comment_count>1</comment_count>
    <who name="Lubos Lunak">l.lunak</who>
    <bug_when>2005-07-19 15:08:03 +0000</bug_when>
    <thetext>*** Bug 94643 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>361971</commentid>
    <comment_count>2</comment_count>
    <who name="Lubos Lunak">l.lunak</who>
    <bug_when>2005-08-01 16:46:17 +0000</bug_when>
    <thetext>SVN commit 442075 by lunakl:

Implement #108961 - there&apos;s now a shortcut and window-specific setting
for &apos;Block global shortcuts&apos;, which allows applications like Xnest etc.
to get shortcuts like Alt+F4 etc. that&apos;d be otherwise intercepted as
global shortcuts. A shortcut turn it on and off globally, window-specific
setting only for the given window, the shortcut can turn it temporarily
off even for window with a window-specific setting.
FEATURE: 108961



 M  +6 -1      kaccelbase.cpp  
 M  +1 -0      kaccelbase.h  
 M  +7 -1      kapplication.cpp  
 M  +6 -0      kglobalaccel.cpp  
 M  +9 -0      kglobalaccel.h  
 M  +42 -8     kglobalaccel_x11.cpp  
 M  +7 -0      kglobalaccel_x11.h  
 M  +1 -0      kipc.h  


--- branches/KDE/3.5/kdelibs/kdecore/kaccelbase.cpp #442074:442075
@@ -63,6 +63,11 @@
 uint KAccelBase::actionCount() const { return m_rgActions.count(); }
 KAccelActions&amp; KAccelBase::actions() { return m_rgActions; }
 bool KAccelBase::isEnabled() const { return m_bEnabled; }
+// see KGlobalAccel::blockShortcuts() stuff - it&apos;s to temporarily block
+// all global shortcuts, so that the key grabs are released, but from the app&apos;s
+// point of view the KGlobalAccel is still enabled, so KGlobalAccel needs
+// to disable key grabbing even if enabled
+bool KAccelBase::isEnabledInternal() const { return isEnabled(); }
 
 KAccelAction* KAccelBase::actionPtr( const QString&amp; sAction )
 	{ return m_rgActions.actionPtr( sAction ); }
@@ -417,7 +422,7 @@
 void KAccelBase::createKeyList( QValueVector&lt;struct X&gt;&amp; rgKeys )
 {
 	//kdDebug(125) &lt;&lt; &quot;KAccelBase::createKeyList()&quot; &lt;&lt; endl;
-	if( !m_bEnabled )
+	if( !isEnabledInternal())
 		return;
 
 	// create the list
--- branches/KDE/3.5/kdelibs/kdecore/kaccelbase.h #442074:442075
@@ -198,6 +198,7 @@
 	virtual bool disconnectKey( const KKeyServer::Key&amp; ) = 0;
 
  protected:
+        virtual bool isEnabledInternal() const;
 	struct ActionInfo
 	{
 		KAccelAction* pAction;
--- branches/KDE/3.5/kdelibs/kdecore/kapplication.cpp #442074:442075
@@ -73,6 +73,7 @@
 #include &lt;kprotocolinfo.h&gt;
 #include &lt;kkeynative.h&gt;
 #include &lt;kmdcodec.h&gt;
+#include &lt;kglobalaccel.h&gt;
 
 #if defined Q_WS_X11
 #include &lt;kstartupinfo.h&gt;
@@ -828,7 +829,7 @@
   kipcEventMask = (1 &lt;&lt; KIPC::StyleChanged) | (1 &lt;&lt; KIPC::PaletteChanged) |
                   (1 &lt;&lt; KIPC::FontChanged) | (1 &lt;&lt; KIPC::BackgroundChanged) |
                   (1 &lt;&lt; KIPC::ToolbarStyleChanged) | (1 &lt;&lt; KIPC::SettingsChanged) |
-                  (1 &lt;&lt; KIPC::ClipboardConfigChanged);
+                  (1 &lt;&lt; KIPC::ClipboardConfigChanged | (1 &lt;&lt; KIPC::BlockShortcuts));
 #endif
 
   // Trigger creation of locale.
@@ -1779,6 +1780,11 @@
             case KIPC::ClipboardConfigChanged:
                 KClipboardSynchronizer::newConfiguration(arg);
                 break;
+                
+            case KIPC::BlockShortcuts:
+                KGlobalAccel::blockShortcuts(arg);
+                emit kipcMessage(id, arg); // some apps may do additional things
+                break;
             }
         }
         else if (id &gt;= 32)
--- branches/KDE/3.5/kdelibs/kdecore/kglobalaccel.cpp #442074:442075
@@ -65,6 +65,12 @@
 void KGlobalAccel::setEnabled( bool bEnabled )
 	{ d-&gt;setEnabled( bEnabled ); }
 
+void KGlobalAccel::blockShortcuts( bool block )
+        { KGlobalAccelPrivate::blockShortcuts( block ); }
+
+void KGlobalAccel::disableBlocking( bool disable )
+        { d-&gt;disableBlocking( disable ); }
+
 KAccelAction* KGlobalAccel::insert( const QString&amp; sAction, const QString&amp; sDesc, const QString&amp; sHelp,
 		const KShortcut&amp; cutDef3, const KShortcut&amp; cutDef4,
 		const QObject* pObjSlot, const char* psMethodSlot,
--- branches/KDE/3.5/kdelibs/kdecore/kglobalaccel.h #442074:442075
@@ -206,6 +206,15 @@
 	 * KAccelActions::useFourModifierKeys().
 	 */
 	static bool useFourModifierKeys();
+        
+        /**
+         * @internal
+         */
+        static void blockShortcuts( bool block );
+        /**
+         * @internal
+         */
+        void disableBlocking( bool disable );
 
 private:
 
--- branches/KDE/3.5/kdelibs/kdecore/kglobalaccel_x11.cpp #442074:442075
@@ -76,9 +76,16 @@
 
 //----------------------------------------------------
 
+static QValueList&lt; KGlobalAccelPrivate* &gt;* all_accels;
+
 KGlobalAccelPrivate::KGlobalAccelPrivate()
 : KAccelBase( KAccelBase::NATIVE_KEYS )
+, m_blocked( false )
+, m_blockingDisabled( false )
 {
+        if( all_accels == NULL )
+            all_accels = new QValueList&lt; KGlobalAccelPrivate* &gt;;
+        all_accels-&gt;append( this );
 	m_sConfigGroup = &quot;Global Shortcuts&quot;;
 	kapp-&gt;installX11EventFilter( this );
 }
@@ -89,6 +96,11 @@
 	//for( CodeModMap::ConstIterator it = m_rgCodeModToAction.begin(); it != m_rgCodeModToAction.end(); ++it ) {
 	//	const CodeMod&amp; codemod = it.key();
 	//}
+        all_accels-&gt;remove( this );
+        if( all_accels-&gt;count() == 0 ) {
+            delete all_accels;
+            all_accels = NULL;
+        }
 }
 
 void KGlobalAccelPrivate::setEnabled( bool bEnable )
@@ -97,6 +109,30 @@
 	updateConnections();
 }
 
+void KGlobalAccelPrivate::blockShortcuts( bool block )
+{
+        if( all_accels == NULL )
+            return;
+        for( QValueList&lt; KGlobalAccelPrivate* &gt;::ConstIterator it = all_accels-&gt;begin();
+             it != all_accels-&gt;end();
+             ++it ) {
+            if( (*it)-&gt;m_blockingDisabled )
+                continue;
+            (*it)-&gt;m_blocked = block;
+            (*it)-&gt;updateConnections();
+        }
+}
+
+void KGlobalAccelPrivate::disableBlocking( bool block )
+{
+        m_blockingDisabled = block;
+}
+
+bool KGlobalAccelPrivate::isEnabledInternal() const
+{
+        return KAccelBase::isEnabled() &amp;&amp; !m_blocked;
+}
+
 bool KGlobalAccelPrivate::emitSignal( Signal )
 {
 	return false;
@@ -216,13 +252,11 @@
 void KGlobalAccelPrivate::x11MappingNotify()
 {
 	kdDebug(125) &lt;&lt; &quot;KGlobalAccelPrivate::x11MappingNotify()&quot; &lt;&lt; endl;
-	if( m_bEnabled ) {
-		// Maybe the X modifier map has been changed.
-		KKeyServer::initializeMods();
-		calculateGrabMasks();
-		// Do new XGrabKey()s.
-		updateConnections();
-	}
+	// Maybe the X modifier map has been changed.
+	KKeyServer::initializeMods();
+	calculateGrabMasks();
+	// Do new XGrabKey()s.
+	updateConnections();
 }
 
 bool KGlobalAccelPrivate::x11KeyPress( const XEvent *pEvent )
@@ -233,7 +267,7 @@
                 XFlush( qt_xdisplay()); // avoid X(?) bug
         }
 
-	if( !m_bEnabled )
+	if( !isEnabledInternal())
 		return false;
 
 	CodeMod codemod;
--- branches/KDE/3.5/kdelibs/kdecore/kglobalaccel_x11.h #442074:442075
@@ -93,9 +93,16 @@
 	void x11MappingNotify();
 	bool x11KeyPress( const XEvent *pEvent );
 	void activate( KAccelAction* pAction, const KKeySequence&amp; seq );
+        virtual bool isEnabledInternal() const;
 
+        static void blockShortcuts( bool block );
+        void disableBlocking( bool disable );
+
  protected slots:
 	void slotActivated( int iAction );
+ private:
+        bool m_blocked;
+        bool m_blockingDisabled;
 };
 
 #endif // _KGLOBALACCEL_X11_H
--- branches/KDE/3.5/kdelibs/kdecore/kipc.h #442074:442075
@@ -56,6 +56,7 @@
     enum Message { PaletteChanged=0, FontChanged, StyleChanged,
                    BackgroundChanged, SettingsChanged, IconChanged, ToolbarStyleChanged,
                    ClipboardConfigChanged, /// @since 3.1
+                   BlockShortcuts, /// @since 3.5
                    UserMessage=32 };
 
     /**
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>363292</commentid>
    <comment_count>3</comment_count>
    <who name="Mircea Bardac">contact</who>
    <bug_when>2005-08-06 23:43:23 +0000</bug_when>
    <thetext>Maybe this could somehow help: http://bugs.kde.org/show_bug.cgi?id=58672
Just a thought.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>363395</commentid>
    <comment_count>4</comment_count>
    <who name="Mircea Bardac">contact</who>
    <bug_when>2005-08-07 09:52:41 +0000</bug_when>
    <thetext>Rephrasing of my last comment:
Maybe this commit (or parts of it) could also (somehow) help: http://bugs.kde.org/show_bug.cgi?id=58672 </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>363797</commentid>
    <comment_count>5</comment_count>
    <who name="Lubos Lunak">l.lunak</who>
    <bug_when>2005-08-08 15:43:11 +0000</bug_when>
    <thetext>Not really, that&apos;s a different issue.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>399149</commentid>
    <comment_count>6</comment_count>
    <who name="Lubos Lunak">l.lunak</who>
    <bug_when>2005-12-16 16:37:04 +0000</bug_when>
    <thetext>*** Bug 79966 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>419159</commentid>
    <comment_count>7</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2006-03-04 15:23:58 +0000</bug_when>
    <thetext>See bug #123058 which seems to be a consquence of this feature.
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>