Only reserve required electric borders for ElectricAlways

CCBUG: 293011
REVIEW: 104073
This commit is contained in:
Thomas Lübking 2012-05-03 19:48:20 +02:00
parent 766bc27940
commit 3a6095726e
10 changed files with 70 additions and 22 deletions

View file

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/ *********************************************************************/
#include "workspace.h" #include "workspace.h"
#include "options.h"
#include "assert.h" #include "assert.h"
@ -27,6 +28,11 @@ namespace KWin
void Workspace::updateDesktopLayout() void Workspace::updateDesktopLayout()
{ {
#ifdef KWIN_BUILD_SCREENEDGES
if (options->electricBorders() == Options::ElectricAlways) {
m_screenEdge.reserveDesktopSwitching(false, m_screenEdgeOrientation);
}
#endif
// TODO: Is there a sane way to avoid overriding the existing grid? // TODO: Is there a sane way to avoid overriding the existing grid?
int width = rootInfo->desktopLayoutColumnsRows().width(); int width = rootInfo->desktopLayoutColumnsRows().width();
int height = rootInfo->desktopLayoutColumnsRows().height(); int height = rootInfo->desktopLayoutColumnsRows().height();
@ -36,6 +42,17 @@ void Workspace::updateDesktopLayout()
rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical, rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical,
width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now.
); );
#ifdef KWIN_BUILD_SCREENEDGES
m_screenEdgeOrientation = 0;
if (width > 1)
m_screenEdgeOrientation |= Qt::Horizontal;
if (height > 1)
m_screenEdgeOrientation |= Qt::Vertical;
if (options->electricBorders() == Options::ElectricAlways) {
m_screenEdge.reserveDesktopSwitching(true, m_screenEdgeOrientation);
}
#endif
} }
void Workspace::setNETDesktopLayout(Qt::Orientation orientation, int width, int height, void Workspace::setNETDesktopLayout(Qt::Orientation orientation, int width, int height,

View file

@ -1075,10 +1075,10 @@ void EffectsHandlerImpl::unreserveElectricBorder(ElectricBorder border)
#endif #endif
} }
void EffectsHandlerImpl::reserveElectricBorderSwitching(bool reserve) void EffectsHandlerImpl::reserveElectricBorderSwitching(bool reserve, Qt::Orientations o)
{ {
#ifdef KWIN_BUILD_SCREENEDGES #ifdef KWIN_BUILD_SCREENEDGES
Workspace::self()->screenEdge()->reserveDesktopSwitching(reserve); Workspace::self()->screenEdge()->reserveDesktopSwitching(reserve, o);
#else #else
Q_UNUSED(reserve) Q_UNUSED(reserve)
#endif #endif

View file

@ -137,7 +137,7 @@ public:
virtual void checkElectricBorder(const QPoint &pos, Time time); virtual void checkElectricBorder(const QPoint &pos, Time time);
virtual void reserveElectricBorder(ElectricBorder border); virtual void reserveElectricBorder(ElectricBorder border);
virtual void unreserveElectricBorder(ElectricBorder border); virtual void unreserveElectricBorder(ElectricBorder border);
virtual void reserveElectricBorderSwitching(bool reserve); virtual void reserveElectricBorderSwitching(bool reserve, Qt::Orientations o);
virtual unsigned long xrenderBufferPicture(); virtual unsigned long xrenderBufferPicture();
virtual void reconfigure(); virtual void reconfigure();

View file

@ -2564,7 +2564,7 @@ bool Client::startMoveResize()
if (options->electricBorders() == Options::ElectricMoveOnly || if (options->electricBorders() == Options::ElectricMoveOnly ||
options->electricBorderMaximize() || options->electricBorderMaximize() ||
options->electricBorderTiling()) options->electricBorderTiling())
workspace()->screenEdge()->reserveDesktopSwitching(true); workspace()->screenEdge()->reserveDesktopSwitching(true, Qt::Vertical|Qt::Horizontal);
#endif #endif
if (fakeMove) // fix geom_restore position - it HAS to happen at the end, ie. when all moving is set up. inline call will lock focus!! if (fakeMove) // fix geom_restore position - it HAS to happen at the end, ie. when all moving is set up. inline call will lock focus!!
handleMoveResize(QCursor::pos().x(), QCursor::pos().y(), QCursor::pos().x(), QCursor::pos().y()); handleMoveResize(QCursor::pos().x(), QCursor::pos().y(), QCursor::pos().x(), QCursor::pos().y());
@ -2677,7 +2677,7 @@ void Client::leaveMoveResize()
if (options->electricBorders() == Options::ElectricMoveOnly || if (options->electricBorders() == Options::ElectricMoveOnly ||
options->electricBorderMaximize() || options->electricBorderMaximize() ||
options->electricBorderTiling()) options->electricBorderTiling())
workspace()->screenEdge()->reserveDesktopSwitching(false); workspace()->screenEdge()->reserveDesktopSwitching(false, Qt::Vertical|Qt::Horizontal);
#endif #endif
} }

