[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    PATCH: Fix handling of RMB on non-active views
From:       David Faure <david () mandrakesoft ! com>
Date:       2002-03-19 21:01:41
[Download RAW message or body]

The attached patch fixes the various problems with RMB on non-active views
(coolo found bug #39428 about that).

There are two cases:
* the non-active view is a passive one (e.g. the sidebar) :
 in that case we want to set it as the 'currentview' temporarily,
 simply setting m_currentView. This is what we've always been doing.

* the non-active view can be activated (e.g. a dir view). Let's activate it for real then
(KParts gets the mousepress event and makes the part active, but m_currentView
was wrong after closing the popup). So now m_currentView remains set to the
new active part.

The above can be simply seen in these lines:
+      if ( currentView->isPassiveMode() )
+          // Make this view active only temporarily (because it's passive)
+          m_currentView = currentView;
+      else
+          m_pViewManager->setActivePart( currentView->part() );

The patch also fixes the case where a konqrun is running - the "return" statement
was happening after m_currentView was set, so it would be left to a wrong value in that case,
I suppose.

Ouch the patch also contains an approved speedup fix I forgot to commit...

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://people.mandrakesoft.com/~david/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today

["konq_mainwindow.cc.dif" (text/x-diff)]

Index: konq_mainwindow.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_mainwindow.cc,v
retrieving revision 1.969
diff -u -p -b -r1.969 konq_mainwindow.cc
--- konq_mainwindow.cc	2002/03/18 10:22:50	1.969
+++ konq_mainwindow.cc	2002/03/19 20:51:09
@@ -33,7 +33,7 @@
 #include <konq_operations.h>
 #include <konqbookmarkmanager.h>
 
-
+#include <config.h>
 #include <pwd.h>
 // we define STRICT_ANSI to get rid of some warnings in glibc
 #ifndef __STRICT_ANSI__
@@ -47,7 +47,9 @@
 #endif
 #include <assert.h>
 #include <stdlib.h>
-#include <unistd.h>
+#include <klargefile.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #include <qclipboard.h>
 #include <qmetaobject.h>
@@ -399,6 +401,15 @@ void KonqMainWindow::openURL( KonqView *
   else // startup with argument
     setLocationBarURL( url.prettyURL() );
 
+  // Fast mode for local files: do the stat ourselves instead of letting KRun do it.
+  if ( url.isLocalFile() )
+  {
+    QCString _path( QFile::encodeName(url.path()));
+    KDE_struct_stat buff;
+    if ( KDE_stat( _path.data(), &buff ) != -1 )
+        serviceType = KMimeType::findByURL( url, buff.st_mode )->name();
+  }
+
   kdDebug(1202) << QString("trying openView for %1 (servicetype \
%2)").arg(url.url()).arg(serviceType) << endl;  if ( ( !serviceType.isEmpty() && \
serviceType != "application/octet-stream") || url.protocol() == "about" )  {
@@ -3251,21 +3262,30 @@ void KonqMainWindow::slotPopupMenu( KXML
 {
   KonqView * m_oldView = m_currentView;
 
-  // Make this view active temporarily, if not the current one (e.g. because it's \
                passive)
-  m_currentView = childView( static_cast<KParts::ReadOnlyPart *>( sender()->parent() \
                ) );
-
+  KonqView * currentView = childView( static_cast<KParts::ReadOnlyPart *>( \
sender()->parent() ) );  // the page is currently loading something -> Don't enter a \
local event loop  // by launching a popupmenu!
-  if ( m_currentView->run() != 0 )
+  if ( currentView->run() != 0 )
       return;
 
-  if ( m_oldView && m_oldView != m_currentView )
+  //kdDebug() << "KonqMainWindow::slotPopupMenu m_oldView=" << m_oldView << " new \
currentView=" << currentView << " passive:" << currentView->isPassiveMode() << endl; \
+ +  if ( m_oldView != currentView )
   {
+      if ( currentView->isPassiveMode() )
+          // Make this view active only temporarily (because it's passive)
+          m_currentView = currentView;
+      else
+          m_pViewManager->setActivePart( currentView->part() );
+
+      if ( m_oldView )
+      {
     if ( m_oldView->browserExtension() )
       disconnectExtension( m_oldView->browserExtension() );
     if ( m_currentView->browserExtension() )
       connectExtension( m_currentView->browserExtension() );
   }
+  }
 
   kdDebug(1202) << "KonqMainWindow::slotPopupMenu( " << client << "...)" << " \
current view=" << m_currentView << " " << m_currentView->part()->className() << endl; \
 @@ -3358,9 +3378,13 @@ void KonqMainWindow::slotPopupMenu( KXML
       disconnectExtension( m_currentView->browserExtension() );
     if ( m_oldView->browserExtension() )
       connectExtension( m_oldView->browserExtension() );
-  }
-
+    // Restore current view if current is passive
+    if ( currentView->isPassiveMode() ) {
+        //kdDebug() << "KonqMainWindow::slotPopupMenu restoring active view " << \
m_oldView << endl;  m_currentView = m_oldView;
+        m_oldView->part()->widget()->setFocus();
+    }
+  }
 }
 
 void KonqMainWindow::slotOpenEmbedded()



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic