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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/shells/mid
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2008-08-25 19:28:40
Message-ID: 1219692520.234656.4603.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 852338 by aseigo:

in the desktop shell the view follows the scene around; in the mid shell it's the \
opposite: we set up an essentially static view layout and map the scene to it


 M  +2 -11     midcorona.cpp  
 M  +11 -28    midview.cpp  
 M  +2 -21     midview.h  
 M  +71 -31    plasmaapp.cpp  
 M  +3 -0      plasmaapp.h  


--- trunk/KDE/kdebase/workspace/plasma/shells/mid/midcorona.cpp #852337:852338
@@ -66,22 +66,13 @@
         return;
     }
 
+    c->init();
+
     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
     bool isDesktop = args->isSet("desktop");
 
-    c->init();
-
     if (isDesktop) {
         c->setScreen(0);
-    } else {
-        QString geom = args->getOption("screen");
-        int x = geom.indexOf('x');
-
-        if (x > 0)  {
-            int width = qMax(400, geom.left(x).toInt());
-            int height = qMax(200, geom.right(geom.length() - x - 1).toInt());
-            c->resize(width, height);
-        }
     }
 
     c->setWallpaper("image", "SingleImage");
--- trunk/KDE/kdebase/workspace/plasma/shells/mid/midview.cpp #852337:852338
@@ -18,11 +18,10 @@
 
 #include "midview.h"
 
+#include <QAction>
 #include <QCoreApplication>
 #include <QDesktopWidget>
 
-#include <KAction>
-#include <KStandardAction>
 #include <KWindowSystem>
 
 #include "plasma/applet.h"
@@ -62,9 +61,6 @@
     pt.end();
     QBrush b(tile);
     setBackgroundBrush(tile);
-
-    kDebug() << "goin' in!" << containment->geometry().size().toSize();
-    resize(containment->geometry().size().toSize());
 }
 
 MidView::~MidView()
@@ -83,31 +79,10 @@
 void MidView::setContainment(Plasma::Containment *containment)
 {
     Plasma::View::setContainment(containment);
-    kDebug() << "goin' in!" << containment->geometry().size().toSize();
-    resize(containment->geometry().size().toSize());
+    containment->resize(size());
+    kDebug() << "goin' in!" << size() << containment->geometry().size().toSize();
 }
 
