From f780e8b68bfd018cf1ad215dd361e387af386a19 Mon Sep 17 00:00:00 2001 From: Guillaume Pothier Date: Sat, 15 Nov 2008 03:04:44 +0000 Subject: [PATCH] Kephalized plasma and kwin: replaced usage of QDesktopWidget by Kephal svn path=/trunk/KDE/kdebase/workspace/; revision=884482 --- effects/CMakeLists.txt | 6 ++-- geometry.cpp | 52 +++++++++++------------------- kcmkwin/kwinoptions/CMakeLists.txt | 2 +- kcmkwin/kwinoptions/windows.cpp | 6 ++-- lib/CMakeLists.txt | 4 +-- lib/kcommondecoration.cpp | 8 ++--- manage.cpp | 6 +--- workspace.cpp | 30 +++++++++-------- 8 files changed, 49 insertions(+), 65 deletions(-) diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 583bce8234..ac0bb1a7c5 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -5,7 +5,7 @@ # Adds effect plugin with given name. Sources are given after the name macro(KWIN4_ADD_EFFECT name) kde4_add_plugin(kwin4_effect_${name} ${ARGN}) - target_link_libraries(kwin4_effect_${name} kwineffects ${KDE4_KDEUI_LIBS}) + target_link_libraries(kwin4_effect_${name} kwineffects ${KDE4_KDEUI_LIBS} kephal) install(TARGETS kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR}) endmacro(KWIN4_ADD_EFFECT) @@ -21,7 +21,7 @@ macro(KWIN4_ADD_EFFECT_CONFIG name) endforeach(file) kde4_add_ui_files(kwin4_effect_src ${kwin4_effect_ui}) kde4_add_plugin(kcm_kwin4_effect_${name} ${kwin4_effect_src}) - target_link_libraries(kcm_kwin4_effect_${name} kwineffects ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS}) + target_link_libraries(kcm_kwin4_effect_${name} kwineffects ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS} kephal) install(TARGETS kcm_kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR}) endmacro(KWIN4_ADD_EFFECT_CONFIG) @@ -223,7 +223,7 @@ KWIN4_ADD_EFFECT(builtins ${kwin4_effect_builtins_sources}) KWIN4_ADD_EFFECT_CONFIG(builtins ${kwin4_effect_builtins_config_sources}) # link to xrender if necessary if (KWIN_HAVE_XRENDER_COMPOSITING) - target_link_libraries(kwin4_effect_builtins ${X11_Xrender_LIB} ${X11_LIBRARIES}) + target_link_libraries(kwin4_effect_builtins ${X11_Xrender_LIB} ${X11_LIBRARIES} kephal) endif (KWIN_HAVE_XRENDER_COMPOSITING) diff --git a/geometry.cpp b/geometry.cpp index 57f17ff4ce..b45f51cad5 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -40,7 +40,8 @@ along with this program. If not, see . #include "rules.h" #include "effects.h" #include -#include + +#include namespace KWin { @@ -54,7 +55,7 @@ namespace KWin */ void Workspace::desktopResized() { - QRect geom = QApplication::desktop()->geometry(); + QRect geom = Kephal::ScreenUtils::desktopGeometry(); NETSize desktop_geometry; desktop_geometry.width = geom.width(); desktop_geometry.height = geom.height(); @@ -84,18 +85,17 @@ void Workspace::desktopResized() void Workspace::updateClientArea( bool force ) { - QDesktopWidget *desktopwidget = KApplication::desktop(); - int nscreens = desktopwidget -> numScreens (); -// kDebug () << "screens: " << nscreens; + int nscreens = Kephal::ScreenUtils::numScreens(); + kDebug() << "screens: " << nscreens << "desktops: " << numberOfDesktops(); QVector< QRect > new_wareas( numberOfDesktops() + 1 ); QVector< QVector< QRect > > new_sareas( numberOfDesktops() + 1 ); QVector< QRect > screens( nscreens ); - QRect desktopArea = desktopwidget -> geometry (); + QRect desktopArea = Kephal::ScreenUtils::desktopGeometry(); for( int iS = 0; iS < nscreens; iS ++ ) { - screens [iS] = desktopwidget -> screenGeometry (iS); + screens [iS] = Kephal::ScreenUtils::screenGeometry( iS ); } for( int i = 1; i <= numberOfDesktops(); @@ -230,12 +230,11 @@ QRect Workspace::clientArea( clientAreaOption opt, int screen, int desktop ) con desktop = currentDesktop(); if( screen == -1 ) screen = activeScreen(); - QDesktopWidget *desktopwidget = KApplication::desktop(); QRect sarea = !screenarea.isEmpty() // may be empty during KWin initialization ? screenarea[ desktop ][ screen ] - : desktopwidget->screenGeometry( screen ); + : Kephal::ScreenUtils::screenGeometry( screen ); QRect warea = workarea[ desktop ].isNull() - ? QApplication::desktop()->geometry() + ? Kephal::ScreenUtils::desktopGeometry() : workarea[ desktop ]; switch (opt) { @@ -246,14 +245,14 @@ QRect Workspace::clientArea( clientAreaOption opt, int screen, int desktop ) con return warea; case MaximizeFullArea: if (options->xineramaMaximizeEnabled) - return desktopwidget->screenGeometry( screen ); + return Kephal::ScreenUtils::screenGeometry( screen ); else - return desktopwidget->geometry(); + return Kephal::ScreenUtils::desktopGeometry(); case FullScreenArea: if (options->xineramaFullscreenEnabled) - return desktopwidget->screenGeometry( screen ); + return Kephal::ScreenUtils::screenGeometry( screen ); else - return desktopwidget->geometry(); + return Kephal::ScreenUtils::desktopGeometry(); case PlacementArea: if (options->xineramaPlacementEnabled) return sarea; @@ -261,25 +260,22 @@ QRect Workspace::clientArea( clientAreaOption opt, int screen, int desktop ) con return warea; case MovementArea: if (options->xineramaMovementEnabled) - return desktopwidget->screenGeometry( screen ); + return Kephal::ScreenUtils::screenGeometry( screen ); else - return desktopwidget->geometry(); + return Kephal::ScreenUtils::desktopGeometry(); case WorkArea: return warea; case FullArea: - return desktopwidget->geometry(); + return Kephal::ScreenUtils::desktopGeometry(); case ScreenArea: - return desktopwidget->screenGeometry( screen ); + return Kephal::ScreenUtils::screenGeometry( screen ); } abort(); } QRect Workspace::clientArea( clientAreaOption opt, const QPoint& p, int desktop ) const { - QDesktopWidget *desktopwidget = KApplication::desktop(); - int screen = desktopwidget->isVirtualDesktop() ? desktopwidget->screenNumber( p ) : desktopwidget->primaryScreen(); - if( screen < 0 ) - screen = desktopwidget->primaryScreen(); + int screen = Kephal::ScreenUtils::screenId( p ); return clientArea( opt, screen, desktop ); } @@ -871,7 +867,7 @@ QRect Client::adjustedClientArea( const QRect &desktopArea, const QRect& area ) // HACK: workarea handling is not xinerama aware, so if this strut // reserves place at a xinerama edge that's inside the virtual screen, // ignore the strut for workspace setting. - if( area == kapp->desktop()->geometry()) + if( area == Kephal::ScreenUtils::desktopGeometry()) { if( stareaL.left() < screenarea.left()) stareaL = QRect(); @@ -992,17 +988,7 @@ int Client::computeWorkareaDiff( int left, int right, int a_left, int a_right ) void Client::checkWorkspacePosition() { if( isDesktop()) - { - if (geometry() == workspace()->clientArea( ScreenArea, this )) - { - return; - } - - QRect area = workspace()->clientArea( FullArea, this ); - if( geometry() != area ) - setGeometry( area ); return; - } if( isFullScreen()) { QRect area = workspace()->clientArea( FullScreenArea, this ); diff --git a/kcmkwin/kwinoptions/CMakeLists.txt b/kcmkwin/kwinoptions/CMakeLists.txt index 41a52b77ea..319ab47efd 100644 --- a/kcmkwin/kwinoptions/CMakeLists.txt +++ b/kcmkwin/kwinoptions/CMakeLists.txt @@ -2,7 +2,7 @@ set(kcm_kwinoptions_PART_SRCS windows.cpp mouse.cpp main.cpp ) kde4_add_plugin(kcm_kwinoptions ${kcm_kwinoptions_PART_SRCS}) -target_link_libraries(kcm_kwinoptions ${KDE4_KDEUI_LIBS}) +target_link_libraries(kcm_kwinoptions ${KDE4_KDEUI_LIBS} kephal) install(TARGETS kcm_kwinoptions DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kcmkwin/kwinoptions/windows.cpp b/kcmkwin/kwinoptions/windows.cpp index a9be626e8b..88e68f5166 100644 --- a/kcmkwin/kwinoptions/windows.cpp +++ b/kcmkwin/kwinoptions/windows.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -44,6 +43,8 @@ #include "windows.h" +#include + // kwin config keywords #define KWIN_FOCUS "FocusPolicy" #define KWIN_PLACEMENT "Placement" @@ -257,8 +258,7 @@ KFocusConfig::KFocusConfig (bool _standAlone, KConfig *_config, const KComponent activeMouseScreen->setWhatsThis( wtstr ); connect(focusCombo, SIGNAL(activated(int)), this, SLOT(updateActiveMouseScreen())); - if (!QApplication::desktop()->isVirtualDesktop() || - QApplication::desktop()->numScreens() == 1) // No Ximerama + if (Kephal::ScreenUtils::numScreens() == 1) // No Ximerama { separateScreenFocus->hide(); activeMouseScreen->hide(); diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 1ab7e7b412..c1119a2443 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -11,7 +11,7 @@ set(kdecorations_LIB_SRCS kde4_add_library(kdecorations SHARED ${kdecorations_LIB_SRCS}) -target_link_libraries(kdecorations ${KDE4_KDEUI_LIBS}) +target_link_libraries(kdecorations ${KDE4_KDEUI_LIBS} kephal) set_target_properties(kdecorations PROPERTIES VERSION ${GENERIC_LIB_VERSION} @@ -40,7 +40,7 @@ set(kwin_EFFECTSLIB_SRCS ) kde4_add_library(kwineffects SHARED ${kwin_EFFECTSLIB_SRCS}) -target_link_libraries(kwineffects ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY} ${X11_LIBRARIES}) +target_link_libraries(kwineffects ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY} ${X11_LIBRARIES} kephal) set_target_properties(kwineffects PROPERTIES VERSION 1.0.0 SOVERSION 1 ) install(TARGETS kwineffects ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/lib/kcommondecoration.cpp b/lib/kcommondecoration.cpp index 2330119a39..35a8779f10 100644 --- a/lib/kcommondecoration.cpp +++ b/lib/kcommondecoration.cpp @@ -37,7 +37,8 @@ #include #include "kdecorationfactory.h" #include -#include + +#include #include "kcommondecoration.moc" @@ -799,11 +800,10 @@ void KCommonDecoration::updateWindowShape() bool tl=true,tr=true,bl=true,br=true; // is there a transparent rounded corner in top-left? etc - QDesktopWidget *desktop=KApplication::desktop(); // no transparent rounded corners if this window corner lines up with a screen corner - for(int screen=0; screen < desktop->numScreens(); ++screen) + for(int screen=0; screen < Kephal::ScreenUtils::numScreens(); ++screen) { - QRect fullscreen(desktop->screenGeometry(screen)); + QRect fullscreen(Kephal::ScreenUtils::screenGeometry(screen)); QRect window = geometry(); if(window.topLeft() == fullscreen.topLeft() ) tl = false; diff --git a/manage.cpp b/manage.cpp index 832fc4fd44..8661d8e9df 100644 --- a/manage.cpp +++ b/manage.cpp @@ -234,11 +234,7 @@ bool Client::manage( Window w, bool isMapped ) if ( isDesktop() ) { - // desktops are treated slightly special - if (geom != workspace()->clientArea( ScreenArea, geom.center(), desktop())) - { - geom = workspace()->clientArea( FullArea, geom.center(), desktop()); - } + // kwin doesn't manage desktop windows placementDone = true; } diff --git a/workspace.cpp b/workspace.cpp index 9dbdd2154f..d151e009a9 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -36,7 +36,6 @@ along with this program. If not, see . #include #include #include -#include #include #include #include @@ -67,6 +66,8 @@ along with this program. If not, see . #include #include +#include + namespace KWin { @@ -176,8 +177,6 @@ Workspace::Workspace( bool restore ) loadWindowRules(); - (void) QApplication::desktop(); // trigger creation of desktop widget - // call this before XSelectInput() on the root window startup = new KStartupInfo( KStartupInfo::DisableKWinModule | KStartupInfo::AnnounceSilenceChanges, this ); @@ -217,7 +216,10 @@ Workspace::Workspace( bool restore ) init(); - connect( kapp->desktop(), SIGNAL( resized( int )), SLOT( desktopResized())); + connect( Kephal::Screens::self(), SIGNAL( screenAdded( Kephal::Screen *)), SLOT( desktopResized())); + connect( Kephal::Screens::self(), SIGNAL( screenRemoved(int)), SLOT( desktopResized())); + connect( Kephal::Screens::self(), SIGNAL( screenResized( Kephal::Screen *, QSize, QSize)), SLOT( desktopResized())); + connect( Kephal::Screens::self(), SIGNAL( screenMoved( Kephal::Screen *, QPoint, QPoint)), SLOT( desktopResized())); } void Workspace::init() @@ -405,7 +407,7 @@ void Workspace::init() NETPoint* viewports = new NETPoint[ number_of_desktops ]; rootInfo->setDesktopViewport( number_of_desktops, *viewports ); delete[] viewports; - QRect geom = QApplication::desktop()->geometry(); + QRect geom = Kephal::ScreenUtils::desktopGeometry(); NETSize desktop_geometry; desktop_geometry.width = geom.width(); desktop_geometry.height = geom.height(); @@ -1017,7 +1019,7 @@ void Workspace::slotReconfigure() #if 0 // This actually seems to make things worse now QWidget curtain; curtain.setBackgroundMode( NoBackground ); - curtain.setGeometry( QApplication::desktop()->geometry() ); + curtain.setGeometry( Kephal::ScreenUtils::desktopGeometry() ); curtain.show(); #endif for( ClientList::ConstIterator it = clients.constBegin(); @@ -1205,7 +1207,7 @@ bool Workspace::isNotManaged( const QString& title ) void Workspace::refresh() { QWidget w( NULL, Qt::X11BypassWindowManagerHint ); - w.setGeometry( QApplication::desktop()->geometry() ); + w.setGeometry( Kephal::ScreenUtils::desktopGeometry() ); w.show(); w.hide(); QApplication::flush(); @@ -1646,7 +1648,7 @@ int Workspace::numScreens() const { if( !options->xineramaEnabled ) return 1; - return qApp->desktop()->numScreens(); + return Kephal::ScreenUtils::numScreens(); } int Workspace::activeScreen() const @@ -1659,7 +1661,7 @@ int Workspace::activeScreen() const return activeClient()->screen(); return active_screen; } - return qApp->desktop()->screenNumber( cursorPos()); + return Kephal::ScreenUtils::screenId( cursorPos()); } // check whether a client moved completely out of what's considered the active screen, @@ -1680,21 +1682,21 @@ void Workspace::setActiveScreenMouse( const QPoint &mousepos ) { if( !options->xineramaEnabled ) return; - active_screen = qApp->desktop()->screenNumber( mousepos ); + active_screen = Kephal::ScreenUtils::screenId( mousepos ); } QRect Workspace::screenGeometry( int screen ) const { if( !options->xineramaEnabled ) - return qApp->desktop()->geometry(); - return qApp->desktop()->screenGeometry( screen ); + return Kephal::ScreenUtils::desktopGeometry(); + return Kephal::ScreenUtils::screenGeometry( screen ); } int Workspace::screenNumber( const QPoint &pos ) const { if( !options->xineramaEnabled ) return 0; - return qApp->desktop()->screenNumber( pos ); + return Kephal::ScreenUtils::screenId( pos ); } void Workspace::sendClientToScreen( Client* c, int screen ) @@ -2106,7 +2108,7 @@ void Workspace::updateElectricBorders() electric_time_first = xTime(); electric_time_last = xTime(); electric_current_border = ElectricNone; - QRect r = QApplication::desktop()->geometry(); + QRect r = Kephal::ScreenUtils::desktopGeometry(); electricTop = r.top(); electricBottom = r.bottom(); electricLeft = r.left();