svn path=/trunk/KDE/kdebase/workspace/; revision=468193
This commit is contained in:
Luboš Luňák 2005-10-07 12:00:29 +00:00
parent e20f2bd6b2
commit 3f14e3ccd9
4 changed files with 49 additions and 2 deletions

View file

@ -92,9 +92,11 @@ QString Notify::eventToName( Event e )
return event;
}
static bool forgetIt = FALSE;
QList< Notify::EventData > Notify::pending_events;
bool Notify::raise( Event e, const QString& message, Client* c )
{
static bool forgetIt = FALSE;
if ( forgetIt )
return false; // no connection was possible, don't try each time
@ -102,11 +104,35 @@ bool Notify::raise( Event e, const QString& message, Client* c )
if ( event.isNull() )
return false;
forgetIt= !KNotifyClient::event( c ? c->window() : 0, event, message );
// There may be a deadlock if KNotify event is sent while KWin has X grabbed.
// If KNotify is not running, KLauncher may do X requests (startup notification, whatever)
// that will block it. And KNotifyClient waits for the launch to succeed, which means
// KLauncher waits for X and KWin waits for KLauncher. So postpone events in such case.
if( grabbedXServer())
{
EventData data;
data.event = event;
data.message = message;
data.window = c ? c->window() : 0;
pending_events.append( data );
return true;
}
forgetIt= !KNotifyClient::event( c ? c->window() : 0, event, message );
return !forgetIt;
}
void Notify::sendPendingEvents()
{
while( !pending_events.isEmpty())
{
EventData data = pending_events.first();
pending_events.pop_front();
if( !forgetIt )
forgetIt= !KNotifyClient::event( data.window, data.event, data.message );
}
}
bool Notify::makeDemandAttention( Event e )
{
QString event = eventToName( e );

View file

@ -14,6 +14,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include <stdlib.h>
#include <qstring.h>
#include <qlist.h>
namespace KWinInternal
{
@ -51,8 +52,16 @@ class Notify
static bool raise( Event, const QString& message = QString::null, Client* c = NULL );
static bool makeDemandAttention( Event );
static void sendPendingEvents();
private:
static QString eventToName( Event );
struct EventData
{
QString event;
QString message;
long window;
};
static QList< EventData > pending_events;
};
} // namespace

View file

@ -32,6 +32,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include <stdio.h>
#include "atoms.h"
#include "notifications.h"
#endif
@ -282,8 +283,18 @@ void ungrabXServer()
{
assert( server_grab_count > 0 );
if( --server_grab_count == 0 )
{
XUngrabServer( QX11Info::display());
XFlush( QX11Info::display());
Notify::sendPendingEvents();
}
}
bool grabbedXServer()
{
return server_grab_count > 0;
}
#endif
bool isLocalMachine( const QByteArray& host )

View file

@ -188,6 +188,7 @@ QByteArray getStringProperty(WId w, Atom prop, char separator=0);
void updateXTime();
void grabXServer();
void ungrabXServer();
bool grabbedXServer();
// the docs say it's UrgencyHint, but it's often #defined as XUrgencyHint
#ifndef UrgencyHint