View file

@ -167,7 +167,7 @@ X-KDE-Library=kwin4_effect_cooleffect
#define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor ))
#define KWIN_EFFECT_API_VERSION_MAJOR 0 #define KWIN_EFFECT_API_VERSION_MAJOR 0
#define KWIN_EFFECT_API_VERSION_MINOR 182 #define KWIN_EFFECT_API_VERSION_MINOR 183
#define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \
KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR )
@ -645,7 +645,7 @@ public:
virtual void checkElectricBorder(const QPoint &pos, Time time) = 0; virtual void checkElectricBorder(const QPoint &pos, Time time) = 0;
virtual void reserveElectricBorder(ElectricBorder border) = 0; virtual void reserveElectricBorder(ElectricBorder border) = 0;
virtual void unreserveElectricBorder(ElectricBorder border) = 0; virtual void unreserveElectricBorder(ElectricBorder border) = 0;
virtual void reserveElectricBorderSwitching(bool reserve) = 0; virtual void reserveElectricBorderSwitching(bool reserve, Qt::Orientations o) = 0;
// functions that allow controlling windows/desktop // functions that allow controlling windows/desktop
virtual void activateWindow(KWin::EffectWindow* c) = 0; virtual void activateWindow(KWin::EffectWindow* c) = 0;

View file

@ -583,8 +583,7 @@ WindowQuadList Scene::Window::buildQuads(bool force) const
Client *client = dynamic_cast<Client*>(toplevel); Client *client = dynamic_cast<Client*>(toplevel);
QRegion contents = clientShape(); QRegion contents = clientShape();
QRegion center = toplevel->transparentRect(); QRegion center = toplevel->transparentRect();
QRegion decoration = (client && Workspace::self()->decorationHasAlpha() ? QRegion decoration = shape() - center;
QRegion(client->decorationRect()) : shape()) - center;
ret = makeQuads(WindowQuadContents, contents); ret = makeQuads(WindowQuadContents, contents);
if (!client || !(center.isEmpty() || client->isShade())) if (!client || !(center.isEmpty() || client->isShade()))
ret += makeQuads(WindowQuadDecoration, decoration); ret += makeQuads(WindowQuadDecoration, decoration);

View file

@ -58,9 +58,6 @@ ScreenEdge::~ScreenEdge()
void ScreenEdge::init() void ScreenEdge::init()
{ {
reserveActions(true); reserveActions(true);
if (options->electricBorders() == Options::ElectricAlways) {
reserveDesktopSwitching(true);
}
update(); update();
} }
@ -143,13 +140,39 @@ void ScreenEdge::reserveActions(bool isToReserve)
} }
} }
void ScreenEdge::reserveDesktopSwitching(bool isToReserve) void ScreenEdge::reserveDesktopSwitching(bool isToReserve, Qt::Orientations o)
{ {
for (int pos = 0; pos < ELECTRIC_COUNT; ++pos) if (!o)
if (isToReserve) return;
reserve(static_cast<ElectricBorder>(pos)); if (isToReserve) {
else reserve(ElectricTopLeft);
unreserve(static_cast<ElectricBorder>(pos)); reserve(ElectricTopRight);
reserve(ElectricBottomRight);
reserve(ElectricBottomLeft);
if (o & Qt::Horizontal) {
reserve(ElectricLeft);
reserve(ElectricRight);
}
if (o & Qt::Vertical) {
reserve(ElectricTop);
reserve(ElectricBottom);
}
} else {
unreserve(ElectricTopLeft);
unreserve(ElectricTopRight);
unreserve(ElectricBottomRight);
unreserve(ElectricBottomLeft);
if (o & Qt::Horizontal) {
unreserve(ElectricLeft);
unreserve(ElectricRight);
}
if (o & Qt::Vertical) {
unreserve(ElectricTop);
unreserve(ElectricBottom);
}
}
} }
void ScreenEdge::reserve(ElectricBorder border) void ScreenEdge::reserve(ElectricBorder border)

