[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Re: Simple applet makes plasma take 100% CPU
From: Loïc Marteau <loic.marteau () gmail ! com>
Date: 2008-05-24 19:33:32
Message-ID: 48386D8C.70105 () gmail ! com
[Download RAW message or body]
Anne-Marie Mahfouf wrote:
> On Friday 23 May 2008 07:14:05 pm Petri Damstén wrote:
>
>> Hi,
>>
>> I have a problem with minimize-all and paste applets. If they are added to
>> panel, plasma takes lots of CPU time (70%-100%). I attached minimal test
>> applet that does the same. Any ideas what might be wrong?
>>
>> Petri
>>
>
> This test does not reproduce it for me :(
>
> Anne-Marie
>
> _______________________________________________
> Panel-devel mailing list
> Panel-devel@kde.org
> https://mail.kde.org/mailman/listinfo/panel-devel
>
Hi,
Me too, i can't reproduce the 100% cpu with the test you give.
However i have rewrite showdesktop (for personal test) by using the same
plasmoid stuff's code than showdashboard and the 100 % CPU does not
appear anymore.
So perhaps you can rewrite a test case by using the same base code of
the actual version of showdesktop ?!
I join to you the code i have copy/paste from showdashboard to my
version of showdesktop so you can compare it.
Cheers
["showdesktop.cpp" (text/x-c++src)]
/*
* Copyright 2008 Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "showdesktop.h"
#include <plasma/containment.h>
#include <KIcon>
#include <kwindowsystem.h>
#include <netwm.h>
#include <KIconLoader>
#include <QX11Info>
#include <QTimer>
#include <QGraphicsLinearLayout>
ShowDesktop::ShowDesktop(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args), m_wm2ShowingDesktop(false)
//#ifndef MINIMIZE_ONLY
, m_down(false), m_goingDown(false)
//#endif
{
}
ShowDesktop::~ShowDesktop()
{
}
void ShowDesktop::init()
{
setBackgroundHints(NoBackground);
m_icon = new Plasma::Icon(KIcon("user-desktop"),QString(),this);
connect(m_icon, SIGNAL(clicked()), this, SLOT(pressed()));
NETRootInfo info(QX11Info::display(), NET::Supported);
m_wm2ShowingDesktop = info.isSupported(NET::WM2ShowingDesktop);
//#ifndef MINIMIZE_ONLY
if (m_wm2ShowingDesktop) {
connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(reset()));
}
//#endif
}
void ShowDesktop::constraintsEvent(Plasma::Constraints constraints)
{
setBackgroundHints(NoBackground);
if (constraints & Plasma::FormFactorConstraint) {
if (formFactor() == Plasma::Planar ||
formFactor() == Plasma::MediaCenter) {
m_icon->setText(i18n("Show Desktop"));
setMinimumSize(m_icon->sizeFromIconSize(IconSize(KIconLoader::Desktop)));
} else {
m_icon->setText(0);
m_icon->setInfoText(0);
setMinimumSize(m_icon->sizeFromIconSize(IconSize(KIconLoader::Panel)));
}
}
if (constraints & Plasma::SizeConstraint && m_icon) {
resize(size());
m_icon->resize(size());
}
updateGeometry();
}
Qt::Orientations ShowDesktop::expandingDirections() const
{
return Qt::Vertical;
}
void ShowDesktop::pressed()
{
if (m_wm2ShowingDesktop) {
NETRootInfo info(QX11Info::display(), 0);
//#ifndef MINIMIZE_ONLY
m_down = !m_down;
m_goingDown = m_down;
info.setShowingDesktop(m_down);
// NETRootInfo::showingDesktop() returns always false
QTimer::singleShot(500, this, SLOT(delay()));
//#else
//info.setShowingDesktop(m_down);
//#endif
}
}
//#ifndef MINIMIZE_ONLY
void ShowDesktop::delay()
{
m_goingDown = false;
}
void ShowDesktop::reset()
{
if (!m_goingDown) {
m_down = false;
}
}
//#endif
#include "showdesktop.moc"
["showdesktop.h" (text/x-chdr)]
/*
* Copyright 2008 Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHOWDESKTOP_HEADER
#define SHOWDESKTOP_HEADER
//#define MINIMIZE_ONLY
#include <Plasma/Applet>
#include <plasma/widgets/icon.h>
class ShowDesktop : public Plasma::Applet
{
Q_OBJECT
public:
ShowDesktop(QObject *parent, const QVariantList &args);
~ShowDesktop();
virtual void init();
Qt::Orientations expandingDirections() const;
public slots:
void pressed();
//#ifndef MINIMIZE_ONLY
void reset();
void delay();
//#endif
protected:
void constraintsEvent(Plasma::Constraints constraints);
private:
Plasma::Icon * m_icon;
bool m_wm2ShowingDesktop;
//#ifndef MINIMIZE_ONLY
bool m_down;
bool m_goingDown;
//#endif
};
K_EXPORT_PLASMA_APPLET(showdesktop, ShowDesktop)
#endif
["CMakeLists.txt" (text/plain)]
project(plasma-showdesktop)
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
find_package(Plasma REQUIRED)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES}
)
set(showdesktop_SRCS
showdesktop.cpp
)
kde4_add_plugin(plasma_applet_showdesktop ${showdesktop_SRCS})
target_link_libraries(plasma_applet_showdesktop
${KDE4_KDEUI_LIBS} ${PLASMA_LIBS} )
install(TARGETS plasma_applet_showdesktop DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plasma-applet-showdesktop.desktop
DESTINATION ${SERVICES_INSTALL_DIR})
_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic