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 QString
Notify::eventToName( Event e
)
54 event
= "on_all_desktops";
56 case NotOnAllDesktops
:
57 event
= "not_on_all_desktops";
69 event
= "transdelete";
84 event
= "resizestart";
89 case DemandAttentionCurrent
:
90 event
= "demandsattentioncurrent";
92 case DemandAttentionOther
:
93 event
= "demandsattentionother";
96 if ((e
> DesktopChange
) && (e
<= DesktopChange
+20))
98 event
= QString("desktop%1").arg(e
-DesktopChange
);
105 static bool forgetIt
= false;
106 QList
< Notify::EventData
> Notify::pending_events
;
108 bool Notify::raise( Event e
, const QString
& message
, Client
* c
)
111 return false; // no connection was possible, don't try each time
113 QString event
= eventToName( e
);
114 if ( event
.isNull() )
117 // There may be a deadlock if KNotify event is sent while KWin has X grabbed.
118 // If KNotify is not running, KLauncher may do X requests (startup notification, whatever)
119 // that will block it. And KNotifyClient waits for the launch to succeed, which means
120 // KLauncher waits for X and KWin waits for KLauncher. So postpone events in such case.
121 if( grabbedXServer())
125 data
.message
= message
;
126 data
.window
= c
? c
->window() : 0;
127 pending_events
.append( data
);
132 return KNotification::event( event
, message
/*, QPixmap() , c ? c->window() : 0*/ ); //FIXME get the widget ?
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() , data.window */ );