You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.5 KiB
78 lines
2.5 KiB
/******************************************************************** |
|
KWin - the KDE window manager |
|
This file is part of the KDE project. |
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org> |
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> |
|
|
|
This program is free software; you can redistribute it and/or modify |
|
it under the terms of the GNU General Public License as published by |
|
the Free Software Foundation; either version 2 of the License, or |
|
(at your option) any later version. |
|
|
|
This program is distributed in the hope that it will be useful, |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
GNU General Public License for more details. |
|
|
|
You should have received a copy of the GNU General Public License |
|
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
*********************************************************************/ |
|
|
|
#include "notifications.h" |
|
#include <knotification.h> |
|
|
|
#include "client.h" |
|
|
|
namespace KWin |
|
{ |
|
|
|
static bool forgetIt = false; |
|
QList< Notify::EventData > Notify::pending_events; |
|
|
|
bool Notify::raise(Event e, const QString& message, Client* c) |
|
{ |
|
if (forgetIt) |
|
return false; // no connection was possible, don't try each time |
|
|
|
QString event; |
|
KNotification::NotificationFlags flags = KNotification::CloseOnTimeout; |
|
switch(e) { |
|
case CompositingSuspendedDbus: |
|
event = "compositingsuspendeddbus"; |
|
break; |
|
default: |
|
break; |
|
} |
|
if (event.isNull()) |
|
return false; |
|
|
|
// 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; |
|
data.flags = flags; |
|
pending_events.append(data); |
|
return true; |
|
} |
|
|
|
|
|
return KNotification::event(event, message, QPixmap(), NULL /* TODO c ? c->window() : 0*/, flags); |
|
} |
|
|
|
void Notify::sendPendingEvents() |
|
{ |
|
while (!pending_events.isEmpty()) { |
|
EventData data = pending_events.first(); |
|
pending_events.pop_front(); |
|
if (!forgetIt) |
|
KNotification::event(data.event, data.message, QPixmap(), NULL /* TODO data.window*/, data.flags); |
|
} |
|
} |
|
|
|
} // namespace
|
|
|