Qt World Summit: Register Today!

debian tray doesn't close Qmenu properly

  • There is odd behavior in debian when I close context menu by clicking on desktop but not with Esc key
    I expect menu will open next time I click right button on tray, but it only hides notification area

    I made logs to catch all possible mouse activities and disovered that this code in qsystemtrayicon_x11.cpp does not emit QSystemTrayIcon::Context in case when popup was hiden by clicking on desktop

    void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev)
        QPoint globalPos = ev->globalPos();
        if (ev->button() == Qt::RightButton && q->contextMenu())
    #endif // QT_NO_CONTEXTMENU
        if (QBalloonTip::isBalloonVisible()) {
            emit q->messageClicked();
        if (ev->button() == Qt::LeftButton)
            emit q->activated(QSystemTrayIcon::Trigger);
        else if (ev->button() == Qt::RightButton)
            emit q->activated(QSystemTrayIcon::Context);
        else if (ev->button() == Qt::MidButton)
            emit q->activated(QSystemTrayIcon::MiddleClick);

    there is no problem in any other desktop environments unless it is gnome shell ( in my case 3.14 ) with notification area

  • Lifetime Qt Champion


    Which version of Debian is it ? Are you using the Qt version that comes with the distribution ?

  • Moderators

    (... continues from @SGaist's ...)
    Which window manager and desktop environment?

  • @SGaist debian 8 gnome shell 3.14
    project is duilt on sandbox debian 7 with Qt 5.8

  • Continuing investigation
    I made watcher to check events from QSystemTrayIconSys and as I can see the Tray does not produce any when I click right button second time.
    So it works half the time as I said early.
    I have to note that it doesn't produce a bunch of events as it happens in other distros, only 3 at one click


    Next time I click tray none of them appear in my log
    I checked how this code works on Mint ( or whatever except debian ) and there are a huge number of events whenever I click or just hover the area of tray icon

    To get a pointer on QSystemTrayIconSys and set up filter on it

    #include <QtWidgets/private/qsystemtrayicon_p.h>
    class MyTray : public QSystemTrayIcon
         QSystemTrayIconPrivate* d() { return reinterpret_cast<QSystemTrayIconPrivate *>(qGetPtrHelper(d_ptr)); }
    inline QSystemTrayIconPrivate* p_tray_ptr(QSystemTrayIcon* t)
         return static_cast<MyTray*>(t)->d();
    QSystemTrayIconPrivate* trr = p_tray_ptr( trayIcon );
         if ( trr )
              QSystemTrayIconSys * s = trr->sys;
              if ( s )
                   reinterpret_cast<QWidget*>(s)->installEventFilter( this );

    and the filter itself

    bool Window::eventFilter(QObject *watched, QEvent *event)
         if ( watched != reinterpret_cast<QWidget*>(p_tray_ptr( trayIcon )->sys) )
              return false;
         qDebug() << event->type();
         return false;

    So the question is what blocks those operation above tray in debian.

  • Lifetime Qt Champion

    Are you using the same desktop environment with each distribution your tried ?

  • @SGaist said in debian tray doesn't close Qmenu properly:

    Are you using the same desktop environment with each distribution your tried ?

    Nope. Mint - MATE; Astra - Fly DE; debian - gnome;

  • Lifetime Qt Champion

    Then it starts to get pretty hard to find whether it's a Gnome specific bug or a Debian + Gnome specific bug or a xcb backend problem.

  • @SGaist also I checked it on debian 9 gnome 3.22.2 and there is same problem

  • I have reported it to bugreprot.qt

  • Lifetime Qt Champion

    Thanks for the link

Log in to reply