~ubuntu-branches/ubuntu/feisty/psi/feisty

« back to all changes in this revision

Viewing changes to cutestuff/trayicon/trayicon_x11.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2005-09-14 16:33:49 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050914163349-3zacov4afysz5cw5
Tags: 0.9.3-2ubuntu1
* Sync with debian
* Applied patch to psi.desktop to start psi without gpg-agent use (known
  issue)
* Updated README.Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
#include "trayicon.h"
 
23
#include "psiapplication.h"
23
24
 
24
25
#include<qapplication.h>
25
26
#include<qimage.h>
225
226
{
226
227
public:
227
228
        TrayIconFreeDesktop(TrayIcon *object, const QPixmap &pm);
 
229
protected:
 
230
        virtual bool x11Event(XEvent*);
228
231
};
229
232
 
230
233
TrayIconFreeDesktop::TrayIconFreeDesktop(TrayIcon *object, const QPixmap &pm)
239
242
        Screen *screen = XDefaultScreenOfDisplay(dsp); // get the screen
240
243
        int screen_id = XScreenNumberOfScreen(screen); // and it's number
241
244
 
 
245
        // tell X that we want to see ClientMessage and Deleted events, which
 
246
        // are picked up by QApplication::x11EventFilter
 
247
        Window root_window = QApplication::desktop()->winId();
 
248
        XWindowAttributes attr;
 
249
 
 
250
        XGetWindowAttributes(dsp, root_window, &attr);
 
251
        XSelectInput(dsp, root_window, attr.your_event_mask | StructureNotifyMask);
 
252
 
242
253
        char buf[32];
243
254
        snprintf(buf, sizeof(buf), "_NET_SYSTEM_TRAY_S%d", screen_id);
244
255
        Atom selection_atom = XInternAtom(dsp, buf, false);
251
262
 
252
263
        if ( manager_window != None )
253
264
                send_message(dsp, manager_window, SYSTEM_TRAY_REQUEST_DOCK, winId(), 0, 0);
 
265
        else
 
266
        {
 
267
                object->hide();
 
268
                return;
 
269
        }
254
270
 
255
271
        // some KDE mumbo-jumbo... why is it there? anybody?
256
272
        Atom kwm_dockwindow_atom = XInternAtom(dsp, "KWM_DOCKWINDOW", false);
263
279
        setPixmap(pm);
264
280
}
265
281
 
 
282
bool TrayIconFreeDesktop::x11Event(XEvent *ev)
 
283
{
 
284
        switch(ev->type)
 
285
        {
 
286
                case ReparentNotify:
 
287
                        show();
 
288
 
 
289
        }
 
290
        return false;
 
291
}
 
292
 
266
293
//----------------------------------------------------------------------------
267
294
// TrayIconWindowMaker
268
295
//----------------------------------------------------------------------------
345
372
                d = (TrayIconPrivate *)(new TrayIconFreeDesktop(this, pm));
346
373
 
347
374
        sysUpdateToolTip();
348
 
        d->show();
 
375
 
 
376
        if ( v_isWMDock )
 
377
                d->show();
349
378
}
350
379
 
351
380
void TrayIcon::sysRemove()