Index: kdebase/CMakeLists.txt =================================================================== --- kdebase/CMakeLists.txt (revision 868895) +++ kdebase/CMakeLists.txt (working copy) @@ -20,11 +20,11 @@ include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES}) if ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/runtime ) - add_subdirectory( runtime ) +# add_subdirectory( runtime ) endif ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/runtime ) if ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/apps ) - add_subdirectory( apps ) +# add_subdirectory( apps ) endif ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/apps ) if ( NOT Q_WS_MAC AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/workspace ) Index: kdebase/workspace/CMakeLists.txt =================================================================== --- kdebase/workspace/CMakeLists.txt (revision 868895) +++ kdebase/workspace/CMakeLists.txt (working copy) @@ -78,42 +78,42 @@ add_subdirectory(libs) # system settings (kcontrol replacement) -macro_optional_add_subdirectory( systemsettings ) +#macro_optional_add_subdirectory( systemsettings ) # core apps if(NOT WIN32) -macro_optional_add_subdirectory( kcheckpass ) -macro_optional_add_subdirectory( kscreensaver ) -macro_optional_add_subdirectory( kwin ) -macro_optional_add_subdirectory( ksmserver ) -macro_optional_add_subdirectory( kcminit ) -macro_optional_add_subdirectory( ksplash ) -macro_optional_add_subdirectory( khotkeys ) -macro_optional_add_subdirectory( klipper ) -macro_optional_add_subdirectory( ksysguard ) -macro_optional_add_subdirectory( powerdevil ) +#macro_optional_add_subdirectory( kcheckpass ) +#macro_optional_add_subdirectory( kscreensaver ) +#macro_optional_add_subdirectory( kwin ) +#macro_optional_add_subdirectory( ksmserver ) +#macro_optional_add_subdirectory( kcminit ) +#macro_optional_add_subdirectory( ksplash ) +#macro_optional_add_subdirectory( khotkeys ) +#macro_optional_add_subdirectory( klipper ) +#macro_optional_add_subdirectory( ksysguard ) +#macro_optional_add_subdirectory( powerdevil ) endif(NOT WIN32) -macro_optional_add_subdirectory( krunner ) -macro_optional_add_subdirectory( solid ) -macro_optional_add_subdirectory( kmenuedit ) +#macro_optional_add_subdirectory( krunner ) +#macro_optional_add_subdirectory( solid ) +#macro_optional_add_subdirectory( kmenuedit ) macro_optional_add_subdirectory( plasma ) -macro_optional_add_subdirectory( kstartupconfig ) +#macro_optional_add_subdirectory( kstartupconfig ) # apps we need to figure out what to do with -macro_optional_add_subdirectory( kcontrol ) +#macro_optional_add_subdirectory( kcontrol ) if(NOT WIN32) -macro_optional_add_subdirectory( ksystraycmd ) +#macro_optional_add_subdirectory( ksystraycmd ) endif(NOT WIN32) # data if(NOT WIN32) -macro_optional_add_subdirectory( cursors ) +#macro_optional_add_subdirectory( cursors ) endif(NOT WIN32) -macro_optional_add_subdirectory( doc ) -macro_optional_add_subdirectory( wallpapers ) +#macro_optional_add_subdirectory( doc ) +#macro_optional_add_subdirectory( wallpapers ) if(X11_Xau_FOUND AND X11_Xdmcp_FOUND) - add_subdirectory( kdm ) +# add_subdirectory( kdm ) else(X11_Xau_FOUND AND X11_Xdmcp_FOUND) message(STATUS "Xau lib or Xdmcp lib was missing. kdm will not compile") endif(X11_Xau_FOUND AND X11_Xdmcp_FOUND) Index: kdebase/workspace/libs/plasma/plasma.cpp =================================================================== --- kdebase/workspace/libs/plasma/plasma.cpp (revision 868895) +++ kdebase/workspace/libs/plasma/plasma.cpp (working copy) @@ -26,6 +26,8 @@ #include #include +#include "kephal/screens.h" + namespace Plasma { @@ -109,7 +111,7 @@ } //are we out of screen? - QRect screenRect = QApplication::desktop()->screenGeometry(pv ? pv->containment()->screen() : -1); + QRect screenRect = kephal::ScreenUtils::screenGeometry(pv ? pv->containment()->screen() : -1); //kDebug() << "==> rect for" << (pv ? pv->containment()->screen() : -1) << "is" << screenRect; if (pos.rx() + s.width() > screenRect.right()) { Index: kdebase/workspace/libs/plasma/CMakeLists.txt =================================================================== --- kdebase/workspace/libs/plasma/CMakeLists.txt (revision 868895) +++ kdebase/workspace/libs/plasma/CMakeLists.txt (working copy) @@ -123,6 +123,8 @@ target_link_libraries(plasma ${DL_LIBRARY}) endif(DL_LIBRARY) +target_link_libraries(plasma kephal) + if(QT_QTOPENGL_FOUND AND OPENGL_FOUND) target_link_libraries(plasma ${QT_QTOPENGL_LIBRARY} ${OPENGL_gl_LIBRARY}) endif(QT_QTOPENGL_FOUND AND OPENGL_FOUND) Index: kdebase/workspace/libs/plasma/containment.cpp =================================================================== --- kdebase/workspace/libs/plasma/containment.cpp (revision 868895) +++ kdebase/workspace/libs/plasma/containment.cpp (working copy) @@ -56,6 +56,8 @@ #include "private/desktoptoolbox_p.h" #include "private/paneltoolbox_p.h" +#include "kephal/screens.h" + namespace Plasma { @@ -737,8 +739,7 @@ } //kDebug() << "setting screen to" << screen << "and we are a" << containmentType(); - QDesktopWidget *desktop = QApplication::desktop(); - int numScreens = desktop->numScreens(); + int numScreens = kephal::ScreenUtils::numScreens(); if (screen < -1) { screen = -1; } @@ -747,7 +748,7 @@ if (screen < numScreens && screen > -1) { if (containmentType() == DesktopContainment || containmentType() >= CustomContainment) { - resize(desktop->screenGeometry(screen).size()); + resize(kephal::ScreenUtils::screenSize(screen)); } } @@ -774,7 +775,7 @@ return QPoint(); } - QRect r = QApplication::desktop()->screenGeometry(d->screen); + QRect r = kephal::ScreenUtils::screenGeometry(d->screen); if (containmentType() == PanelContainment || containmentType() == CustomPanelContainment) { QRectF p = geometry(); @@ -1372,7 +1373,7 @@ //don't remove a desktop that's in use //FIXME allow removal of containments for screens that don't currently exist if (d->type != PanelContainment && d->type != CustomPanelContainment && - (d->screen != -1 || d->screen >= QApplication::desktop()->numScreens())) { + (d->screen != -1 || d->screen >= kephal::ScreenUtils::numScreens())) { kDebug() << (QObject*)this << "containment has a screen number?" << d->screen; return; } @@ -1491,9 +1492,10 @@ } } } else { - QDesktopWidget *desktop = QApplication::desktop(); - QRectF avail = desktop->availableGeometry(screen); - QRectF screenGeom = desktop->screenGeometry(screen); +// QRectF avail = QApplication::desktop()->availableGeometry(screen); + QRectF screenGeom = kephal::ScreenUtils::screenGeometry(screen); + QRectF avail = screenGeom; // TODO: implement availableGeometry in kephal +// kDebug() << "Screen" << screen << "QDesktopWidget::availableGeometry" << avail << "kephal" << screenGeom; if (q->view() && !q->view()->transform().isScaling()) { @@ -1746,11 +1748,10 @@ int width = 0; int height = 0; - QDesktopWidget *desktop = QApplication::desktop(); - int numScreens = desktop->numScreens(); + int numScreens = kephal::ScreenUtils::numScreens(); for (int i = 0; i < numScreens; ++i) { - QRect otherScreen = desktop->screenGeometry(i); + QRect otherScreen = kephal::ScreenUtils::screenGeometry(i); if (width < otherScreen.width()) { width = otherScreen.width(); Index: kdebase/workspace/libs/CMakeLists.txt =================================================================== --- kdebase/workspace/libs/CMakeLists.txt (revision 868895) +++ kdebase/workspace/libs/CMakeLists.txt (working copy) @@ -1,15 +1,15 @@ -add_subdirectory(kdm) -add_subdirectory(solid) +#add_subdirectory(kdm) +#add_subdirectory(solid) add_subdirectory(plasma) if(NOT WIN32) - add_subdirectory(taskmanager) - add_subdirectory(ksysguard) - add_subdirectory(kworkspace) +# add_subdirectory(taskmanager) +# add_subdirectory(ksysguard) +# add_subdirectory(kworkspace) endif(NOT WIN32) macro_optional_find_package(Nepomuk) macro_log_feature(Nepomuk_FOUND "Nepomuk" "Nepomuk Libraries" "kdelibs" FALSE "" "Required to build Nepomuk.") if(Nepomuk_FOUND) - add_subdirectory(nepomukquery) - add_subdirectory(nepomukqueryclient) +# add_subdirectory(nepomukquery) +# add_subdirectory(nepomukqueryclient) endif(Nepomuk_FOUND) Index: kdebase/workspace/plasma/shells/desktop/panelcontroller.cpp =================================================================== --- kdebase/workspace/plasma/shells/desktop/panelcontroller.cpp (revision 868895) +++ kdebase/workspace/plasma/shells/desktop/panelcontroller.cpp (working copy) @@ -46,6 +46,8 @@ #include "positioningruler.h" #include "toolbutton.h" +#include "kephal/screens.h" + class PanelController::ButtonGroup: public QFrame { public: @@ -240,7 +242,8 @@ } } - QRect screenRect = QApplication::desktop()->screenGeometry(containment->screen()); + QRect screenRect = + kephal::ScreenUtils::screenGeometry(containment->screen()); if (pos.rx() + s.width() > screenRect.right()) { pos.rx() -= ((pos.rx() + s.width()) - screenRect.right()); @@ -259,7 +262,7 @@ void syncRuler() { QRect screenGeom = - QApplication::desktop()->screenGeometry(containment->screen()); + kephal::ScreenUtils::screenGeometry(containment->screen()); switch (location) { case Plasma::LeftEdge: @@ -515,7 +518,7 @@ QSize PanelController::sizeHint() const { QRect screenGeom = - QApplication::desktop()->screenGeometry(d->containment->screen()); + kephal::ScreenUtils::screenGeometry(d->containment->screen()); switch (d->location) { case Plasma::LeftEdge: @@ -533,7 +536,7 @@ QPoint PanelController::positionForPanelGeometry(const QRect &panelGeom) const { QRect screenGeom = - QApplication::desktop()->screenGeometry(d->containment->screen()); + kephal::ScreenUtils::screenGeometry(d->containment->screen()); switch (d->location) { case Plasma::LeftEdge: @@ -561,7 +564,7 @@ d->location = loc; d->ruler->setLocation(loc); QRect screenGeom = - QApplication::desktop()->screenGeometry(d->containment->screen()); + kephal::ScreenUtils::screenGeometry(d->containment->screen()); switch (loc) { case Plasma::LeftEdge: @@ -766,7 +769,7 @@ } else if (event->type() == QEvent::MouseButtonRelease) { //FIXME: for now resizes here instead of on mouse move, for a serious performance problem, maybe in Qt QRect screenGeom = - QApplication::desktop()->screenGeometry(d->containment->screen()); + kephal::ScreenUtils::screenGeometry(d->containment->screen()); if (d->dragging == Private::ResizeButtonElement) { switch (location()) { case Plasma::LeftEdge: @@ -804,8 +807,7 @@ return; } - QDesktopWidget *desktop = QApplication::desktop(); - QRect screenGeom = desktop->screenGeometry(d->containment->screen()); + QRect screenGeom = kephal::ScreenUtils::screenGeometry(d->containment->screen()); if (d->dragging == Private::MoveButtonElement) { //only move when the mouse cursor is out of the controller to avoid an endless reposition cycle @@ -815,7 +817,7 @@ if (!screenGeom.contains(event->globalPos())) { //move panel to new screen if dragged there - int targetScreen = desktop->screenNumber(event->globalPos()); + int targetScreen = QApplication::desktop()->screenNumber(event->globalPos()); //kDebug() << "Moving panel from screen" << d->containment->screen() << "to screen" << targetScreen; d->containment->setScreen(targetScreen); return; Index: kdebase/workspace/plasma/shells/desktop/desktopcorona.h =================================================================== --- kdebase/workspace/plasma/shells/desktop/desktopcorona.h (revision 868895) +++ kdebase/workspace/plasma/shells/desktop/desktopcorona.h (working copy) @@ -29,6 +29,11 @@ class Applet; } // namespace Plasma +namespace kephal { + class Screen; + class Screens; +} // namespace kephal + /** * @short A Corona with desktop-y considerations */ @@ -50,7 +55,9 @@ void checkScreens(); protected Q_SLOTS: - void screenResized(int); + void screenAdded(kephal::Screen * s); + void screenRemoved(int id); + void screenResized(kephal::Screen * s, QSize oldSize, QSize newSize); private: void init(); Index: kdebase/workspace/plasma/shells/desktop/plasmaapp.h =================================================================== --- kdebase/workspace/plasma/shells/desktop/plasmaapp.h (revision 868895) +++ kdebase/workspace/plasma/shells/desktop/plasmaapp.h (working copy) @@ -21,6 +21,8 @@ #define PLASMA_APP_H #include +#include +#include #include @@ -31,6 +33,11 @@ class Corona; } // namespace Plasma +namespace kephal { + class Screen; + class Screens; +} // namespace kephal + class RootWidget; class PanelView; class DesktopView; @@ -93,7 +100,7 @@ private: PlasmaApp(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap); DesktopView* viewForScreen(int screen) const; - + private Q_SLOTS: void cleanup(); void syncConfig(); @@ -101,7 +108,12 @@ void createView(Plasma::Containment *containment); void panelRemoved(QObject* panel); void adjustSize(int screen); - + + void screenAdded(kephal::Screen * s); + void screenRemoved(int id); + void screenResized(kephal::Screen * s, QSize oldSize, QSize newSize); + void screenMoved(kephal::Screen * s, QPoint oldPosition, QPoint newPosition); + private: Plasma::Corona *m_corona; QList m_panels; Index: kdebase/workspace/plasma/shells/desktop/panelview.cpp =================================================================== --- kdebase/workspace/plasma/shells/desktop/panelview.cpp (revision 868895) +++ kdebase/workspace/plasma/shells/desktop/panelview.cpp (working copy) @@ -41,6 +41,8 @@ #include "panelcontroller.h" #include "plasmaapp.h" +#include "kephal/screens.h" + PanelView::PanelView(Plasma::Containment *panel, int id, QWidget *parent) : Plasma::View(panel, id, parent), m_panelController(0), @@ -62,7 +64,7 @@ // pinchContainment calls updatePanelGeometry for us - QRect screenRect = QApplication::desktop()->screenGeometry(containment()->screen()); + QRect screenRect = kephal::ScreenUtils::screenGeometry(containment()->screen()); m_lastHorizontal = isHorizontal(); KConfigGroup sizes = KConfigGroup(&viewConfig, "Sizes"); m_lastSeenSize = sizes.readEntry("lastsize", m_lastHorizontal ? screenRect.width() : screenRect.height()); @@ -130,7 +132,7 @@ // we're switching! swap the sizes about panelHeight = s.width(); if (wasFullSize) { - QRect screenGeom = QApplication::desktop()->screenGeometry(c->screen()); + QRect screenGeom = kephal::ScreenUtils::screenGeometry(c->screen()); panelWidth = screenGeom.width(); } else { panelWidth = s.height(); @@ -145,7 +147,7 @@ // we're switching! swap the sizes about if (wasFullSize) { - QRect screenGeom = QApplication::desktop()->screenGeometry(c->screen()); + QRect screenGeom = kephal::ScreenUtils::screenGeometry(c->screen()); panelHeight = screenGeom.height(); } else { panelHeight = s.width(); @@ -170,7 +172,7 @@ c->setMinimumSize(min); c->setMaximumSize(max); - QRect screenRect = QApplication::desktop()->screenGeometry(c->screen()); + QRect screenRect = kephal::ScreenUtils::screenGeometry(c->screen()); pinchContainment(screenRect); //updatePanelGeometry(); connect(this, SIGNAL(sceneRectAboutToChange()), this, SLOT(updatePanelGeometry())); @@ -246,7 +248,7 @@ screen = 0; } - QRect screenGeom = QApplication::desktop()->screenGeometry(screen); + QRect screenGeom = kephal::ScreenUtils::screenGeometry(screen); if (m_alignment != Qt::AlignCenter) { m_offset = qMax(m_offset, 0); @@ -643,8 +645,8 @@ NETExtendedStrut strut; if (m_panelMode == NormalPanel) { - QRect thisScreen = QApplication::desktop()->screenGeometry(containment()->screen()); - QRect wholeScreen = QApplication::desktop()->geometry(); + QRect thisScreen = kephal::ScreenUtils::screenGeometry(containment()->screen()); + QRect wholeScreen = QApplication::desktop()->geometry(); //TODO: do that through kephal // extended struts are to the combined screen geoms, not the single screen int leftOffset = wholeScreen.x() - thisScreen.x(); Index: kdebase/workspace/plasma/shells/desktop/CMakeLists.txt =================================================================== --- kdebase/workspace/plasma/shells/desktop/CMakeLists.txt (revision 868895) +++ kdebase/workspace/plasma/shells/desktop/CMakeLists.txt (working copy) @@ -42,6 +42,8 @@ set_target_properties(kdeinit_plasma_qgv PROPERTIES OUTPUT_NAME kdeinit4_plasma) set_target_properties(plasma_qgv PROPERTIES OUTPUT_NAME plasma) +target_link_libraries(kdeinit_plasma_qgv kephal) + install(TARGETS kdeinit_plasma_qgv DESTINATION ${LIB_INSTALL_DIR}) install(TARGETS plasma_qgv ${INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES plasma.desktop DESTINATION ${AUTOSTART_INSTALL_DIR}) Index: kdebase/workspace/plasma/shells/desktop/desktopview.cpp =================================================================== --- kdebase/workspace/plasma/shells/desktop/desktopview.cpp (revision 868895) +++ kdebase/workspace/plasma/shells/desktop/desktopview.cpp (working copy) @@ -20,7 +20,6 @@ #include "desktopview.h" #include -#include #include #include #include @@ -43,6 +42,8 @@ #include "backgrounddialog.h" +#include "kephal/screens.h" + #ifdef Q_WS_WIN #include "windows.h" #include "windef.h" @@ -138,14 +139,17 @@ void DesktopView::adjustSize() { // adapt to screen resolution changes - QDesktopWidget *desktop = QApplication::desktop(); - QRect geom = desktop->screenGeometry(screen()); + QRect geom = kephal::ScreenUtils::screenGeometry(screen()); + kDebug() << "screen" << screen() << "geom" << geom; + containment()->resize(geom.size()); setGeometry(geom); - containment()->resize(geom.size()); + kDebug() << "Containment's geom after resize" << containment()->geometry(); if (m_dashboard) { m_dashboard->setGeometry(geom); } + + kDebug() << "Done" << screen(); } void DesktopView::setIsDesktop(bool isDesktop) @@ -229,7 +233,7 @@ { if (m_configDialog == 0) { const QSize resolution = - QApplication::desktop()->screenGeometry(screen()).size(); + kephal::ScreenUtils::screenSize(screen()); m_configDialog = new BackgroundDialog(resolution, this); } else { Index: kdebase/workspace/plasma/shells/desktop/desktopcorona.cpp =================================================================== --- kdebase/workspace/plasma/shells/desktop/desktopcorona.cpp (revision 868895) +++ kdebase/workspace/plasma/shells/desktop/desktopcorona.cpp (working copy) @@ -20,7 +20,6 @@ #include "desktopcorona.h" #include -#include #include #include @@ -32,6 +31,8 @@ #include #include +#include "kephal/screens.h" + DesktopCorona::DesktopCorona(QObject *parent) : Plasma::Corona(parent) { @@ -40,16 +41,17 @@ void DesktopCorona::init() { - QDesktopWidget *desktop = QApplication::desktop(); - m_numScreens = desktop->numScreens(); - QObject::connect(desktop, SIGNAL(resized(int)), this, SLOT(screenResized(int))); + kephal::Screens *screens = kephal::Screens::instance(); + m_numScreens = screens->screens().size(); + connect(screens, SIGNAL(screenAdded(kephal::Screen *)), SLOT(screenAdded(kephal::Screen *))); + connect(screens, SIGNAL(screenRemoved(int)), SLOT(screenRemoved(int))); + connect(kephal::Screens::instance(), SIGNAL(screenResized(kephal::Screen *, QSize, QSize)), SLOT(screenResized(kephal::Screen *, QSize, QSize))); } void DesktopCorona::checkScreens() { // quick sanity check to ensure we have containments for each screen! - int numScreens = QApplication::desktop()->numScreens(); - for (int i = 0; i < numScreens; ++i) { + for (int i = 0; i < m_numScreens; ++i) { if (!containmentForScreen(i)) { //TODO: should we look for containments that aren't asigned but already exist? Plasma::Containment* c = addContainment("desktop"); @@ -69,8 +71,6 @@ emit containmentAdded(containmentForScreen(i)); } } - - m_numScreens = numScreens; } void DesktopCorona::loadDefaultLayout() @@ -82,15 +82,13 @@ return; } - QDesktopWidget *desktop = QApplication::desktop(); - int numScreens = desktop->numScreens(); - kDebug() << "number of screens is" << numScreens; + kDebug() << "number of screens is" << m_numScreens; int topLeftScreen = 0; - QPoint topLeftCorner = desktop->screenGeometry(0).topLeft(); + QPoint topLeftCorner = kephal::Screens::instance()->primaryScreen()->geom().topLeft(); // find our "top left" screen, use it as the primary - for (int i = 0; i < numScreens; ++i) { - QRect g = desktop->screenGeometry(i); + for (int i = 0; i < m_numScreens; ++i) { + QRect g = kephal::ScreenUtils::screenGeometry(i); kDebug() << " screen " << i << "geometry is" << g; if (g.x() <= topLeftCorner.x() && g.y() >= topLeftCorner.y()) { @@ -103,7 +101,7 @@ KConfigGroup invalidConfig; // create a containment for each screen - for (int i = 0; i < numScreens; ++i) { + for (int i = 0; i < m_numScreens; ++i) { // passing in an empty string will get us whatever the default // containment type is! Plasma::Containment* c = addContainmentDelayed(QString()); @@ -205,22 +203,40 @@ return applet; } -void DesktopCorona::screenResized(int screen) +void DesktopCorona::screenResized(kephal::Screen *s, QSize oldSize, QSize newSize) { - int numScreens = QApplication::desktop()->numScreens(); - if (screen < numScreens) { - foreach (Plasma::Containment *c, containments()) { - if (c->screen() == screen) { - // trigger a relayout - c->setScreen(screen); - } + // TODO: that check should not be necessary, fix kephal + if (oldSize == newSize) + return; + + kDebug(); + foreach (Plasma::Containment *c, containments()) { + if (c->screen() == s->id()) { + // trigger a relayout + c->setScreen(s->id()); } + } - checkScreens(); // ensure we have containments for every screen - } else { - m_numScreens = numScreens; - } + checkScreens(); // ensure we have containments for every screen + kDebug() << "Done"; } +void DesktopCorona::screenAdded(kephal::Screen * s) +{ + kDebug(); + m_numScreens = kephal::ScreenUtils::numScreens(); + checkScreens(); // ensure we have containments for every screen + kDebug() << "Done"; +} + +void DesktopCorona::screenRemoved(int id) +{ + kDebug(); + m_numScreens = kephal::ScreenUtils::numScreens(); + checkScreens(); // ensure we have containments for every screen + kDebug() << "Done"; +} + + #include "desktopcorona.moc" Index: kdebase/workspace/plasma/shells/desktop/plasmaapp.cpp =================================================================== --- kdebase/workspace/plasma/shells/desktop/plasmaapp.cpp (revision 868895) +++ kdebase/workspace/plasma/shells/desktop/plasmaapp.cpp (working copy) @@ -64,6 +64,8 @@ #include "desktopview.h" #include "panelview.h" +#include "kephal/screens.h" + #ifdef Q_WS_X11 #include #include @@ -147,10 +149,11 @@ // Calculate the size required to hold background pixmaps for all screens. // Add 10% so that other (smaller) pixmaps can also be cached. int cacheSize = 0; - QDesktopWidget *desktop = QApplication::desktop(); - for (int i = 0; i < desktop->numScreens(); i++) { - QRect geometry = desktop->screenGeometry(i); - cacheSize += 4 * geometry.width() * geometry.height() / 1024; + QList screensList = kephal::Screens::instance()->screens(); + for (int i = 0; i < screensList.size(); i++) { + kephal::Screen *screen = screensList.at(i); + QSize size = screen->size(); + cacheSize += 4 * size.width() * size.height() / 1024; } cacheSize += cacheSize / 10; @@ -251,8 +254,8 @@ } } - int numScreens = QApplication::desktop()->numScreens(); - for (int i = 0; i < numScreens; ++i) { + QList screensList = kephal::Screens::instance()->screens(); + for (int i = 0; i < screensList.size(); i++) { DesktopView *v = viewForScreen(i); if (v && v->containment()) { viewIds.writeEntry(QString::number(v->containment()->id()), v->id()); @@ -281,7 +284,8 @@ void PlasmaApp::toggleDashboard() { int currentScreen = 0; - if (QApplication::desktop()->numScreens() > 1) { + if (kephal::ScreenUtils::numScreens() > 1) { + // TODO: that should be done through kephal currentScreen = QApplication::desktop()->screenNumber(QCursor::pos()); } @@ -334,10 +338,17 @@ view->setIsDesktop(isDesktop); } + kephal::Screens *screens = kephal::Screens::instance(); if (isDesktop) { - connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(adjustSize(int))); + connect(screens, SIGNAL(screenAdded(kephal::Screen *)), SLOT(screenAdded(kephal::Screen *))); + connect(screens, SIGNAL(screenRemoved(int)), SLOT(screenRemoved(int))); + connect(screens, SIGNAL(screenResized(kephal::Screen *, QSize, QSize)), SLOT(screenResized(kephal::Screen *, QSize, QSize))); + connect(screens, SIGNAL(screenMoved(kephal::Screen *, QPoint, QPoint)), SLOT(screenMoved(kephal::Screen *, QPoint, QPoint))); } else { - disconnect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(adjustSize(int))); + disconnect(screens, SIGNAL(screenAdded(kephal::Screen *)), this, SLOT(screenAdded(kephal::Screen *))); + disconnect(screens, SIGNAL(screenRemoved(int)), this, SLOT(screenRemoved(int))); + disconnect(screens, SIGNAL(screenResized(kephal::Screen *, QSize, QSize)), this, SLOT(screenResized(kephal::Screen *, QSize, QSize))); + disconnect(screens, SIGNAL(screenMoved(kephal::Screen *, QPoint, QPoint)), this, SLOT(screenMoved(kephal::Screen *, QPoint, QPoint))); } } @@ -348,31 +359,42 @@ void PlasmaApp::adjustSize(int screen) { - QDesktopWidget *desktop = QApplication::desktop(); - bool screenExists = screen < desktop->numScreens(); +} - QRect screenGeom; - if (screenExists) { - screenGeom = desktop->screenGeometry(screen); +void PlasmaApp::screenAdded(kephal::Screen * s) +{ + kDebug() << s->id(); +} + +void PlasmaApp::screenRemoved(int id) +{ + kDebug() << id; + DesktopView *view = viewForScreen(id); + if (view) { + // the screen was removed, so we'll destroy the + // corresponding view + kDebug() << "removing the view for screen" << id; + view->setContainment(0); + m_desktops.removeAll(view); + delete view; } +} - DesktopView *view = viewForScreen(screen); +void PlasmaApp::screenResized(kephal::Screen *s, QSize oldSize, QSize newSize) +{ + // TODO: that check should not be necessary, fix kephal + if (oldSize == newSize) + return; + + kDebug() << s->id() << oldSize << newSize; + + DesktopView *view = viewForScreen(s->id()); - kDebug() << "adjust size for screen" << screen << screenGeom << view; + kDebug() << "adjust size for screen" << s->id() << newSize << view; if (view) { - if (screenExists) { - kDebug() << "here we go ... adjusting size"; - view->adjustSize(); - } else { - // the screen was removed, so we'll destroy the - // corresponding view - kDebug() << "removing the view for screen" << screen; - view->setContainment(0); - m_desktops.removeAll(view); - delete view; - } - } else if (screenExists) { + view->adjustSize(); + } else { //TODO: we have a screen that has changed, but no view. // perhaps we should make one. } @@ -381,15 +403,22 @@ // disappears? this would mean having some // way of alerting that we have a new screen // that appears - if (screenExists) { - foreach (PanelView *panel, m_panels) { - if (panel->screen() == screen) { - panel->pinchContainment(screenGeom); - } + foreach (PanelView *panel, m_panels) { + if (panel->screen() == s->id()) { + panel->pinchContainment(s->geom()); } } + + kDebug() << "Done."; } +void PlasmaApp::screenMoved(kephal::Screen * s, QPoint oldPosition, QPoint newPosition) +{ + kDebug() << s->id() << oldPosition.x() << oldPosition.y() << newPosition.x() << newPosition.y(); +} + + + DesktopView* PlasmaApp::viewForScreen(int screen) const { foreach (DesktopView *view, m_desktops) { @@ -499,14 +528,14 @@ } default: if (containment->screen() > -1 && - containment->screen() < QApplication::desktop()->numScreens()) { + containment->screen() < kephal::ScreenUtils::numScreens()) { if (viewForScreen(containment->screen())) { // we already have a view for this screen return; } kDebug() << "creating a view for" << containment->screen() << "and we have" - << QApplication::desktop()->numScreens() << "screens"; + << kephal::ScreenUtils::numScreens() << "screens"; // we have a new screen. neat. DesktopView *view = new DesktopView(containment, id, 0); @@ -515,7 +544,7 @@ connect(m_corona, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)), view, SLOT(screenOwnerChanged(int,int,Plasma::Containment*))); } - view->setGeometry(QApplication::desktop()->screenGeometry(containment->screen())); + view->setGeometry(kephal::ScreenUtils::screenGeometry(containment->screen())); m_desktops.append(view); view->setIsDesktop(m_isDesktop); view->show(); Index: kdebase/workspace/plasma/shells/desktop/dashboardview.cpp =================================================================== --- kdebase/workspace/plasma/shells/desktop/dashboardview.cpp (revision 868895) +++ kdebase/workspace/plasma/shells/desktop/dashboardview.cpp (working copy) @@ -22,7 +22,6 @@ #include "dashboardview.h" #include -#include #include #include @@ -35,6 +34,8 @@ #include "plasma/appletbrowser.h" #include "plasmaapp.h" +#include "kephal/screens.h" + static const int SUPPRESS_SHOW_TIMEOUT = 500; // Number of millis to prevent reshow of dashboard DashboardView::DashboardView(Plasma::Containment *containment, QWidget *parent) @@ -51,8 +52,7 @@ setAttribute(Qt::WA_NoSystemBackground); } - QDesktopWidget *desktop = QApplication::desktop(); - setGeometry(desktop->screenGeometry(containment->screen())); + setGeometry(kephal::ScreenUtils::screenGeometry(containment->screen())); setWallpaperEnabled(!PlasmaApp::hasComposite()); Index: kdebase/workspace/plasma/containments/panel/panel.cpp =================================================================== --- kdebase/workspace/plasma/containments/panel/panel.cpp (revision 868895) +++ kdebase/workspace/plasma/containments/panel/panel.cpp (working copy) @@ -44,13 +44,15 @@ #include #include +#include + using namespace Plasma; Panel::Panel(QObject *parent, const QVariantList &args) : Containment(parent, args), m_configureAction(0), m_addPanelAction(0), - m_currentSize(QSize(QApplication::desktop()->screenGeometry(screen()).width(), 38)), + m_currentSize(QSize(kephal::ScreenUtils::screenSize(screen()).width(), 38)), m_lastViewGeom() { m_background = new Plasma::PanelSvg(this); @@ -232,7 +234,7 @@ if (s < 0) { // do nothing in this case, we want all the borders } else if (loc == BottomEdge || loc == TopEdge) { - QRect r = QApplication::desktop()->screenGeometry(s); + QRect r = kephal::ScreenUtils::screenGeometry(s); if (loc == BottomEdge) { enabledBorders ^= PanelSvg::BottomBorder; @@ -253,7 +255,7 @@ //kDebug() << "top/bottom: Width:" << width << ", height:" << height; } else if (loc == LeftEdge || loc == RightEdge) { - QRect r = QApplication::desktop()->screenGeometry(s); + QRect r = kephal::ScreenUtils::screenGeometry(s); if (loc == RightEdge) { enabledBorders ^= PanelSvg::RightBorder; @@ -340,7 +342,7 @@ //we need to know if the width or height is 100% if (constraints & Plasma::LocationConstraint || constraints & Plasma::SizeConstraint) { m_currentSize = geometry().size().toSize(); - QRectF screenRect = screen() >= 0 ? QApplication::desktop()->screenGeometry(screen()) : + QRectF screenRect = screen() >= 0 ? kephal::ScreenUtils::screenGeometry(screen()) : geometry(); if ((formFactor() == Horizontal && m_currentSize.width() >= screenRect.width()) || Index: kdebase/workspace/plasma/containments/desktop/desktop.cpp =================================================================== --- kdebase/workspace/plasma/containments/desktop/desktop.cpp (revision 868895) +++ kdebase/workspace/plasma/containments/desktop/desktop.cpp (working copy) @@ -52,6 +52,8 @@ #include "krunner_interface.h" #include "screensaver_interface.h" +#include "kephal/screens.h" + #ifdef Q_OS_WIN #define _WIN32_WINNT 0x0500 // require NT 5.0 (win 2k pro) #include @@ -98,7 +100,7 @@ QSize DefaultDesktop::resolution() const { - return QApplication::desktop()->screenGeometry(screen()).size(); + return kephal::ScreenUtils::screenSize(screen()); } void DefaultDesktop::constraintsEvent(Plasma::Constraints constraints) Index: kdebase/workspace/plasma/CMakeLists.txt =================================================================== --- kdebase/workspace/plasma/CMakeLists.txt (revision 868895) +++ kdebase/workspace/plasma/CMakeLists.txt (working copy) @@ -1,12 +1,12 @@ add_definitions(-DKDE_DEFAULT_DEBUG_AREA=1204) -add_subdirectory(animators) -add_subdirectory(applets) +#add_subdirectory(animators) +#add_subdirectory(applets) add_subdirectory(containments) -add_subdirectory(dataengines) -add_subdirectory(desktoptheme) -add_subdirectory(runners) -add_subdirectory(scriptengines) +#add_subdirectory(dataengines) +#add_subdirectory(desktoptheme) +#add_subdirectory(runners) +#add_subdirectory(scriptengines) add_subdirectory(shells) -add_subdirectory(tools) -add_subdirectory(wallpapers) +#add_subdirectory(tools) +#add_subdirectory(wallpapers)