mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-20 08:51:24 +00:00
Fix #56965 - make konqy preloading/reusing multihead aware.
svn path=/trunk/kdebase/konqueror/; revision=226710
This commit is contained in:
parent
27e51dbbd6
commit
fc8df528db
|
@ -209,8 +209,10 @@ void KonquerorIface::comboCleared( QCString objId )
|
|||
QString::null, objId );
|
||||
}
|
||||
|
||||
bool KonquerorIface::processCanBeReused()
|
||||
bool KonquerorIface::processCanBeReused( int screen )
|
||||
{
|
||||
if( qt_xscreen() != screen )
|
||||
return false; // this instance run on different screen, and Qt apps can't migrate
|
||||
if( KonqMainWindow::isPreloaded())
|
||||
return false; // will be handled by preloading related code instead
|
||||
QPtrList<KonqMainWindow>* windows = KonqMainWindow::mainWindowList();
|
||||
|
|
|
@ -166,7 +166,7 @@ k_dcop:
|
|||
* Used by kfmclient when the 'minimize memory usage' setting is set
|
||||
* to find out if this konqueror can be used.
|
||||
*/
|
||||
bool processCanBeReused();
|
||||
bool processCanBeReused( int screen );
|
||||
|
||||
/**
|
||||
* Called from konqy_preloader to terminate this Konqueror instance,
|
||||
|
|
|
@ -216,6 +216,21 @@ static bool startNewKonqueror( QString url, QString mimetype, const QString& pro
|
|||
return serv == NULL || !allowed_parts.contains( serv->desktopEntryName() + QString::fromLatin1(".desktop") );
|
||||
}
|
||||
|
||||
static int currentScreen()
|
||||
{
|
||||
if( qt_xdisplay() != NULL )
|
||||
return qt_xscreen();
|
||||
// case when there's no KApplication instance
|
||||
const char* env = getenv( "DISPLAY" );
|
||||
if( env == NULL )
|
||||
return 0;
|
||||
const char* dotpos = strrchr( env, '.' );
|
||||
const char* colonpos = strrchr( env, ':' );
|
||||
if( dotpos != NULL && colonpos != NULL && dotpos > colonpos )
|
||||
return atoi( dotpos + 1 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// when reusing a preloaded konqy, make sure your always use a DCOP call which opens a profile !
|
||||
static QCString getPreloadedKonqy()
|
||||
{
|
||||
|
@ -225,7 +240,7 @@ static QCString getPreloadedKonqy()
|
|||
return "";
|
||||
DCOPRef ref( "kded", "konqy_preloader" );
|
||||
QCString ret;
|
||||
if( ref.callExt( "getPreloadedKonqy", DCOPRef::NoEventLoop, 3000 ).get( ret ))
|
||||
if( ref.callExt( "getPreloadedKonqy", DCOPRef::NoEventLoop, 3000, currentScreen()).get( ret ))
|
||||
return ret;
|
||||
return QCString();
|
||||
}
|
||||
|
@ -240,8 +255,10 @@ static QCString konqyToReuse( const QString& url, const QString& mimetype, const
|
|||
return "";
|
||||
QCString appObj;
|
||||
QByteArray data;
|
||||
QDataStream str( data, IO_WriteOnly );
|
||||
str << currentScreen();
|
||||
if( !KApplication::dcopClient()->findObject( "konqueror*", "KonquerorIface",
|
||||
"processCanBeReused()", data, ret, appObj, false, 3000 ) )
|
||||
"processCanBeReused( int )", data, ret, appObj, false, 3000 ) )
|
||||
return "";
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,8 @@ extern "C" int kdemain( int argc, char **argv )
|
|||
if( app.config()->readNumEntry( "MaxPreloadCount", 1 ) > 0 )
|
||||
{
|
||||
DCOPRef ref( "kded", "konqy_preloader" );
|
||||
if( !ref.callExt( "registerPreloadedKonqy", DCOPRef::NoEventLoop, 5000, app.dcopClient()->appId()))
|
||||
if( !ref.callExt( "registerPreloadedKonqy", DCOPRef::NoEventLoop, 5000,
|
||||
app.dcopClient()->appId(), qt_xscreen()))
|
||||
return 0; // too many preloaded or failed
|
||||
KonqMainWindow* win = new KonqMainWindow( KURL(), false ); // prepare an empty window too
|
||||
// KonqMainWindow ctor sets always the preloaded flag to false, so create the window before this
|
||||
|
|
|
@ -4672,7 +4672,8 @@ bool KonqMainWindow::stayPreloaded()
|
|||
return false;
|
||||
}
|
||||
DCOPRef ref( "kded", "konqy_preloader" );
|
||||
if( !ref.callExt( "registerPreloadedKonqy", DCOPRef::NoEventLoop, 5000, kapp->dcopClient()->appId()))
|
||||
if( !ref.callExt( "registerPreloadedKonqy", DCOPRef::NoEventLoop, 5000,
|
||||
kapp->dcopClient()->appId(), qt_xscreen()))
|
||||
{
|
||||
kapp->deref();
|
||||
return false;
|
||||
|
|
|
@ -42,24 +42,33 @@ KonqyPreloader::~KonqyPreloader()
|
|||
updateCount();
|
||||
}
|
||||
|
||||
bool KonqyPreloader::registerPreloadedKonqy( QCString id )
|
||||
bool KonqyPreloader::registerPreloadedKonqy( QCString id, int screen )
|
||||
{
|
||||
if( instances.count() >= max_count )
|
||||
return false;
|
||||
instances.append( KonqyData( id ));
|
||||
instances.append( KonqyData( id, screen ));
|
||||
return true;
|
||||
}
|
||||
|
||||
QCString KonqyPreloader::getPreloadedKonqy()
|
||||
QCString KonqyPreloader::getPreloadedKonqy( int screen )
|
||||
{
|
||||
if( instances.count() == 0 )
|
||||
return "";
|
||||
KonqyData konqy = instances.first();
|
||||
instances.pop_front();
|
||||
check_always_preloaded_timer.start( 5000, true );
|
||||
return konqy.id;
|
||||
for( InstancesList::Iterator it = instances.begin();
|
||||
it != instances.end();
|
||||
++it )
|
||||
{
|
||||
if( (*it).screen == screen )
|
||||
{
|
||||
QCString ret = (*it).id;
|
||||
instances.remove( it );
|
||||
check_always_preloaded_timer.start( 5000, true );
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
void KonqyPreloader::unregisterPreloadedKonqy( QCString id_P )
|
||||
{
|
||||
for( InstancesList::Iterator it = instances.begin();
|
||||
|
|
|
@ -32,8 +32,8 @@ class KonqyPreloader
|
|||
KonqyPreloader( const QCString& obj );
|
||||
virtual ~KonqyPreloader();
|
||||
k_dcop:
|
||||
bool registerPreloadedKonqy( QCString id );
|
||||
QCString getPreloadedKonqy();
|
||||
bool registerPreloadedKonqy( QCString id, int screen );
|
||||
QCString getPreloadedKonqy( int screen );
|
||||
ASYNC unregisterPreloadedKonqy( QCString id );
|
||||
void reconfigure();
|
||||
void unloadAllPreloaded();
|
||||
|
@ -47,9 +47,10 @@ class KonqyPreloader
|
|||
struct KonqyData
|
||||
{
|
||||
KonqyData() {}; // for QValueList
|
||||
KonqyData( const QCString& id_P )
|
||||
: id( id_P ) {}
|
||||
KonqyData( const QCString& id_P, int screen_P )
|
||||
: id( id_P ), screen( screen_P ) {}
|
||||
QCString id;
|
||||
int screen;
|
||||
};
|
||||
typedef QValueList< KonqyData > InstancesList;
|
||||
InstancesList instances;
|
||||
|
|
Loading…
Reference in a new issue