View file

@ -84,7 +84,7 @@ public:
* Reserve desktop switching for screen edges, if reserve is true. Unreserve otherwise. * Reserve desktop switching for screen edges, if reserve is true. Unreserve otherwise.
* @param reserve indicated weather desktop switching should be reserved or unreseved * @param reserve indicated weather desktop switching should be reserved or unreseved
*/ */
void reserveDesktopSwitching(bool isToReserve); void reserveDesktopSwitching(bool isToReserve, Qt::Orientations o);
/** /**
* Raise electric border windows to the real top of the screen. We only need * Raise electric border windows to the real top of the screen. We only need
* to do this if an effect input window is active. * to do this if an effect input window is active.

View file

@ -107,6 +107,7 @@ Workspace::Workspace(bool restore)
, desktopGridSize_(1, 2) // Default to two rows , desktopGridSize_(1, 2) // Default to two rows
, desktopGrid_(new int[2]) , desktopGrid_(new int[2])
, currentDesktop_(0) , currentDesktop_(0)
, m_screenEdgeOrientation(0)
// Unsorted // Unsorted
, active_popup(NULL) , active_popup(NULL)
, active_popup_client(NULL) , active_popup_client(NULL)
@ -958,7 +959,7 @@ void Workspace::slotReconfigure()
#ifdef KWIN_BUILD_SCREENEDGES #ifdef KWIN_BUILD_SCREENEDGES
m_screenEdge.reserveActions(false); m_screenEdge.reserveActions(false);
if (options->electricBorders() == Options::ElectricAlways) if (options->electricBorders() == Options::ElectricAlways)
m_screenEdge.reserveDesktopSwitching(false); m_screenEdge.reserveDesktopSwitching(false, m_screenEdgeOrientation);
#endif #endif
bool borderlessMaximizedWindows = options->borderlessMaximizedWindows(); bool borderlessMaximizedWindows = options->borderlessMaximizedWindows();
@ -996,8 +997,15 @@ void Workspace::slotReconfigure()
#ifdef KWIN_BUILD_SCREENEDGES #ifdef KWIN_BUILD_SCREENEDGES
m_screenEdge.reserveActions(true); m_screenEdge.reserveActions(true);
if (options->electricBorders() == Options::ElectricAlways) if (options->electricBorders() == Options::ElectricAlways) {
m_screenEdge.reserveDesktopSwitching(true); QSize desktopMatrix = rootInfo->desktopLayoutColumnsRows();
m_screenEdgeOrientation = 0;
if (desktopMatrix.width() > 1)
m_screenEdgeOrientation |= Qt::Horizontal;
if (desktopMatrix.height() > 1)
m_screenEdgeOrientation |= Qt::Vertical;
m_screenEdge.reserveDesktopSwitching(true, m_screenEdgeOrientation);
}
m_screenEdge.update(); m_screenEdge.update();
#endif #endif

View file

@ -318,6 +318,7 @@ private:
Outline* m_outline; Outline* m_outline;
#ifdef KWIN_BUILD_SCREENEDGES #ifdef KWIN_BUILD_SCREENEDGES
ScreenEdge m_screenEdge; ScreenEdge m_screenEdge;
Qt::Orientations m_screenEdgeOrientation;
#endif #endif
//------------------------------------------------- //-------------------------------------------------