Refactoring Screen Edge handling

This commit change the screen edge function calls to be called in the
new class ScreenEdge. The old methods are still in Workspace and will
be removed in a further commit.
This commit is contained in:
Arthur Arlt 2011-06-23 19:54:14 +02:00
parent 7533bfac75
commit 2f11337d98
7 changed files with 39 additions and 29 deletions

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "group.h"
#include "scene_xrender.h"
#include "scene_opengl.h"
#include "screenedge.h"
#include "unmanaged.h"
#include "tabbox.h"
#include "workspace.h"
@ -869,7 +870,7 @@ Window EffectsHandlerImpl::createInputWindow(Effect* e, int x, int y, int w, int
// Raise electric border windows above the input windows
// so they can still be triggered.
Workspace::self()->raiseElectricBorderWindows();
Workspace::self()->screenEdge()->raiseElectricBorderWindows();
return win;
}
@ -940,7 +941,7 @@ void EffectsHandlerImpl::checkInputWindowStacking()
delete[] wins;
// Raise electric border windows above the input windows
// so they can still be triggered. TODO: Do both at once.
Workspace::self()->raiseElectricBorderWindows();
Workspace::self()->screenEdge()->raiseElectricBorderWindows();
}
QPoint EffectsHandlerImpl::cursorPos() const
@ -950,22 +951,22 @@ QPoint EffectsHandlerImpl::cursorPos() const
void EffectsHandlerImpl::checkElectricBorder(const QPoint &pos, Time time)
{
Workspace::self()->checkElectricBorder(pos, time);
Workspace::self()->screenEdge()->checkElectricBorder(pos, time);
}
void EffectsHandlerImpl::reserveElectricBorder(ElectricBorder border)
{
Workspace::self()->reserveElectricBorder(border);
Workspace::self()->screenEdge()->reserveElectricBorder(border);
}
void EffectsHandlerImpl::unreserveElectricBorder(ElectricBorder border)
{
Workspace::self()->unreserveElectricBorder(border);
Workspace::self()->screenEdge()->unreserveElectricBorder(border);
}
void EffectsHandlerImpl::reserveElectricBorderSwitching(bool reserve)
{
Workspace::self()->reserveElectricBorderSwitching(reserve);
Workspace::self()->screenEdge()->reserveElectricBorderSwitching(reserve);
}
unsigned long EffectsHandlerImpl::xrenderBufferPicture()

View file

@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "rules.h"
#include "unmanaged.h"
#include "scene.h"
#include "screenedge.h"
#include "effects.h"
#include <QWhatsThis>
@ -376,7 +377,7 @@ bool Workspace::workspaceEvent(XEvent * e)
if (w)
QWhatsThis::leaveWhatsThisMode();
}
if (electricBorderEvent(e))
if (m_screenEdge.electricBorderEvent(e))
return true;
break;
}
@ -428,7 +429,7 @@ bool Workspace::workspaceEvent(XEvent * e)
case FocusOut:
return true; // always eat these, they would tell Qt that KWin is the active app
case ClientMessage:
if (electricBorderEvent(e))
if (m_screenEdge.electricBorderEvent(e))
return true;
break;
case Expose:

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 "screenedge.h"
#include "effects.h"
#include <QPainter>
#include <QVarLengthArray>
@ -71,8 +72,8 @@ void Workspace::desktopResized()
rootInfo->setDesktopGeometry(-1, desktop_geometry);
updateClientArea();
destroyElectricBorders();
updateElectricBorders();
m_screenEdge.destroyElectricBorders();
m_screenEdge.updateElectricBorders();
if (compositing())
compositeResetTimer.start(0);
}
@ -2526,7 +2527,7 @@ bool Client::startMoveResize()
if (options->electricBorders() == Options::ElectricMoveOnly ||
options->electricBorderMaximize() ||
options->electricBorderTiling())
workspace()->reserveElectricBorderSwitching(true);
workspace()->screenEdge()->reserveElectricBorderSwitching(true);
return true;
}
@ -2591,7 +2592,7 @@ void Client::finishMoveResize(bool cancel)
kDebug(1212) << "invalid electric mode" << electricMode << "leading to invalid array acces,\
this should not have happened!";
else
workspace()->restoreElectricBorderSize(border);
workspace()->screenEdge()->restoreElectricBorderSize(border);
electricMaximizing = false;
workspace()->outline()->hide();
}
@ -2621,7 +2622,7 @@ void Client::leaveMoveResize()
if (options->electricBorders() == Options::ElectricMoveOnly ||
options->electricBorderMaximize() ||
options->electricBorderTiling())
workspace()->reserveElectricBorderSwitching(false);
workspace()->screenEdge()->reserveElectricBorderSwitching(false);
}
// This function checks if it actually makes sense to perform a restricted move/resize.
@ -2944,7 +2945,7 @@ void Client::handleMoveResize(int x, int y, int x_root, int y_root)
if (isMove()) {
workspace()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom);
workspace()->checkElectricBorder(globalPos, xTime());
workspace()->screenEdge()->checkElectricBorder(globalPos, xTime());
}
}

