[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    kicker patch
From:       m_elter () t-online ! de (Matthias Elter)
Date:       2000-08-31 9:59:09
[Download RAW message or body]

Hi

Attached is a kicker patch that:

- Works around the DCOP server glitch we tracked down yesterday.
- Gets rid of the delay after moving a container.
- Adds tricks to avoid flicker when loading external applets on startup.
- Fixes a bug that prevented external applets from updating the panel layout.

Please review.
Bye, Matthias

-- 
Matthias Elter
elter@kde.org
me@caldera.de

["kicker.patch" (text/x-c++)]

Index: core/container_applet.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_applet.cpp,v
retrieving revision 1.4
diff -u -3 -p -u -b -r1.4 container_applet.cpp
--- core/container_applet.cpp	2000/08/30 16:09:51	1.4
+++ core/container_applet.cpp	2000/08/31 09:54:50
@@ -49,6 +49,8 @@ AppletContainer::AppletContainer(const A
   , _info(info)
   , _layout(0)
   , _type(KPanelApplet::Normal)
+  , _widthForHeightHint(0)
+  , _heightForWidthHint(0)
 {
   // setup handle
   _handle = new AppletHandle(this);
@@ -217,13 +219,23 @@ void InternalAppletContainer::slotSetOri

 int InternalAppletContainer::widthForHeight(int h)
 {
-  if (!_applet) return h;
+    if (!_applet) {
+	if (_widthForHeightHint > 0)
+	    return _widthForHeightHint + _handle->width();
+	else
+	    return h + _handle->width();
+    }
   return _applet->widthForHeight(h) + _handle->width();
 }

 int InternalAppletContainer::heightForWidth(int w)
 {
-  if (!_applet) return w;
+    if (!_applet) {
+	if (_heightForWidthHint > 0)
+	    return _heightForWidthHint + _handle->height();
+	else
+	    return w + _handle->height();
+    }
   return _applet->heightForWidth(w) + _handle->height();
 }

@@ -247,8 +259,8 @@ void InternalAppletContainer::preference

 ExternalAppletContainer::ExternalAppletContainer( const AppletInfo& info, QWidget \
*parent)  : AppletContainer(info, parent)
-  , DCOPObject(QCString("ExternalAppletContainer_") + \
                kapp->randomString(20).lower().local8Bit())
-  , _isdocked(false)
+, DCOPObject(QCString("ExternalAppletContainer_") + \
kapp->randomString(20).lower().local8Bit()) +, _isdocked(false)
 {
   _deskFile = info.desktopFile();
   _configFile = info.configFile();
@@ -347,7 +359,11 @@ void ExternalAppletContainer::preference

 int ExternalAppletContainer::widthForHeight(int h)
 {
-  if (!_isdocked) return h; // FIXME: return old width
+    int w = h;
+    if (_widthForHeightHint > 0)
+	w = _widthForHeightHint;
+
+    if (!_isdocked) return w;

   DCOPClient* dcop = kapp->dcopClient();

@@ -357,8 +373,6 @@ int ExternalAppletContainer::widthForHei
   QDataStream dataStream( data, IO_WriteOnly );
   dataStream << h;

-  int w = h + _handle->width();
-
   if (dcop->call( _app, "AppletProxy", "widthForHeight(int)", data, replyType, \
replyData ) )  {
       QDataStream reply( replyData, IO_ReadOnly );
@@ -369,7 +383,11 @@ int ExternalAppletContainer::widthForHei

 int ExternalAppletContainer::heightForWidth(int w)
 {
-  if (!_isdocked) return w; // FIMXE: return old height
+    int h = w;
+    if (_heightForWidthHint > 0)
+	h = _heightForWidthHint;
+
+    if (!_isdocked) return h;

   DCOPClient* dcop = kapp->dcopClient();

@@ -379,8 +397,6 @@ int ExternalAppletContainer::heightForWi
   QDataStream dataStream( data, IO_WriteOnly );
   dataStream << w;

-  int h = w + _handle->height();
-
   if (dcop->call( _app, "AppletProxy", "heightForWidth(int)", data, replyType, \
replyData ) )  {
       QDataStream reply( replyData, IO_ReadOnly );
@@ -389,16 +405,21 @@ int ExternalAppletContainer::heightForWi
   return h + _handle->height();
 }

-bool ExternalAppletContainer::process(const QCString &fun, const QByteArray \
&/*data*/, +bool ExternalAppletContainer::process(const QCString &fun, const \
                QByteArray &data,
                                                                           QCString& \
replyType, QByteArray & replyData)  {
-  if ( fun == "dockRequest()" )
+    if ( fun == "dockRequest(int,int)" )
     {
       QDataStream reply( replyData, IO_WriteOnly );
       replyType = "WId";
           reply << _embed->winId();
+
+	    QDataStream sdata( data, IO_ReadOnly );
+	    int actions, type;
+	    sdata >> actions;
+	    sdata >> type;

-      dockRequest(kapp->dcopClient()->senderId());
+	    dockRequest(kapp->dcopClient()->senderId(), actions, type);
       return true;
     }
   else if(fun == "updateLayout()")
@@ -409,32 +430,19 @@ bool ExternalAppletContainer::process(co
   return true;
 }

-void ExternalAppletContainer::dockRequest(QCString app)
+void ExternalAppletContainer::dockRequest(QCString app, int actions, int type)
 {
   _app = app;

-  kdDebug() << "dockRequest(QCString app): " << app << endl;
+    kdDebug() << "ExternalAppletContainer::dockRequest: " << app << endl;

-  DCOPClient* dcop = kapp->dcopClient();
-
   QByteArray data;
   QCString replyType;
   QByteArray replyData;

-  // retrieve RMB menu actions
-  if ( dcop->call ( _app, "AppletProxy", "actions()", data, replyType, replyData ) )
-    {
-      QDataStream reply( replyData, IO_ReadOnly );
-      reply >> _actions;
-    }
-  // retrieve applet type
-  if ( dcop->call ( _app, "AppletProxy", "type()", data, replyType, replyData ) )
-    {
-      QDataStream reply( replyData, IO_ReadOnly );
-      int type;
-          reply >> type;
           _type = static_cast<KPanelApplet::Type>(type);
-    }
+    _actions = actions;
+
   // set orientation
   {
     QByteArray data;
Index: core/container_applet.h
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_applet.h,v
retrieving revision 1.2
diff -u -3 -p -u -b -r1.2 container_applet.h
--- core/container_applet.h	2000/08/11 03:13:53	1.2
+++ core/container_applet.h	2000/08/31 09:54:51
@@ -40,7 +40,7 @@ class AppletContainer : public BaseConta
 {
   Q_OBJECT

- public:
+public:
   AppletContainer(const AppletInfo& info, QWidget* parent = 0);

   bool eventFilter (QObject *, QEvent *);
@@ -52,22 +52,26 @@ class AppletContainer : public BaseConta

   virtual void configure();

+    void setWidthForHeightHint(int w) { _widthForHeightHint = w; }
+    void setHeightForWidthHint(int h) { _heightForWidthHint = h; }
+
 signals:
   void updateLayout();

- protected:
+protected:
   AppletHandle      *_handle;
   AppletInfo         _info;
   QHBox             *_appletframe;
   QBoxLayout        *_layout;
   KPanelApplet::Type _type;
+    int                _widthForHeightHint, _heightForWidthHint;
 };

 class InternalAppletContainer : public AppletContainer
 {
   Q_OBJECT

- public:
+public:
   InternalAppletContainer(const AppletInfo& info, QWidget *parent);
    ~InternalAppletContainer();

@@ -82,11 +86,11 @@ class InternalAppletContainer : public A

   QString appletType() { return "Applet"; }

- public slots:
+public slots:
   void slotSetPopupDirection(Direction d);
   void slotSetOrientation(Orientation o);

- private:
+private:
   QCString      _id;
   QString       _deskFile, _configFile;
   KPanelApplet *_applet;
@@ -97,7 +101,7 @@ class ExternalAppletContainer : public A
 {
   Q_OBJECT

- public:
+public:
   ExternalAppletContainer(const AppletInfo& info, QWidget *parent);
   ~ExternalAppletContainer();

@@ -114,19 +118,18 @@ class ExternalAppletContainer : public A

   bool process(const QCString &fun, const QByteArray &data,
                QCString& replyType, QByteArray &replyData);
-
- public slots:
+public slots:
   void slotSetPopupDirection(Direction d);
   void slotSetOrientation(Orientation o);

- signals:
+signals:
   void embeddedWindowDestroyed();
   void docked(ExternalAppletContainer*);

- protected:
-  void dockRequest(QCString app);
+protected:
+    void dockRequest(QCString app, int actions, int type);

- private:
+private:
   QString   _deskFile, _configFile;
   QXEmbed  *_embed;
   QCString  _app;
Index: core/container_base.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_base.cpp,v
retrieving revision 1.1
diff -u -3 -p -u -b -r1.1 container_base.cpp
--- core/container_base.cpp	2000/08/08 13:13:35	1.1
+++ core/container_base.cpp	2000/08/31 09:54:51
@@ -39,13 +39,7 @@ BaseContainer::BaseContainer(QWidget *pa
   , _aid(QString::null)
   , _opMnu(0)
   , _actions(0)
-{
-  // FIXME: move these to the containerarea
-    //connect(PGlobal::panel, SIGNAL(orientationChanged(Orientation)),
-    //       SLOT(slotSetOrientation(Orientation)));
-    //connect(PGlobal::panel, SIGNAL(popupDirectionChanged(Direction)),
-    //        SLOT(slotSetPopupDirection(Direction)));
-}
+{}

 BaseContainer::~BaseContainer()
 {
Index: core/containerarea.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/containerarea.cpp,v
retrieving revision 1.12
diff -u -3 -p -u -b -r1.12 containerarea.cpp
--- core/containerarea.cpp	2000/08/30 16:09:51	1.12
+++ core/containerarea.cpp	2000/08/31 09:54:58
@@ -156,7 +156,7 @@ void ContainerArea::defaultContainerConf
     saveContainerConfig();
 }

-void ContainerArea::saveContainerConfig()
+void ContainerArea::saveContainerConfig(bool layoutOnly)
 {
     kdDebug() << "ContainerArea::saveContainerConfig()" << endl;

@@ -185,7 +185,16 @@ void ContainerArea::saveContainerConfig(
 	    // write positioning info
 	    config->writeEntry("FreeSpace", QString("%1").arg(a->freeSpace()));
 	
+	    // write size hint
+	    if(a->inherits("AppletContainer")) {
+		if(orientation() == Horizontal)
+		    config->writeEntry("WidthForHeightHint", \
QString("%1").arg(a->widthForHeight(height()))); +		else
+		    config->writeEntry("HeightForWidthHint", \
QString("%1").arg(a->heightForWidth(width()))); +	    }
+	
 	    // let the applet container write custom data fields
+	    if(!layoutOnly)
 	    a->saveConfiguration(a->appletId());
 	}

@@ -241,6 +250,9 @@ void ContainerArea::loadContainerConfig(
 		a = new ExeButtonContainer(group, viewport());
 	    else if (appletId.contains("Applet") > 0)
 		{
+		    int whint = config->readNumEntry("WidthForHeightHint", 0);
+		    int hhint = config->readNumEntry("HeightForWidthHint", 0);
+		
 		    KConfig *config = KGlobal::config();
 		    config->setGroup(group);

@@ -274,6 +286,8 @@ void ContainerArea::loadContainerConfig(
 			}
 		    else
 			a = new InternalAppletContainer(info, viewport());
+		    ((AppletContainer*)a)->setWidthForHeightHint(whint);
+		    ((AppletContainer*)a)->setHeightForWidthHint(hhint);
 		}

 	    if (a) {
@@ -492,7 +506,8 @@ void ContainerArea::addContainer(BaseCon
     if (a->inherits("ExternalAppletContainer"))
 	connect(a, SIGNAL(embeddedWindowDestroyed() ), this,
 		SLOT( embeddedWindowDestroyed()));
-    if (a->inherits("InternalAppletContainer"))
+    if (a->inherits("InternalAppletContainer")
+	|| a->inherits("ExternalAppletContainer"))
 	connect(a, SIGNAL(updateLayout() ), this,
 		SLOT( slotLayoutChildren()));

@@ -529,7 +544,7 @@ void ContainerArea::removeContainer(Base

     updateContainerList();
     layoutChildren();
-    saveContainerConfig();
+    saveContainerConfig(true);
 }

 void ContainerArea::setUniqueId(BaseContainer* a)
@@ -625,8 +640,7 @@ void ContainerArea::stopContainerMove(Ba

     updateContainerList();
     layoutChildren();
-
-    saveContainerConfig();
+    saveContainerConfig(true);
 }

 void ContainerArea::mouseReleaseEvent(QMouseEvent *)
Index: core/containerarea.h
===================================================================
RCS file: /home/kde/kdebase/kicker/core/containerarea.h,v
retrieving revision 1.4
diff -u -3 -p -u -b -r1.4 containerarea.h
--- core/containerarea.h	2000/08/29 09:46:29	1.4
+++ core/containerarea.h	2000/08/31 09:54:58
@@ -98,7 +98,7 @@ public:

   void setupDummyWidget(BaseContainer* a);

-  void saveContainerConfig();
+  void saveContainerConfig(bool layoutOnly = false);
   void loadContainerConfig();
   void defaultContainerConfig();

Index: proxy/appletproxy.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/proxy/appletproxy.cpp,v
retrieving revision 1.3
diff -u -3 -p -u -b -r1.3 appletproxy.cpp
--- proxy/appletproxy.cpp	2000/08/30 16:09:51	1.3
+++ proxy/appletproxy.cpp	2000/08/31 09:55:00
@@ -160,8 +160,16 @@ void AppletProxy::dock(const QCString& c
 	QByteArray data, replyData;
 	QDataStream dataStream( data, IO_WriteOnly );

+	int actions = 0;
+	if(_applet) actions = _applet->actions();
+	dataStream << actions;
+	
+	int type = 0;
+	if (_applet) type = static_cast<int>(_applet->type());
+	dataStream << type;
+	
 	// we use "call" to know whether it was sucessful
-	if ( !dcop->call("kicker", _callbackID, "dockRequest()",
+	if ( !dcop->call("kicker", _callbackID, "dockRequest(int,int)",
 			 data, replyType, replyData ) )
 	    {
 		kdError() << "Failed to dock into the panel." << endl;



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic