Split out screen handling from Workspace into own class Screens

Following the approaches of other split out functionality Screens is a
singleton class created by Workspace.

The class takes over the responsibility for:
* screenChanged signal delayed by timer
* number of screens
* geometry of given screen
* active screen
* config option for active screen follows mouse

The class contains a small abstraction layer and has a concrete subclass
wrapping around QDesktopWidget, but the idea is to go more low level and
interact with XRandR directly to get more detailed information.

All over KWin the usage from QDesktopWidget is ported over to the new
Screens class.

REVIEW: 109839
icc-effect-5.14.5
Martin Gräßlin 2013-04-03 12:19:27 +02:00
parent 27627bdccb
commit edb074cbc2
24 changed files with 417 additions and 214 deletions

View File

@ -112,6 +112,7 @@ set(kwin_KDEINIT_SRCS
events.cpp
killwindow.cpp
geometrytip.cpp
screens.cpp
shadow.cpp
sm.cpp
group.cpp

View File

@ -44,6 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "atoms.h"
#include "group.h"
#include "rules.h"
#include "screens.h"
#include "useractions.h"
#include <QX11Info>
@ -378,8 +379,8 @@ void Workspace::takeActivity(Client* c, int flags, bool handled)
return;
}
c->takeActivity(flags, handled, Allowed);
if (!c->isOnScreen(active_screen))
active_screen = c->screen();
if (!c->isOnActiveScreen())
screens()->setCurrent(c->screen());
}
void Workspace::handleTakeActivity(Client* c, Time /*timestamp*/, int flags)
@ -465,7 +466,7 @@ bool Workspace::activateNextClient(Client* c)
}
if (!get_focus && options->isNextFocusPrefersMouse()) {
get_focus = clientUnderMouse(c ? c->screen() : activeScreen());
get_focus = clientUnderMouse(c ? c->screen() : screens()->current());
if (get_focus && (get_focus == c || get_focus->isDesktop())) {
// should rather not happen, but it cannot get the focus. rest of usability is tested above
get_focus = NULL;
@ -498,7 +499,7 @@ bool Workspace::activateNextClient(Client* c)
void Workspace::setCurrentScreen(int new_screen)
{
if (new_screen < 0 || new_screen >= numScreens())
if (new_screen < 0 || new_screen >= screens()->count())
return;
if (!options->focusPolicyIsReasonable())
return;
@ -509,7 +510,7 @@ void Workspace::setCurrentScreen(int new_screen)
get_focus = findDesktop(true, desktop);
if (get_focus != NULL && get_focus != mostRecentlyActivatedClient())
requestFocus(get_focus);
active_screen = new_screen;
screens()->setCurrent(new_screen);
}
void Workspace::gotFocusIn(const Client* c)

View File

@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef KWIN_BUILD_SCRIPTING
#include "scripting/scriptedeffect.h"
#endif
#include "screens.h"
#include "thumbnailitem.h"
#include "virtualdesktops.h"
#include "workspace.h"
@ -1079,17 +1080,17 @@ void EffectsHandlerImpl::addRepaint(int x, int y, int w, int h)
int EffectsHandlerImpl::activeScreen() const
{
return Workspace::self()->activeScreen();
return screens()->current();
}
int EffectsHandlerImpl::numScreens() const
{
return Workspace::self()->numScreens();
return screens()->count();
}
int EffectsHandlerImpl::screenNumber(const QPoint& pos) const
{
return Workspace::self()->screenNumber(pos);
return screens()->number(pos);
}
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, int screen, int desktop) const

View File

@ -45,11 +45,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef KWIN_BUILD_SCREENEDGES
#include "screenedge.h"
#endif
#include "screens.h"
#include "xcbutils.h"
#include <QWhatsThis>
#include <QApplication>
#include <QDesktopWidget>
#include <kkeyserver.h>
@ -1348,9 +1347,9 @@ void Client::checkQuickTilingMaximizationZones(int xroot, int yroot)
{
QuickTileMode mode = QuickTileNone;
for (int i=0; i<QApplication::desktop()->screenCount(); ++i) {
for (int i=0; i<screens()->count(); ++i) {
const QRect &area = QApplication::desktop()->screenGeometry(i);
const QRect &area = screens()->geometry(i);
if (!area.contains(QPoint(xroot, yroot)))
continue;

View File

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "focuschain.h"
#include "client.h"
#include "screens.h"
namespace KWin
{
@ -60,7 +61,7 @@ void FocusChain::resize(uint previousSize, uint newSize)
Client *FocusChain::getForActivation(uint desktop) const
{
return getForActivation(desktop, Workspace::self()->activeScreen());
return getForActivation(desktop, screens()->current());
}
Client *FocusChain::getForActivation(uint desktop, int screen) const
@ -212,7 +213,7 @@ bool FocusChain::isUsableFocusCandidate(Client *c, Client *prev) const
{
return c != prev &&
c->isShown(false) && c->isOnCurrentDesktop() && c->isOnCurrentActivity() &&
(!m_separateScreenFocus || c->isOnScreen(prev ? prev->screen() : Workspace::self()->activeScreen()));
(!m_separateScreenFocus || c->isOnScreen(prev ? prev->screen() : screens()->current()));
}
Client *FocusChain::nextForDesktop(Client *reference, uint desktop) const

View File

@ -40,6 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "notifications.h"
#include "geometrytip.h"
#include "rules.h"
#include "screens.h"
#include "effects.h"
#ifdef KWIN_BUILD_SCREENEDGES
#include "screenedge.h"
@ -68,7 +69,7 @@ extern bool is_multihead;
void Workspace::desktopResized()
{
QRect geom;
for (int i = 0; i < QApplication::desktop()->screenCount(); i++) {
for (int i = 0; i < screens()->count(); i++) {
//do NOT use - QApplication::desktop()->screenGeometry(i) there could be a virtual geometry
// see bug #302783
geom |= QApplication::desktop()->screen(i)->geometry();
@ -99,9 +100,9 @@ void Workspace::saveOldScreenSizes()
olddisplaysize = QSize( displayWidth(), displayHeight());
oldscreensizes.clear();
for( int i = 0;
i < numScreens();
i < screens()->count();
++i )
oldscreensizes.append( screenGeometry( i ));
oldscreensizes.append( screens()->geometry( i ));
}
/*!
@ -118,7 +119,8 @@ void Workspace::saveOldScreenSizes()
void Workspace::updateClientArea(bool force)
{
int nscreens = QApplication::desktop()->screenCount();
const Screens *s = Screens::self();
int nscreens = s->count();
const int numberOfDesktops = VirtualDesktopManager::self()->count();
kDebug(1212) << "screens: " << nscreens << "desktops: " << numberOfDesktops;
QVector< QRect > new_wareas(numberOfDesktops + 1);
@ -126,13 +128,13 @@ void Workspace::updateClientArea(bool force)
QVector< QVector< QRect > > new_sareas(numberOfDesktops + 1);
QVector< QRect > screens(nscreens);
QRect desktopArea;
for (int i = 0; i < QApplication::desktop()->screenCount(); i++) {
desktopArea |= QApplication::desktop()->screenGeometry(i);
for (int i = 0; i < nscreens; i++) {
desktopArea |= s->geometry(i);
}
for (int iS = 0;
iS < nscreens;
iS ++) {
screens [iS] = QApplication::desktop()->screenGeometry(iS);
screens [iS] = s->geometry(iS);
}
for (int i = 1;
i <= numberOfDesktops;
@ -266,7 +268,7 @@ QRect Workspace::clientArea(clientAreaOption opt, int screen, int desktop) const
if (desktop == NETWinInfo::OnAllDesktops || desktop == 0)
desktop = VirtualDesktopManager::self()->current();
if (screen == -1)
screen = activeScreen();
screen = screens()->current();
QRect sarea, warea;
@ -274,15 +276,15 @@ QRect Workspace::clientArea(clientAreaOption opt, int screen, int desktop) const
sarea = (!screenarea.isEmpty()
&& screen < screenarea[ desktop ].size()) // screens may be missing during KWin initialization or screen config changes
? screenarea[ desktop ][ screen_number ]
: QApplication::desktop()->screenGeometry(screen_number);
: screens()->geometry(screen_number);
warea = workarea[ desktop ].isNull()
? QApplication::desktop()->screenGeometry(screen_number)
? screens()->geometry(screen_number)
: workarea[ desktop ];
} else {
sarea = (!screenarea.isEmpty()
&& screen < screenarea[ desktop ].size()) // screens may be missing during KWin initialization or screen config changes
? screenarea[ desktop ][ screen ]
: QApplication::desktop()->screenGeometry(screen);
: screens()->geometry(screen);
warea = workarea[ desktop ].isNull()
? QRect(0, 0, displayWidth(), displayHeight())
: workarea[ desktop ];
@ -297,9 +299,9 @@ QRect Workspace::clientArea(clientAreaOption opt, int screen, int desktop) const
case MovementArea:
case ScreenArea:
if (is_multihead)
return QApplication::desktop()->screenGeometry(screen_number);
return screens()->geometry(screen_number);
else
return QApplication::desktop()->screenGeometry(screen);
return screens()->geometry(screen);
case WorkArea:
if (is_multihead)
return sarea;
@ -314,8 +316,7 @@ QRect Workspace::clientArea(clientAreaOption opt, int screen, int desktop) const
QRect Workspace::clientArea(clientAreaOption opt, const QPoint& p, int desktop) const
{
int screen = QApplication::desktop()->screenNumber(p);
return clientArea(opt, screen, desktop);
return clientArea(opt, screens()->number(p), desktop);
}
QRect Workspace::clientArea(clientAreaOption opt, const Client* c) const
@ -1029,9 +1030,8 @@ bool Client::hasOffscreenXineramaStrut() const
region += strutRect(StrutAreaLeft);
// Remove all visible areas so that only the invisible remain
int numScreens = QApplication::desktop()->screenCount();
for (int i = 0; i < numScreens; i ++)
region -= QApplication::desktop()->screenGeometry(i);
for (int i = 0; i < screens()->count(); i ++)
region -= screens()->geometry(i);
// If there's anything left then we have an offscreen strut
return !region.isEmpty();
@ -1651,7 +1651,7 @@ void Client::configureRequest(int value_mask, int rx, int ry, int rw, int rh, in
nh = rh;
QSize ns = sizeForClientSize(QSize(nw, nh)); // enforces size if needed
new_pos = rules()->checkPosition(new_pos);
int newScreen = workspace()->screenNumber(QRect(new_pos, ns).center());
int newScreen = screens()->number(QRect(new_pos, ns).center());
if (newScreen != rules()->checkScreen(newScreen))
return; // not allowed by rule
@ -1931,7 +1931,7 @@ void Client::setGeometry(int x, int y, int w, int h, ForceGeometry_t force)
// keep track of old maximize mode
// to detect changes
workspace()->checkActiveScreen(this);
screens()->setCurrent(this);
workspace()->updateStackingOrder();
// need to regenerate decoration pixmaps when either
@ -2004,7 +2004,7 @@ void Client::plainResize(int w, int h, ForceGeometry_t force)
sendSyntheticConfigureNotify();
updateWindowRules(Rules::Position|Rules::Size);
workspace()->checkActiveScreen(this);
screens()->setCurrent(this);
workspace()->updateStackingOrder();
discardWindowPixmap();
emit geometryShapeChanged(this, geom_before_block);
@ -2048,7 +2048,7 @@ void Client::move(int x, int y, ForceGeometry_t force)
XMoveWindow(display(), frameId(), x, y);
sendSyntheticConfigureNotify();
updateWindowRules(Rules::Position);
workspace()->checkActiveScreen(this);
screens()->setCurrent(this);
workspace()->updateStackingOrder();
if (Compositor::isCreated()) {
// TODO: move out of geometry.cpp, is this really needed here?
@ -2438,7 +2438,7 @@ void Client::setFullScreen(bool set, bool user)
void Client::updateFullscreenMonitors(NETFullscreenMonitors topology)
{
int nscreens = QApplication::desktop()->screenCount();
int nscreens = screens()->count();
// kDebug( 1212 ) << "incoming request with top: " << topology.top << " bottom: " << topology.bottom
// << " left: " << topology.left << " right: " << topology.right
@ -2466,10 +2466,10 @@ QRect Client::fullscreenMonitorsArea(NETFullscreenMonitors requestedTopology) co
{
QRect top, bottom, left, right, total;
top = QApplication::desktop()->screenGeometry(requestedTopology.top);
bottom = QApplication::desktop()->screenGeometry(requestedTopology.bottom);
left = QApplication::desktop()->screenGeometry(requestedTopology.left);
right = QApplication::desktop()->screenGeometry(requestedTopology.right);
top = screens()->geometry(requestedTopology.top);
bottom = screens()->geometry(requestedTopology.bottom);
left = screens()->geometry(requestedTopology.left);
right = screens()->geometry(requestedTopology.right);
total = top.united(bottom.united(left.united(right)));
// kDebug( 1212 ) << "top: " << top << " bottom: " << bottom
@ -2958,7 +2958,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root)
assert(mode == PositionCenter);
if (!isMovable()) { // isMovableAcrossScreens() must have been true to get here
// Special moving of maximized windows on Xinerama screens
int screen = workspace()->screenNumber(globalPos);
int screen = screens()->number(globalPos);
if (isFullScreen())
moveResizeGeom = workspace()->clientArea(FullScreenArea, screen, 0);
else {
@ -3003,7 +3003,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root)
// by moving the window slightly downwards, but it won't stuck)
// see bug #274466
// and bug #301805 for why we can't just match the titlearea against the screen
if (QApplication::desktop()->screenCount() > 1) { // optimization
if (screens()->count() > 1) { // optimization
// TODO: could be useful on partial screen struts (half-width panels etc.)
int newTitleTop = -1;
foreach (const QRect &r, strut.rects()) {
@ -3205,12 +3205,12 @@ void Client::setQuickTileMode(QuickTileMode mode, bool keyboard)
// If trying to tile to the side that the window is already tiled to move the window to the next
// screen if it exists, otherwise ignore the request to prevent corrupting geom_restore.
if (quick_tile_mode == mode) {
const int numScreens = QApplication::desktop()->screenCount();
const int numScreens = screens()->count();
const int curScreen = screen();
int nextScreen = curScreen;
QVarLengthArray<QRect> screens(numScreens);
for (int i = 0; i < numScreens; ++i) // Cache
screens[i] = QApplication::desktop()->screenGeometry(i);
screens[i] = Screens::self()->geometry(i);
for (int i = 0; i < numScreens; ++i) {
if (i == curScreen)
continue;

View File

@ -83,6 +83,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "tabbox.h"
#include "group.h"
#include "rules.h"
#include "screens.h"
#include "unmanaged.h"
#include "deleted.h"
#include "effects.h"
@ -509,7 +510,7 @@ ToplevelList Workspace::constrainedStackingOrder()
kDebug(1212) << (void*)(*it) << *it << ":" << (*it)->layer();
#endif
// build the order from layers
QVector< QMap<Group*, Layer> > minimum_layer(numScreens());
QVector< QMap<Group*, Layer> > minimum_layer(screens()->count());
for (ToplevelList::ConstIterator it = unconstrained_stacking_order.constBegin(),
end = unconstrained_stacking_order.constEnd(); it != end; ++it) {
Layer l = (*it)->layer();

View File

@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QX11Info>
#include "rules.h"
#include "group.h"
#include "screens.h"
#include "xcbutils.h"
namespace KWin
@ -238,9 +239,9 @@ bool Client::manage(Window w, bool isMapped)
if (isMapped || session)
area = workspace()->clientArea(FullArea, geom.center(), desktop());
else {
int screen = asn_data.xinerama() == -1 ? workspace()->activeScreen() : asn_data.xinerama();
int screen = asn_data.xinerama() == -1 ? screens()->current() : asn_data.xinerama();
screen = rules()->checkScreen(screen, !isMapped);
area = workspace()->clientArea(PlacementArea, workspace()->screenGeometry(screen).center(), desktop());
area = workspace()->clientArea(PlacementArea, screens()->geometry(screen).center(), desktop());
}
if (int type = checkFullScreenHack(geom)) {

View File

@ -34,8 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kglobalsettings.h>
#include <klocale.h>
#include <QDesktopWidget>
#include "client.h"
#include "compositingprefs.h"
#include "settings.h"
@ -130,7 +128,6 @@ Options::Options(QObject *parent)
, m_shadeHover(false)
, m_shadeHoverInterval(0)
, m_separateScreenFocus(false)
, m_activeMouseScreen(false)
, m_placement(Placement::NoPlacement)
, m_borderSnapZone(0)
, m_windowSnapZone(0)
@ -297,15 +294,6 @@ void Options::setSeparateScreenFocus(bool separateScreenFocus)
emit separateScreenFocusChanged(m_separateScreenFocus);
}
void Options::setActiveMouseScreen(bool activeMouseScreen)
{
if (m_activeMouseScreen == activeMouseScreen) {
return;
}
m_activeMouseScreen = activeMouseScreen;
emit activeMouseScreenChanged();
}
void Options::setPlacement(int placement)
{
if (m_placement == static_cast<Placement::Policy>(placement)) {
@ -855,7 +843,6 @@ void Options::syncFromKcfgc()
setFocusPolicy(m_settings->focusPolicy());
setNextFocusPrefersMouse(m_settings->nextFocusPrefersMouse());
setSeparateScreenFocus(m_settings->separateScreenFocus());
setActiveMouseScreen(m_settings->activeMouseScreen());
setRollOverDesktops(m_settings->rollOverDesktops());
setLegacyFullscreenSupport(m_settings->legacyFullscreenSupport());
setFocusStealingPreventionLevel(m_settings->focusStealingPreventionLevel());

View File

@ -77,10 +77,6 @@ class Options : public QObject, public KDecorationOptions
* whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client)
**/
Q_PROPERTY(bool separateScreenFocus READ isSeparateScreenFocus WRITE setSeparateScreenFocus NOTIFY separateScreenFocusChanged)
/**
* whether active Xinerama screen is the one with mouse (or with the active window)
**/
Q_PROPERTY(bool activeMouseScreen READ isActiveMouseScreen WRITE setActiveMouseScreen NOTIFY activeMouseScreenChanged)
Q_PROPERTY(int placement READ placement WRITE setPlacement NOTIFY placementChanged)
Q_PROPERTY(bool focusPolicyIsReasonable READ focusPolicyIsReasonable NOTIFY configChanged)
/**
@ -281,10 +277,6 @@ public:
bool isSeparateScreenFocus() const {
return m_separateScreenFocus;
}
// whether active Xinerama screen is the one with mouse (or with the active window)
bool isActiveMouseScreen() const {
return m_activeMouseScreen;
}
Placement::Policy placement() const {
return m_placement;
@ -562,7 +554,6 @@ public:
void setShadeHover(bool shadeHover);
void setShadeHoverInterval(int shadeHoverInterval);
void setSeparateScreenFocus(bool separateScreenFocus);
void setActiveMouseScreen(bool activeMouseScreen);
void setPlacement(int placement);
void setBorderSnapZone(int borderSnapZone);
void setWindowSnapZone(int windowSnapZone);
@ -748,7 +739,6 @@ Q_SIGNALS:
void shadeHoverChanged();
void shadeHoverIntervalChanged();
void separateScreenFocusChanged(bool);
void activeMouseScreenChanged();
void placementChanged();
void borderSnapZoneChanged();
void windowSnapZoneChanged();
@ -817,7 +807,6 @@ private:
bool m_shadeHover;
int m_shadeHoverInterval;
bool m_separateScreenFocus;
bool m_activeMouseScreen;
Placement::Policy m_placement;
int m_borderSnapZone;
int m_windowSnapZone;

View File

@ -28,9 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <ktoolinvocation.h>
#ifndef KCMRULES
#include <QDesktopWidget>
#include "client.h"
#include "client_machine.h"
#include "screens.h"
#include "workspace.h"
#endif
@ -808,7 +808,7 @@ int WindowRules::checkScreen(int screen, bool init) const
if ( (*it)->applyScreen( ret, init ))
break;
}
if (ret >= QApplication::desktop()->screenCount())
if (ret >= Screens::self()->count())
ret = screen;
return ret;
}

View File

@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "lanczosfilter.h"
#include "overlaywindow.h"
#include "paintredirector.h"
#include "screens.h"
#include <math.h>
@ -56,7 +57,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QDBusConnectionInterface>
#include <QDBusInterface>
#include <QGraphicsScale>
#include <QDesktopWidget>
#include <QStringList>
#include <QVector2D>
#include <QVector4D>
@ -650,11 +650,11 @@ void SceneOpenGL2::finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region
{
if (m_colorCorrection->isEnabled()) {
// Split the painting for separate screens
int numScreens = Workspace::self()->numScreens();
const int numScreens = screens()->count();
for (int screen = 0; screen < numScreens; ++ screen) {
QRegion regionForScreen(region);
if (numScreens > 1)
regionForScreen = region.intersected(Workspace::self()->screenGeometry(screen));
regionForScreen = region.intersected(screens()->geometry(screen));
data.setScreen(screen);
performPaintWindow(w, mask, regionForScreen, data);
@ -670,8 +670,7 @@ void SceneOpenGL2::performPaintWindow(EffectWindowImpl* w, int mask, QRegion reg
if (!m_lanczosFilter) {
m_lanczosFilter = new LanczosFilter(this);
// recreate the lanczos filter when the screen gets resized
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(resetLanczosFilter()));
connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(resetLanczosFilter()));
connect(screens(), SIGNAL(changed()), SLOT(resetLanczosFilter()));
}
m_lanczosFilter->performPaint(w, mask, region, data);
} else

View File

@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "client.h"
#include "cursor.h"
#include "effects.h"
#include "screens.h"
#include "utils.h"
#include "workspace.h"
#include "virtualdesktops.h"
@ -43,7 +44,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QTextStream>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusPendingCall>
#include <QDesktopWidget>
namespace KWin {
@ -676,8 +676,7 @@ void ScreenEdges::updateLayout()
static bool isLeftScreen(const QRect &screen, const QRect &fullArea)
{
const QDesktopWidget *desktop = QApplication::desktop();
if (desktop->screenCount() == 1) {
if (screens()->count() == 1) {
return true;
}
if (screen.x() == fullArea.x()) {
@ -685,8 +684,8 @@ static bool isLeftScreen(const QRect &screen, const QRect &fullArea)
}
// the screen is also on the left in case of a vertical layout with a second screen
// more to the left. In that case no screen ends left of screen's x coord
for (int i=0; i<desktop->screenCount(); ++i) {
const QRect otherGeo = desktop->screenGeometry(i);
for (int i=0; i<screens()->count(); ++i) {
const QRect otherGeo = screens()->geometry(i);
if (otherGeo == screen) {
// that's our screen to test
continue;
@ -702,8 +701,7 @@ static bool isLeftScreen(const QRect &screen, const QRect &fullArea)
static bool isRightScreen(const QRect &screen, const QRect &fullArea)
{
const QDesktopWidget *desktop = QApplication::desktop();
if (desktop->screenCount() == 1) {
if (screens()->count() == 1) {
return true;
}
if (screen.x() + screen.width() == fullArea.x() + fullArea.width()) {
@ -711,8 +709,8 @@ static bool isRightScreen(const QRect &screen, const QRect &fullArea)
}
// the screen is also on the right in case of a vertical layout with a second screen
// more to the right. In that case no screen starts right of this screen
for (int i=0; i<desktop->screenCount(); ++i) {
const QRect otherGeo = desktop->screenGeometry(i);
for (int i=0; i<screens()->count(); ++i) {
const QRect otherGeo = screens()->geometry(i);
if (otherGeo == screen) {
// that's our screen to test
continue;
@ -728,8 +726,7 @@ static bool isRightScreen(const QRect &screen, const QRect &fullArea)
static bool isTopScreen(const QRect &screen, const QRect &fullArea)
{
const QDesktopWidget *desktop = QApplication::desktop();
if (desktop->screenCount() == 1) {
if (screens()->count() == 1) {
return true;
}
if (screen.y() == fullArea.y()) {
@ -737,8 +734,8 @@ static bool isTopScreen(const QRect &screen, const QRect &fullArea)
}
// the screen is also top most in case of a horizontal layout with a second screen
// more to the top. In that case no screen ends above screen's y coord
for (int i=0; i<desktop->screenCount(); ++i) {
const QRect otherGeo = desktop->screenGeometry(i);
for (int i=0; i<screens()->count(); ++i) {
const QRect otherGeo = screens()->geometry(i);
if (otherGeo == screen) {
// that's our screen to test
continue;
@ -754,8 +751,7 @@ static bool isTopScreen(const QRect &screen, const QRect &fullArea)
static bool isBottomScreen(const QRect &screen, const QRect &fullArea)
{
const QDesktopWidget *desktop = QApplication::desktop();
if (desktop->screenCount() == 1) {
if (screens()->count() == 1) {
return true;
}
if (screen.y() + screen.height() == fullArea.y() + fullArea.height()) {
@ -763,8 +759,8 @@ static bool isBottomScreen(const QRect &screen, const QRect &fullArea)
}
// the screen is also bottom most in case of a horizontal layout with a second screen
// more below. In that case no screen starts below screen's y coord + height
for (int i=0; i<desktop->screenCount(); ++i) {
const QRect otherGeo = desktop->screenGeometry(i);
for (int i=0; i<screens()->count(); ++i) {
const QRect otherGeo = screens()->geometry(i);
if (otherGeo == screen) {
// that's our screen to test
continue;
@ -783,9 +779,8 @@ void ScreenEdges::recreateEdges()
QList<WindowBasedEdge*> oldEdges(m_edges);
m_edges.clear();
const QRect fullArea(0, 0, displayWidth(), displayHeight());
const QDesktopWidget *desktop = QApplication::desktop();
for (int i=0; i<desktop->screenCount(); ++i) {
const QRect screen = desktop->screenGeometry(i);
for (int i=0; i<screens()->count(); ++i) {
const QRect screen = screens()->geometry(i);
if (isLeftScreen(screen, fullArea)) {
// left most screen
createVerticalEdge(ElectricLeft, screen, fullArea);

147
screens.cpp Normal file
View File

@ -0,0 +1,147 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
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 "screens.h"
#include "client.h"
#include "cursor.h"
#include "settings.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QTimer>
namespace KWin
{
KWIN_SINGLETON_FACTORY_FACTORED(Screens, DesktopWidgetScreens)
Screens::Screens(QObject *parent)
: QObject(parent)
, m_count(0)
, m_current(0)
, m_currentFollowsMouse(false)
, m_changedTimer(new QTimer(this))
{
m_changedTimer->setSingleShot(true);
m_changedTimer->setInterval(100);
connect(m_changedTimer, SIGNAL(timeout()), SIGNAL(changed()));
Settings settings;
settings.setDefaults();
m_currentFollowsMouse = settings.activeMouseScreen();
}
Screens::~Screens()
{
s_self = NULL;
}
void Screens::reconfigure()
{
if (!m_config) {
return;
}
Settings settings(m_config);
settings.readConfig();
setCurrentFollowsMouse(settings.activeMouseScreen());
}
void Screens::setCount(int count)
{
if (m_count == count) {
return;
}
const int previous = m_count;
m_count = count;
emit countChanged(previous, count);
}
void Screens::setCurrent(int current)
{
if (m_current == current) {
return;
}
m_current = current;
}
void Screens::setCurrent(const QPoint &pos)
{
setCurrent(number(pos));
}
void Screens::setCurrent(const Client *c)
{
if (!c->isActive()) {
return;
}
if (!c->isOnScreen(m_current)) {
setCurrent(c->screen());
}
}
void Screens::setCurrentFollowsMouse(bool follows)
{
if (m_currentFollowsMouse == follows) {
return;
}
m_currentFollowsMouse = follows;
}
int Screens::current() const
{
if (m_currentFollowsMouse) {
return number(Cursor::pos());
}
Client *client = Workspace::self()->activeClient();
if (client && !client->isOnScreen(m_current)) {
return client->screen();
}
return m_current;
}
void Screens::startChangedTimer()
{
m_changedTimer->start();
}
DesktopWidgetScreens::DesktopWidgetScreens(QObject *parent)
: Screens(parent)
, m_desktop(QApplication::desktop())
{
connect(m_desktop, SIGNAL(screenCountChanged(int)), SLOT(setCount(int)));
connect(m_desktop, SIGNAL(screenCountChanged(int)), SLOT(startChangedTimer()));
connect(m_desktop, SIGNAL(resized(int)), SLOT(startChangedTimer()));
setCount(m_desktop->screenCount());
}
DesktopWidgetScreens::~DesktopWidgetScreens()
{
}
QRect DesktopWidgetScreens::geometry(int screen) const
{
return m_desktop->screenGeometry(screen);
}
int DesktopWidgetScreens::number(const QPoint &pos) const
{
return m_desktop->screenNumber(pos);
}
} // namespace

132
screens.h Normal file
View File

@ -0,0 +1,132 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
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 KWIN_SCREENS_H
#define KWIN_SCREENS_H
// KWin includes
#include <kwinglobals.h>
// KDE includes
#include <KDE/KConfig>
// Qt includes
#include <QObject>
#include <QRect>
class QDesktopWidget;
class QTimer;
namespace KWin
{
class Client;
class Screens : public QObject
{
Q_OBJECT
Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
Q_PROPERTY(int current READ current WRITE setCurrent)
Q_PROPERTY(bool currentFollowsMouse READ isCurrentFollowsMouse WRITE setCurrentFollowsMouse)
public:
virtual ~Screens();
/**
* @internal
**/
void setConfig(KSharedConfig::Ptr config);
int count() const;
int current() const;
void setCurrent(int current);
/**
* Called e.g. when a user clicks on a window, set current screen to be the screen
* where the click occurred
*/
void setCurrent(const QPoint &pos);
/**
* Check whether a client moved completely out of what's considered the current screen,
* if yes, set a new active screen.
*/
void setCurrent(const Client *c);
bool isCurrentFollowsMouse() const;
void setCurrentFollowsMouse(bool follows);
virtual QRect geometry(int screen) const = 0;
virtual int number(const QPoint &pos) const = 0;
public Q_SLOTS:
void reconfigure();
Q_SIGNALS:
void countChanged(int previousCount, int newCount);
/**
* Emitted whenever the screens are changed either count or geometry.
**/
void changed();
protected Q_SLOTS:
void setCount(int count);
void startChangedTimer();
private:
int m_count;
int m_current;
bool m_currentFollowsMouse;
QTimer *m_changedTimer;
KSharedConfig::Ptr m_config;
KWIN_SINGLETON(Screens)
};
class DesktopWidgetScreens : public Screens
{
Q_OBJECT
public:
DesktopWidgetScreens(QObject *parent);
virtual ~DesktopWidgetScreens();
virtual QRect geometry(int screen) const;
virtual int number(const QPoint &pos) const;
private:
QDesktopWidget *m_desktop;
};
inline
void Screens::setConfig(KSharedConfig::Ptr config)
{
m_config = config;
}
inline
int Screens::count() const
{
return m_count;
}
inline
bool Screens::isCurrentFollowsMouse() const
{
return m_currentFollowsMouse;
}
inline
Screens *screens()
{
return Screens::self();
}
}
#endif // KWIN_SCREENS_H

View File

@ -20,8 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "scripting_model.h"
#include "activities.h"
#include "client.h"
// Qt
#include <QDesktopWidget>
#include "screens.h"
#include <KDE/KDebug>
@ -327,7 +326,7 @@ AbstractLevel *AbstractLevel::create(const QList< ClientModel::LevelRestriction
#endif
}
case ClientModel::ScreenRestriction:
for (int i=0; i<Workspace::self()->numScreens(); ++i) {
for (int i=0; i<screens()->count(); ++i) {
AbstractLevel *childLevel = create(childRestrictions, childrenRestrictions, model, currentLevel);
if (!childLevel) {
continue;
@ -401,7 +400,7 @@ ForkLevel::ForkLevel(const QList<ClientModel::LevelRestriction> &childRestrictio
, m_childRestrictions(childRestrictions)
{
connect(VirtualDesktopManager::self(), SIGNAL(countChanged(uint,uint)), SLOT(desktopCountChanged(uint,uint)));
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(screenCountChanged(int)));
connect(screens(), SIGNAL(countChanged(int,int)), SLOT(screenCountChanged(int,int)));
#ifdef KWIN_BUILD_ACTIVITIES
Activities *activities = Activities::self();
connect(activities, SIGNAL(added(QString)), SLOT(activityAdded(QString)));
@ -444,13 +443,12 @@ void ForkLevel::desktopCountChanged(uint previousCount, uint newCount)
}
}
void ForkLevel::screenCountChanged(int newCount)
void ForkLevel::screenCountChanged(int previousCount, int newCount)
{
if (restriction() != ClientModel::ClientModel::ClientModel::ScreenRestriction) {
return;
}
const int previousCount = m_children.count();
if (newCount == previousCount) {
if (newCount == previousCount || previousCount != count()) {
return;
}

View File

@ -192,7 +192,7 @@ public:
virtual Client *clientForId(quint32 child) const;
private Q_SLOTS:
void desktopCountChanged(uint previousCount, uint newCount);
void screenCountChanged(int newCount);
void screenCountChanged(int previousCount, int newCount);
void activityAdded(const QString &id);
void activityRemoved(const QString &id);
private:

View File

@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "workspace_wrapper.h"
#include "../client.h"
#include "../outline.h"
#include "../screens.h"
#include "../virtualdesktops.h"
#ifdef KWIN_BUILD_ACTIVITIES
#include "../activities.h"
@ -85,8 +86,6 @@ rettype WorkspaceWrapper::getterName( ) const { \
}
GETTER(KWin::Client*, activeClient)
GETTER(QList< KWin::Client* >, clientList)
GETTER(int, activeScreen)
GETTER(int, numScreens)
#undef GETTER
@ -286,4 +285,14 @@ int WorkspaceWrapper::workspaceWidth() const
return desktopGridWidth() * displayWidth();
}
int WorkspaceWrapper::numScreens() const
{
return screens()->count();
}
int WorkspaceWrapper::activeScreen() const
{
return screens()->current();
}
} // KWin

View File

@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "client.h"
#include "effects.h"
#include "focuschain.h"
#include "screens.h"
#include "virtualdesktops.h"
#include "workspace.h"
// Qt
@ -87,7 +88,7 @@ TabBoxHandlerImpl::~TabBoxHandlerImpl()
int TabBoxHandlerImpl::activeScreen() const
{
return Workspace::self()->activeScreen();
return screens()->current();
}
int TabBoxHandlerImpl::currentDesktop() const
@ -235,15 +236,14 @@ bool TabBoxHandlerImpl::checkMinimized(TabBoxClient* client) const
bool TabBoxHandlerImpl::checkMultiScreen(TabBoxClient* client) const
{
Client* current = (static_cast< TabBoxClientImpl* >(client))->client();
Workspace* workspace = Workspace::self();
switch (config().clientMultiScreenMode()) {
case TabBoxConfig::IgnoreMultiScreen:
return true;
case TabBoxConfig::ExcludeCurrentScreenClients:
return current->screen() != workspace->activeScreen();
return current->screen() != screens()->current();
default: // TabBoxConfig::OnlyCurrentScreenClients
return current->screen() == workspace->activeScreen();
return current->screen() == screens()->current();
}
}
@ -317,7 +317,7 @@ QWeakPointer<TabBoxClient> TabBoxHandlerImpl::desktopClient() const
{
foreach (Toplevel *toplevel, Workspace::self()->stackingOrder()) {
Client *client = qobject_cast<Client*>(toplevel);
if (client && client->isDesktop() && client->isOnCurrentDesktop() && client->screen() == Workspace::self()->activeScreen()) {
if (client && client->isDesktop() && client->isOnCurrentDesktop() && client->screen() == screens()->current()) {
return client->tabBoxClient();
}
}

View File

@ -29,11 +29,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "client.h"
#include "client_machine.h"
#include "effects.h"
#include "screens.h"
#include "shadow.h"
#include "xcbutils.h"
#include <QDesktopWidget>
namespace KWin
{
@ -57,8 +56,7 @@ Toplevel::Toplevel(Workspace* ws)
, m_screen(0)
{
connect(this, SIGNAL(damaged(KWin::Toplevel*,QRect)), SIGNAL(needsRepaint()));
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(checkScreen()));
connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(checkScreen()));
connect(screens(), SIGNAL(changed()), SLOT(checkScreen()));
setupCheckScreenConnection();
}
@ -336,14 +334,14 @@ void Toplevel::deleteEffectWindow()
void Toplevel::checkScreen()
{
if (Workspace::self()->numScreens() == 1) {
if (screens()->count() == 1) {
if (m_screen != 0) {
m_screen = 0;
emit screenChanged();
}
return;
}
const int s = Workspace::self()->screenNumber(geometry().center());
const int s = screens()->number(geometry().center());
if (s != m_screen) {
m_screen = s;
emit screenChanged();
@ -370,7 +368,12 @@ int Toplevel::screen() const
bool Toplevel::isOnScreen(int screen) const
{
return workspace()->screenGeometry(screen).intersects(geometry());
return screens()->geometry(screen).intersects(geometry());
}
bool Toplevel::isOnActiveScreen() const
{
return isOnScreen(screens()->current());
}
void Toplevel::getShadow()

View File

@ -180,6 +180,7 @@ public:
int width() const;
int height() const;
bool isOnScreen(int screen) const; // true if it's at least partially there
bool isOnActiveScreen() const;
int screen() const; // the screen where the center is
virtual QPoint clientPos() const = 0; // inside of geometry()
virtual QSize clientSize() const = 0;

View File

@ -37,6 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "decorations.h"
#include "workspace.h"
#include "effects.h"
#include "screens.h"
#include "virtualdesktops.h"
#ifdef KWIN_BUILD_SCRIPTING
@ -408,7 +409,6 @@ void UserActionsMenu::menuAboutToShow()
{
if (m_client.isNull() || !m_menu)
return;
Workspace *ws = Workspace::self();
if (VirtualDesktopManager::self()->count() == 1) {
delete m_desktopMenu;
@ -416,7 +416,7 @@ void UserActionsMenu::menuAboutToShow()
} else {
initDesktopPopup();
}
if (ws->numScreens() == 1 || (!m_client.data()->isMovable() && !m_client.data()->isMovableAcrossScreens())) {
if (screens()->count() == 1 || (!m_client.data()->isMovable() && !m_client.data()->isMovableAcrossScreens())) {
delete m_screenMenu;
m_screenMenu = NULL;
} else {
@ -688,7 +688,7 @@ void UserActionsMenu::screenPopupAboutToShow()
m_screenMenu->clear();
QActionGroup *group = new QActionGroup(m_screenMenu);
for (int i = 0; i<Workspace::self()->numScreens(); ++i) {
for (int i = 0; i<screens()->count(); ++i) {
// TODO: retrieve the screen name?
// assumption: there are not more than 9 screens attached.
QAction *action = m_screenMenu->addAction(i18nc("@item:inmenu List of all Screens to send a window to",
@ -796,12 +796,11 @@ void UserActionsMenu::slotSendToScreen(QAction *action)
if (m_client.isNull()) {
return;
}
Workspace *ws = Workspace::self();
if (screen >= ws->numScreens()) {
if (screen >= screens()->count()) {
return;
}
ws->sendClientToScreen(m_client.data(), screen);
Workspace::self()->sendClientToScreen(m_client.data(), screen);
}
void UserActionsMenu::slotToggleOnActivity(QAction *action)
@ -1126,37 +1125,37 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
}
}
workspace()->takeActivity(this, ActivityFocus | ActivityRaise, handled && replay);
workspace()->setActiveScreenMouse(globalPos);
screens()->setCurrent(globalPos);
replay = replay || mustReplay;
break;
}
case Options::MouseActivateAndLower:
workspace()->requestFocus(this);
workspace()->lowerClient(this);
workspace()->setActiveScreenMouse(globalPos);
screens()->setCurrent(globalPos);
replay = replay || !rules()->checkAcceptFocus(input);
break;
case Options::MouseActivate:
replay = isActive(); // for clickraise mode
workspace()->takeActivity(this, ActivityFocus, handled && replay);
workspace()->setActiveScreenMouse(globalPos);
screens()->setCurrent(globalPos);
replay = replay || !rules()->checkAcceptFocus(input);
break;
case Options::MouseActivateRaiseAndPassClick:
workspace()->takeActivity(this, ActivityFocus | ActivityRaise, handled);
workspace()->setActiveScreenMouse(globalPos);
screens()->setCurrent(globalPos);
replay = true;
break;
case Options::MouseActivateAndPassClick:
workspace()->takeActivity(this, ActivityFocus, handled);
workspace()->setActiveScreenMouse(globalPos);
screens()->setCurrent(globalPos);
replay = true;
break;
case Options::MouseActivateRaiseAndMove:
case Options::MouseActivateRaiseAndUnrestrictedMove:
workspace()->raiseClient(this);
workspace()->requestFocus(this);
workspace()->setActiveScreenMouse(globalPos);
screens()->setCurrent(globalPos);
// fallthrough
case Options::MouseMove:
case Options::MouseUnrestrictedMove: {
@ -1298,7 +1297,7 @@ void Workspace::slotWindowToDesktop()
static bool screenSwitchImpossible()
{
if (!options->isActiveMouseScreen())
if (!screens()->isCurrentFollowsMouse())
return false;
QStringList args;
args << "--passivepopup" << i18n("The window manager is configured to consider the screen with the mouse on it as active one.\n"
@ -1320,7 +1319,7 @@ void Workspace::slotSwitchToNextScreen()
{
if (screenSwitchImpossible())
return;
setCurrentScreen((activeScreen() + 1) % numScreens());
setCurrentScreen((screens()->current() + 1) % screens()->count());
}
void Workspace::slotWindowToScreen()
@ -1329,7 +1328,7 @@ void Workspace::slotWindowToScreen()
const int i = senderValue(sender());
if (i < 0)
return;
if (i >= 0 && i <= numScreens()) {
if (i >= 0 && i <= screens()->count()) {
sendClientToScreen(active_client, i);
}
}
@ -1338,7 +1337,7 @@ void Workspace::slotWindowToScreen()
void Workspace::slotWindowToNextScreen()
{
if (USABLE_ACTIVE_CLIENT)
sendClientToScreen(active_client, (active_client->screen() + 1) % numScreens());
sendClientToScreen(active_client, (active_client->screen() + 1) % screens()->count());
}
/*!

View File

@ -28,7 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <fixx11h.h>
#include <kconfig.h>
#include <kglobal.h>
#include <QDesktopWidget>
#include <QRegExp>
#include <QPainter>
#include <QBitmap>
@ -65,6 +64,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "deleted.h"
#include "effects.h"
#include "overlaywindow.h"
#include "screens.h"
#include "useractions.h"
#include "virtualdesktops.h"
#include "xcbutils.h"
@ -114,7 +114,6 @@ Workspace::Workspace(bool restore)
, most_recently_raised(0)
, movingClient(0)
, pending_take_activity(NULL)
, active_screen(0)
, delayfocus_client(0)
, force_restacking(false)
, x_stacking_dirty(true)
@ -153,6 +152,10 @@ Workspace::Workspace(bool restore)
// start the cursor support
Cursor::create(this);
// get screen support
Screens *screens = Screens::create(this);
connect(screens, SIGNAL(changed()), SLOT(desktopResized()));
#ifdef KWIN_BUILD_ACTIVITIES
Activities *activities = Activities::create(this);
connect(activities, SIGNAL(currentChanged(QString)), SLOT(updateCurrentActivity(QString)));
@ -234,23 +237,14 @@ Workspace::Workspace(bool restore)
initShortcuts();
init();
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), &screenChangedTimer, SLOT(start()));
connect(QApplication::desktop(), SIGNAL(resized(int)), &screenChangedTimer, SLOT(start()));
connect(&screenChangedTimer, SIGNAL(timeout()), SLOT(screenChangeTimeout()));
screenChangedTimer.setSingleShot(true);
screenChangedTimer.setInterval(100);
}
void Workspace::screenChangeTimeout()
{
kDebug() << "It is time to call desktopResized";
desktopResized();
}
void Workspace::init()
{
Screens *screens = Screens::self();
screens->setConfig(KGlobal::config());
screens->reconfigure();
connect(options, SIGNAL(configChanged()), screens, SLOT(reconfigure()));
#ifdef KWIN_BUILD_SCREENEDGES
ScreenEdges *screenEdges = ScreenEdges::self();
screenEdges->setConfig(KGlobal::config());
@ -463,8 +457,8 @@ void Workspace::init()
rootInfo->setDesktopViewport(VirtualDesktopManager::self()->count(), *viewports);
delete[] viewports;
QRect geom;
for (int i = 0; i < QApplication::desktop()->screenCount(); i++) {
geom |= QApplication::desktop()->screenGeometry(i);
for (int i = 0; i < screens->count(); i++) {
geom |= screens->geometry(i);
}
NETSize desktop_geometry;
desktop_geometry.width = geom.width();
@ -1126,7 +1120,7 @@ Client *Workspace::findClientToActivateOnDesktop(uint desktop)
}
if (!(client->isShown(false) && client->isOnDesktop(desktop) &&
client->isOnCurrentActivity() && client->isOnScreen(activeScreen())))
client->isOnCurrentActivity() && client->isOnActiveScreen()))
continue;
if (client->geometry().contains(Cursor::pos())) {
@ -1305,33 +1299,6 @@ void Workspace::sendClientToDesktop(Client* c, int desk, bool dont_activate)
updateClientArea();
}
int Workspace::numScreens() const
{
return QApplication::desktop()->screenCount();
}
int Workspace::activeScreen() const
{
if (!options->isActiveMouseScreen()) {
if (activeClient() != NULL && !activeClient()->isOnScreen(active_screen))
return activeClient()->screen();
return active_screen;
}
return QApplication::desktop()->screenNumber(cursorPos());
}
/**
* Check whether a client moved completely out of what's considered the active screen,
* if yes, set a new active screen.
*/
void Workspace::checkActiveScreen(const Client* c)
{
if (!c->isActive())
return;
if (!c->isOnScreen(active_screen))
active_screen = c->screen();
}
/**
* checks whether the X Window with the input focus is on our X11 screen
* if the window cannot be determined or inspected, resturn depends on whether there's actually
@ -1360,30 +1327,11 @@ bool Workspace::isOnCurrentHead()
return rootWindow() == geometry->root;
}
/**
* Called e.g. when a user clicks on a window, set active screen to be the screen
* where the click occurred
*/
void Workspace::setActiveScreenMouse(const QPoint& mousepos)
{
active_screen = QApplication::desktop()->screenNumber(mousepos);
}
QRect Workspace::screenGeometry(int screen) const
{
return QApplication::desktop()->screenGeometry(screen);
}
int Workspace::screenNumber(const QPoint& pos) const
{
return QApplication::desktop()->screenNumber(pos);
}
void Workspace::sendClientToScreen(Client* c, int screen)
{
screen = c->rules()->checkScreen(screen);
if (c->isActive()) {
active_screen = screen;
screens()->setCurrent(screen);
// might impact the layer of a fullscreen window
foreach (Client *cc, clientList()) {
if (cc->isFullScreen() && cc->screen() == screen) {
@ -1654,9 +1602,9 @@ QString Workspace::supportInformation() const
} else {
support.append("no\n");
}
support.append(QString("Number of Screens: %1\n").arg(QApplication::desktop()->screenCount()));
for (int i=0; i<QApplication::desktop()->screenCount(); ++i) {
const QRect geo = QApplication::desktop()->screenGeometry(i);
support.append(QString("Number of Screens: %1\n").arg(screens()->count()));
for (int i=0; i<screens()->count(); ++i) {
const QRect geo = screens()->geometry(i);
support.append(QString("Screen %1 Geometry: %2,%3,%4x%5\n")
.arg(i)
.arg(geo.x())

View File

@ -189,13 +189,7 @@ private:
// Unsorted
public:
int activeScreen() const;
int numScreens() const;
void checkActiveScreen(const Client* c);
bool isOnCurrentHead();
void setActiveScreenMouse(const QPoint& mousepos);
QRect screenGeometry(int screen) const;
int screenNumber(const QPoint& pos) const;
// True when performing Workspace::updateClientArea().
// The calls below are valid only in that case.
bool inUpdateClientArea() const;
@ -409,7 +403,6 @@ public slots:
private slots:
void desktopResized();
void screenChangeTimeout();
void slotUpdateToolWindows();
void delayFocus();
void gotTemporaryRulesMessage(const QString&);
@ -503,7 +496,6 @@ private:
QList<Rules*> rules;
KXMessages temporaryRulesMessages;
QTimer rulesUpdatedTimer;
QTimer screenChangedTimer;
bool rules_updates_disabled;
static const char* windowTypeToTxt(NET::WindowType type);
static NET::WindowType txtToWindowType(const char* txt);
@ -514,7 +506,6 @@ private:
Client* most_recently_raised; // Used ONLY by raiseOrLowerClient()
Client* movingClient;
Client* pending_take_activity;
int active_screen;
// Delay(ed) window focus timer and client
QTimer* delayFocusTimer;