View file

@ -79,6 +79,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "utils.h"
#include "client.h"
#include "workspace.h"
#include "screenedge.h"
#include "tabbox.h"
#include "group.h"
#include "rules.h"
@ -158,8 +159,8 @@ void Workspace::propagateClients(bool propagate_new_clients)
for (int i = 0;
i < ELECTRIC_COUNT;
++i)
if (electric_windows[ i ] != None)
new_stack[ pos++ ] = electric_windows[ i ];
if (m_screenEdge.electricWindows()[ i ] != None)
new_stack[ pos++ ] = m_screenEdge.electricWindows()[ i ];
for (int i = stacking_order.size() - 1; i >= 0; i--) {
if (stacking_order.at(i)->hiddenPreview()) {
continue;

View file

@ -49,6 +49,10 @@ namespace KWin {
ScreenEdge::ScreenEdge()
: QObject(NULL)
{
for (int i = 0; i < ELECTRIC_COUNT; ++i) {
electric_reserved[i] = 0;
electric_windows[i] = None;
}
}
ScreenEdge::~ScreenEdge()

View file

@ -28,9 +28,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KWIN_SCREENEDGE_H
#define KWIN_SCREENEDGE_H
#include <QObject>
#include <QtCore/QObject>
#include "kwinglobals.h"
namespace KWin {
//-----------------------------------------------------------------------------
@ -52,11 +53,11 @@ public:
void reserveElectricBorderActions(bool reserve);
void reserveElectricBorderSwitching(bool reserve);
void raiseElectricBorderWindows();
private Q_SLOTS:
void updateElectricBorders();
private:
void destroyElectricBorders();
bool electricBorderEvent(XEvent * e);
public Q_SLOTS:
void updateElectricBorders();
private:
void electricBorderSwitchDesktop(ElectricBorder border, const QPoint& pos);
ElectricBorder electric_current_border;

View file

@ -252,10 +252,11 @@ Workspace::Workspace(bool restore)
void Workspace::init()
{
reserveElectricBorderActions(true);
m_screenEdge.reserveElectricBorderActions(true);
if (options->electricBorders() == Options::ElectricAlways)
reserveElectricBorderSwitching(true);
updateElectricBorders();
m_screenEdge.reserveElectricBorderSwitching(true);
m_screenEdge.updateElectricBorders();
m_screenEdge.init();
// Not used yet
//topDock = 0L;
@ -911,9 +912,9 @@ void Workspace::slotReconfigure()
kDebug(1212) << "Workspace::slotReconfigure()";
reconfigureTimer.stop();
reserveElectricBorderActions(false);
m_screenEdge.reserveElectricBorderActions(false);
if (options->electricBorders() == Options::ElectricAlways)
reserveElectricBorderSwitching(false);
m_screenEdge.reserveElectricBorderSwitching(false);
bool borderlessMaximizedWindows = options->borderlessMaximizedWindows();
@ -953,10 +954,10 @@ void Workspace::slotReconfigure()
c->triggerDecorationRepaint();
}
reserveElectricBorderActions(true);
m_screenEdge.reserveElectricBorderActions(true);
if (options->electricBorders() == Options::ElectricAlways)
reserveElectricBorderSwitching(true);
updateElectricBorders();
m_screenEdge.reserveElectricBorderSwitching(true);
m_screenEdge.updateElectricBorders();
if (!compositingSuspended) {
setupCompositing();
@ -1007,7 +1008,7 @@ void Workspace::slotReinitCompositing()
KGlobal::config()->reparseConfiguration();
// Update any settings that can be set in the compositing kcm.
updateElectricBorders();
m_screenEdge.updateElectricBorders();
// Restart compositing
finishCompositing();