-void MidView::setIsDesktop(bool isDesktop)
-{
-    if (isDesktop) {
-        setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
-        KWindowSystem::setOnAllDesktops(winId(), true);
-        KWindowSystem::setType(winId(), NET::Desktop);
-        lower();
-    } else {
-        setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
-        KWindowSystem::setOnAllDesktops(winId(), false);
-        KWindowSystem::setType(winId(), NET::Normal);
-        QAction *action = KStandardAction::quit(qApp, SLOT(quit()), this);
-        addAction(action);
-    }
-}
-
-bool MidView::isDesktop() const
-{
-    return KWindowInfo(winId(), NET::WMWindowType).windowType(NET::Desktop);
-}
-
 void MidView::configureContainment()
 {
     /* TODO: implement; suggestion: as an overlay that takes the whole screen
@@ -162,6 +137,14 @@
     }
 }
 
+void MidView::resizeEvent(QResizeEvent *event)
+{
+    Q_UNUSED(event)
+    if (containment()) {
+        containment()->resize(size());
+    }
+}
+
 void MidView::screenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment* \
containment)  {
     kDebug() << "was, is, containment:" << wasScreen << isScreen << \
                (QObject*)containment;
--- trunk/KDE/kdebase/workspace/plasma/shells/mid/midview.h #852337:852338
@@ -44,31 +44,11 @@
      */
     void connectContainment(Plasma::Containment *containment);
 
-    /**
-     * Sets this MidView as a desktop window if @p isDesktop is
-     * true or an ordinary window otherwise.
-     *
-     * Desktop windows are displayed beneath all other windows, have
-     * no window decoration and occupy the full size of the desktop.
-     */
-    void setIsDesktop(bool isDesktop);
+    static uint defaultId() { return 1; }
 
-    /**
-     * Returns true if this widget is currently a desktop window.
-     * See setAsDesktop()
-     */
-    bool isDesktop() const;
-
-    static int defaultId() { return 1; }
-
 public slots:
     void showAppletBrowser();
-
-    /**
-     * reimplemented from Plasma::View
-     */
     void setContainment(Plasma::Containment *containment);
-
     void screenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment* \
containment);  
     /**
@@ -90,6 +70,7 @@
 
 protected:
     void drawBackground(QPainter *painter, const QRectF &rect);
+    void resizeEvent(QResizeEvent *event);
 };
 
 #endif // multiple inclusion guard
--- trunk/KDE/kdebase/workspace/plasma/shells/mid/plasmaapp.cpp #852337:852338
@@ -25,13 +25,15 @@
 #include <QDesktopWidget>
 #include <QPixmapCache>
 #include <QTimer>
+#include <QVBoxLayout>
 #include <QtDBus/QtDBus>
 
+#include <KAction>
 #include <KCrash>
 #include <KDebug>
 #include <KCmdLineArgs>
+#include <KStandardAction>
 #include <KWindowSystem>
-#include <KAction>
 
 #include <ksmserver_interface.h>
 
@@ -47,6 +49,7 @@
 Display* dpy = 0;
 Colormap colormap = 0;
 Visual *visual = 0;
+static const int CONTROL_BAR_HEIGHT = 22;
 
 void checkComposite()
 {
@@ -98,12 +101,15 @@
 PlasmaApp::PlasmaApp(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap)
     : KUniqueApplication(display, visual, colormap),
       m_corona(0),
+      m_window(0),
+      m_controlBar(0),
       m_mainView(0),
       m_isDesktop(false)
 {
     KGlobal::locale()->insertCatalog("libplasma");
 
-    bool isDesktop = KCmdLineArgs::parsedArgs()->isSet("desktop");
+    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+    bool isDesktop = args->isSet("desktop");
     if (isDesktop) {
         notifyStartup(false);
     }
@@ -134,11 +140,49 @@
     KConfigGroup cg(KGlobal::config(), "General");
     Plasma::Theme::defaultTheme()->setFont(cg.readEntry("desktopFont", font()));
 
-    setIsDesktop(isDesktop);
+    m_window = new QWidget;
 
+    //FIXME: if argb visuals enabled Qt will always set WM_CLASS as \
"qt-subapplication" no matter what +    //the application name is we set the proper \
XClassHint here, hopefully won't be necessary anymore when +    //qapplication will \
manage apps with argb visuals in a better way +    XClassHint classHint;
+    classHint.res_name = const_cast<char*>("Plasma");
+    classHint.res_class = const_cast<char*>("Plasma");
+    XSetClassHint(QX11Info::display(), m_window->winId(), &classHint);
+
+    QVBoxLayout *layout = new QVBoxLayout(m_window);
+    layout->setMargin(0);
+    layout->setSpacing(0);
+
+    //FIXME: replace with a proper View subclass, or at least populate this one!
+    m_controlBar = new Plasma::View(0, m_window);
+    m_controlBar->setFixedHeight(CONTROL_BAR_HEIGHT);
+    m_controlBar->setBackgroundBrush(Qt::red);
+    m_mainView = new MidView(0, m_window);
+
+    layout->addWidget(m_controlBar);
+    layout->addWidget(m_mainView);
+
+    if (!isDesktop) {
+        QAction *action = KStandardAction::quit(qApp, SLOT(quit()), m_window);
+        m_window->addAction(action);
+
+        QString geom = args->getOption("screen");
+        int x = geom.indexOf('x');
+
+        if (x > 0)  {
+            int width = qMax(400, geom.left(x).toInt());
+            int height = qMax(200, geom.right(geom.length() - x - 1).toInt());
+            m_window->setFixedSize(width, height);
+            m_mainView->setFixedSize(width, height - CONTROL_BAR_HEIGHT);
+        }
+    }
+
     // this line initializes the corona.
     corona();
 
+    setIsDesktop(isDesktop);
+
     if (isDesktop) {
         notifyStartup(true);
     }
@@ -171,13 +215,17 @@
 void PlasmaApp::setIsDesktop(bool isDesktop)
 {
     m_isDesktop = isDesktop;
-    if (m_mainView) {
-        m_mainView->setIsDesktop(isDesktop);
-    }
 
     if (isDesktop) {
+        m_window->setWindowFlags(m_window->windowFlags() | Qt::FramelessWindowHint);
+        KWindowSystem::setOnAllDesktops(m_window->winId(), true);
+        KWindowSystem::setType(m_window->winId(), NET::Desktop);
+        m_window->lower();
         connect(QApplication::desktop(), SIGNAL(resized(int)), \
SLOT(adjustSize(int)));  } else {
+        m_window->setWindowFlags(m_window->windowFlags() & \
~Qt::FramelessWindowHint); +        \
KWindowSystem::setOnAllDesktops(m_window->winId(), false); +        \
                KWindowSystem::setType(m_window->winId(), NET::Normal);
         disconnect(QApplication::desktop(), SIGNAL(resized(int)), this, \
SLOT(adjustSize(int)));  }
 }
@@ -214,14 +262,20 @@
 Plasma::Corona* PlasmaApp::corona()
 {
     if (!m_corona) {
-        MidCorona *c = new MidCorona(this);
-        connect(c, SIGNAL(containmentAdded(Plasma::Containment*)),
+        m_corona = new MidCorona(this);
+        connect(m_corona, SIGNAL(containmentAdded(Plasma::Containment*)),
                 this, SLOT(createView(Plasma::Containment*)));
-        connect(c, SIGNAL(configSynced()), this, SLOT(syncConfig()));
+        connect(m_corona, SIGNAL(configSynced()), this, SLOT(syncConfig()));
 
-        c->setItemIndexMethod(QGraphicsScene::NoIndex);
-        c->initializeLayout();
-        m_corona = c;
+
+        m_corona->setItemIndexMethod(QGraphicsScene::NoIndex);
+        m_corona->initializeLayout();
+
+        m_window->show();
+
+        connect(m_corona, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)),
+                m_mainView, SLOT(screenOwnerChanged(int,int,Plasma::Containment*)));
+
     }
 
     return m_corona;
@@ -250,26 +304,12 @@
              << "| type" << containment->containmentType()
              <<  "| screen:" << containment->screen()
              << "| geometry:" << containment->geometry()
-             << "| zValue:" << containment->zValue();
+             << "| zValue:" << containment->zValue()
+             << "| id:" << containment->id() << "==" << MidView::defaultId();
 
-    if (!m_mainView && containment->id() == MidView::defaultId()) {
-        m_mainView = new MidView(containment);
-
-        if (m_corona) {
-            connect(m_corona, \
                SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)),
-                    m_mainView, \
                SLOT(screenOwnerChanged(int,int,Plasma::Containment*)));
-        }
-
-        m_mainView->setIsDesktop(m_isDesktop);
-        m_mainView->show();
-
-        //FIXME: if argb visuals enabled Qt will always set WM_CLASS as \
                "qt-subapplication" no matter what
-        //the application name is we set the proper XClassHint here, hopefully won't \
                be necessary anymore when
-        //qapplication will manage apps with argb visuals in a better way
-        XClassHint classHint;
-        classHint.res_name = const_cast<char*>("Plasma");
-        classHint.res_class = const_cast<char*>("Plasma");
-        XSetClassHint(QX11Info::display(), m_mainView->winId(), &classHint);
+    if (m_mainView && containment->id() == MidView::defaultId()) {
+        kDebug() << "setting mainview to the containment!";
+        m_mainView->setContainment(containment);
     }
 }
 
--- trunk/KDE/kdebase/workspace/plasma/shells/mid/plasmaapp.h #852337:852338
@@ -28,6 +28,7 @@
 {
     class Containment;
     class Corona;
+    class View;
 } // namespace Plasma
 
 class MidView;
@@ -75,6 +76,8 @@
 
 private:
     Plasma::Corona *m_corona;
+    QWidget *m_window;
+    Plasma::View *m_controlBar;
     MidView *m_mainView;
     bool m_isDesktop;
 };


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

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