Question

I have written a small program to switch between compositors (xfwm4, dcompmgr, cairo-compmgr) to help with video tearing that can be experienced with nVidia. It creates an icon in system tray that has its actions. The problem is that the icon does not always show up when I run my program and it disappears after I switch to different compositor. I've captured it on a video that can be seen here: https://www.youtube.com/watch?v=31qqOiaOdfw

I'm using: Manjaro Linux 64bit with Xfce
QtCreator v.2.8.0 with Qt 5.1

Could someone please help me with this?

compSwitcher.cpp

#include "compswitcher.h"
#include "ui_compswitcher.h"
#include <QMenu>
#include <QCloseEvent>
#include <QDebug>

compSwitcher::compSwitcher(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::compSwitcher)
{
    ui->setupUi(this);

    createActions();
    createIcon();
    setIcon();
    qDebug() << "Before trayIcon->show()\n";
    trayIcon->show();
    qDebug() << "After trayIcon->show()";

}

compSwitcher::~compSwitcher()
{
    delete ui;
    delete trayIcon;
    delete menu;
    delete xfwm4;
    delete close;
    delete dcompmgr;
}

void compSwitcher::createActions()
{
    close = new QAction(tr("&Quit"),this);
    QObject::connect(close, SIGNAL(triggered()), this, SLOT(endProgram()));

    xfwm4 = new QAction(tr("&xfwm4"), this);
    connect(xfwm4, SIGNAL(triggered()), this, SLOT(setXfwm4()));

    dcompmgr = new QAction(tr("&dcompmgr"), this);
    connect(dcompmgr, SIGNAL(triggered()), this, SLOT(setDcompmgr()));

    cairo = new QAction(tr("&cairo-compmgr"), this);
    connect(cairo,SIGNAL(triggered()), this, SLOT(setCairo()));
}

void compSwitcher::createIcon()
{
    menu = new QMenu(this);
    menu->addAction(xfwm4);
    menu->addAction(dcompmgr);
    menu->addAction(cairo);
    menu->addSeparator();
    menu->addAction(close);

    trayIcon = new QSystemTrayIcon(this);
    trayIcon->setContextMenu(menu);

}

void compSwitcher::setIcon()
{
    QIcon ikona(":/new/prefix1/kuba_fan1.png");
    trayIcon->setIcon(QIcon(ikona));

}

void compSwitcher::setXfwm4()
{
    system("/home/dec/Programowanie/qt/compSwitcher/skrypty/xfwm4true.sh");
}

void compSwitcher::setDcompmgr()
{
    system("/home/dec/Programowanie/qt/compSwitcher/skrypty/dcompmgr.sh");
}

void compSwitcher::setCairo()
{
    system("/home/dec/Programowanie/qt/compSwitcher/skrypty/cairo.sh");

}
Was it helpful?

Solution

I had a similar problem, in my case the tray never shows.

I also have: Manjaro Linux 64bit with Xfce

I solved it by changing the panel to tint2. I think it's a problem of xfce-panel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top