1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *********************************************************************/
22 #include "notifications.h"
23 #include <knotification.h>
30 static bool forgetIt
= false;
31 QList
< Notify::EventData
> Notify::pending_events
;
33 bool Notify::raise( Event e
, const QString
& message
, Client
* c
)
36 return false; // no connection was possible, don't try each time
39 KNotification::NotificationFlags flags
= KNotification::CloseOnTimeout
;
61 event
= "on_all_desktops";
63 case NotOnAllDesktops
:
64 event
= "not_on_all_desktops";
76 event
= "transdelete";
91 event
= "resizestart";
96 case DemandAttentionCurrent
:
97 event
= "demandsattentioncurrent";
99 case DemandAttentionOther
:
100 event
= "demandsattentionother";
102 case CompositingSlow
:
103 event
= "compositingslow";
104 flags
= KNotification::Persistent
;
107 if ((e
> DesktopChange
) && (e
<= DesktopChange
+20))
109 event
= QString("desktop%1").arg(e
-DesktopChange
);
113 if ( event
.isNull() )
116 // There may be a deadlock if KNotify event is sent while KWin has X grabbed.
117 // If KNotify is not running, KLauncher may do X requests (startup notification, whatever)
118 // that will block it. And KNotifyClient waits for the launch to succeed, which means
119 // KLauncher waits for X and KWin waits for KLauncher. So postpone events in such case.
120 if( grabbedXServer())
124 data
.message
= message
;
125 data
.window
= c
? c
->window() : 0;
127 pending_events
.append( data
);
132 return KNotification::event( event
, message
, QPixmap(), NULL
/* TODO c ? c->window() : 0*/, flags
);
135 void Notify::sendPendingEvents()
137 while( !pending_events
.isEmpty())
139 EventData data
= pending_events
.first();
140 pending_events
.pop_front();
142 KNotification::event( data
.event
, data
.message
, QPixmap(), NULL
/* TODO data.window*/, data
.flags
);