Remove screen edge handling methods from workspace
Since the newly introduced class ScreenEdge and its calls work fine, the redundand methods from workspace are now removed.
This commit is contained in:
parent
76e5f0e08b
commit
5ead1d90a1
3 changed files with 0 additions and 358 deletions
21
layers.cpp
21
layers.cpp
|
@ -197,27 +197,6 @@ void Workspace::propagateClients(bool propagate_new_clients)
|
|||
x_stacking_dirty = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise electric border windows to the real top of the screen. We only need
|
||||
* to do this if an effect input window is active.
|
||||
*/
|
||||
void Workspace::raiseElectricBorderWindows()
|
||||
{
|
||||
Window* windows = new Window[ 8 ]; // There are up to 8 borders
|
||||
int pos = 0;
|
||||
for (int i = 0; i < ELECTRIC_COUNT; ++i)
|
||||
if (electric_windows[ i ] != None)
|
||||
windows[ pos++ ] = electric_windows[ i ];
|
||||
if (!pos) {
|
||||
delete [] windows;
|
||||
return; // No borders at all
|
||||
}
|
||||
XRaiseWindow(display(), windows[ 0 ]);
|
||||
XRestackWindows(display(), windows, pos);
|
||||
delete [] windows;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns topmost visible client. Windows on the dock, the desktop
|
||||
or of any other special kind are excluded. Also if the window
|
||||
|
|
311
workspace.cpp
311
workspace.cpp
|
@ -176,11 +176,6 @@ Workspace::Workspace(bool restore)
|
|||
default_colormap = DefaultColormap(display(), info.screen());
|
||||
installed_colormap = default_colormap;
|
||||
|
||||
for (int i = 0; i < ELECTRIC_COUNT; ++i) {
|
||||
electric_reserved[i] = 0;
|
||||
electric_windows[i] = None;
|
||||
}
|
||||
|
||||
connect(&temporaryRulesMessages, SIGNAL(gotMessage(const QString&)),
|
||||
this, SLOT(gotTemporaryRulesMessage(const QString&)));
|
||||
connect(&rulesUpdatedTimer, SIGNAL(timeout()), this, SLOT(writeWindowRules()));
|
||||
|
@ -1757,312 +1752,6 @@ void Workspace::cancelDelayFocus()
|
|||
delayFocusTimer = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Electric Borders
|
||||
//-----------------------------------------------------------------------------
|
||||
// Electric Border Window management. Electric borders allow a user to change
|
||||
// the virtual desktop or activate another features by moving the mouse pointer
|
||||
// to the borders or corners. Technically this is done with input only windows.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void Workspace::updateElectricBorders()
|
||||
{
|
||||
electric_time_first = xTime();
|
||||
electric_time_last = xTime();
|
||||
electric_time_last_trigger = xTime();
|
||||
electric_current_border = ElectricNone;
|
||||
QRect r = Kephal::ScreenUtils::desktopGeometry();
|
||||
electricTop = r.top();
|
||||
electricBottom = r.bottom();
|
||||
electricLeft = r.left();
|
||||
electricRight = r.right();
|
||||
|
||||
for (int pos = 0; pos < ELECTRIC_COUNT; ++pos) {
|
||||
if (electric_reserved[pos] == 0) {
|
||||
if (electric_windows[pos] != None)
|
||||
XDestroyWindow(display(), electric_windows[pos]);
|
||||
electric_windows[pos] = None;
|
||||
continue;
|
||||
}
|
||||
if (electric_windows[pos] != None)
|
||||
continue;
|
||||
XSetWindowAttributes attributes;
|
||||
attributes.override_redirect = True;
|
||||
attributes.event_mask = EnterWindowMask | LeaveWindowMask;
|
||||
unsigned long valuemask = CWOverrideRedirect | CWEventMask;
|
||||
int xywh[ELECTRIC_COUNT][4] = {
|
||||
{ r.left() + 1, r.top(), r.width() - 2, 1 }, // Top
|
||||
{ r.right(), r.top(), 1, 1 }, // Top-right
|
||||
{ r.right(), r.top() + 1, 1, r.height() - 2 }, // Etc.
|
||||
{ r.right(), r.bottom(), 1, 1 },
|
||||
{ r.left() + 1, r.bottom(), r.width() - 2, 1 },
|
||||
{ r.left(), r.bottom(), 1, 1 },
|
||||
{ r.left(), r.top() + 1, 1, r.height() - 2 },
|
||||
{ r.left(), r.top(), 1, 1 }
|
||||
};
|
||||
electric_windows[pos] = XCreateWindow(display(), rootWindow(),
|
||||
xywh[pos][0], xywh[pos][1], xywh[pos][2], xywh[pos][3],
|
||||
0, CopyFromParent, InputOnly, CopyFromParent, valuemask, &attributes);
|
||||
XMapWindow(display(), electric_windows[pos]);
|
||||
|
||||
// Set XdndAware on the windows, so that DND enter events are received (#86998)
|
||||
Atom version = 4; // XDND version
|
||||
XChangeProperty(display(), electric_windows[pos], atoms->xdnd_aware, XA_ATOM,
|
||||
32, PropModeReplace, (unsigned char*)(&version), 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Workspace::destroyElectricBorders()
|
||||
{
|
||||
for (int pos = 0; pos < ELECTRIC_COUNT; ++pos) {
|
||||
if (electric_windows[pos] != None)
|
||||
XDestroyWindow(display(), electric_windows[pos]);
|
||||
electric_windows[pos] = None;
|
||||
}
|
||||
}
|
||||
|
||||
void Workspace::restoreElectricBorderSize(ElectricBorder border)
|
||||
{
|
||||
if (electric_windows[border] == None)
|
||||
return;
|
||||
QRect r = Kephal::ScreenUtils::desktopGeometry();
|
||||
int xywh[ELECTRIC_COUNT][4] = {
|
||||
{ r.left() + 1, r.top(), r.width() - 2, 1 }, // Top
|
||||
{ r.right(), r.top(), 1, 1 }, // Top-right
|
||||
{ r.right(), r.top() + 1, 1, r.height() - 2 }, // Etc.
|
||||
{ r.right(), r.bottom(), 1, 1 },
|
||||
{ r.left() + 1, r.bottom(), r.width() - 2, 1 },
|
||||
{ r.left(), r.bottom(), 1, 1 },
|
||||
{ r.left(), r.top() + 1, 1, r.height() - 2 },
|
||||
{ r.left(), r.top(), 1, 1 }
|
||||
};
|
||||
XMoveResizeWindow(display(), electric_windows[border],
|
||||
xywh[border][0], xywh[border][1], xywh[border][2], xywh[border][3]);
|
||||
}
|
||||
|
||||
void Workspace::reserveElectricBorderActions(bool reserve)
|
||||
{
|
||||
for (int pos = 0; pos < ELECTRIC_COUNT; ++pos)
|
||||
if (options->electricBorderAction(static_cast<ElectricBorder>(pos))) {
|
||||
if (reserve)
|
||||
reserveElectricBorder(static_cast<ElectricBorder>(pos));
|
||||
else
|
||||
unreserveElectricBorder(static_cast<ElectricBorder>(pos));
|
||||
}
|
||||
}
|
||||
|
||||
void Workspace::reserveElectricBorderSwitching(bool reserve)
|
||||
{
|
||||
for (int pos = 0; pos < ELECTRIC_COUNT; ++pos)
|
||||
if (reserve)
|
||||
reserveElectricBorder(static_cast<ElectricBorder>(pos));
|
||||
else
|
||||
unreserveElectricBorder(static_cast<ElectricBorder>(pos));
|
||||
}
|
||||
|
||||
void Workspace::reserveElectricBorder(ElectricBorder border)
|
||||
{
|
||||
if (border == ElectricNone)
|
||||
return;
|
||||
if (electric_reserved[border]++ == 0)
|
||||
QTimer::singleShot(0, this, SLOT(updateElectricBorders()));
|
||||
}
|
||||
|
||||
void Workspace::unreserveElectricBorder(ElectricBorder border)
|
||||
{
|
||||
if (border == ElectricNone)
|
||||
return;
|
||||
assert(electric_reserved[border] > 0);
|
||||
if (--electric_reserved[border] == 0)
|
||||
QTimer::singleShot(0, this, SLOT(updateElectricBorders()));
|
||||
}
|
||||
|
||||
void Workspace::checkElectricBorder(const QPoint& pos, Time now)
|
||||
{
|
||||
if ((pos.x() != electricLeft) &&
|
||||
(pos.x() != electricRight) &&
|
||||
(pos.y() != electricTop) &&
|
||||
(pos.y() != electricBottom))
|
||||
return;
|
||||
|
||||
bool have_borders = false;
|
||||
for (int i = 0; i < ELECTRIC_COUNT; ++i)
|
||||
if (electric_windows[i] != None)
|
||||
have_borders = true;
|
||||
if (!have_borders)
|
||||
return;
|
||||
|
||||
Time treshold_set = options->electricBorderDelay(); // Set timeout
|
||||
Time treshold_reset = 250; // Reset timeout
|
||||
Time treshold_trigger = options->electricBorderCooldown(); // Minimum time between triggers
|
||||
int distance_reset = 30; // Mouse should not move more than this many pixels
|
||||
int pushback_pixels = options->electricBorderPushbackPixels();
|
||||
|
||||
ElectricBorder border;
|
||||
if (pos.x() == electricLeft && pos.y() == electricTop)
|
||||
border = ElectricTopLeft;
|
||||
else if (pos.x() == electricRight && pos.y() == electricTop)
|
||||
border = ElectricTopRight;
|
||||
else if (pos.x() == electricLeft && pos.y() == electricBottom)
|
||||
border = ElectricBottomLeft;
|
||||
else if (pos.x() == electricRight && pos.y() == electricBottom)
|
||||
border = ElectricBottomRight;
|
||||
else if (pos.x() == electricLeft)
|
||||
border = ElectricLeft;
|
||||
else if (pos.x() == electricRight)
|
||||
border = ElectricRight;
|
||||
else if (pos.y() == electricTop)
|
||||
border = ElectricTop;
|
||||
else if (pos.y() == electricBottom)
|
||||
border = ElectricBottom;
|
||||
else
|
||||
abort();
|
||||
|
||||
if (electric_windows[border] == None)
|
||||
return;
|
||||
|
||||
if (pushback_pixels == 0) {
|
||||
// no pushback so we have to activate at once
|
||||
electric_time_last = now;
|
||||
}
|
||||
if ((electric_current_border == border) &&
|
||||
(timestampDiff(electric_time_last, now) < treshold_reset) &&
|
||||
(timestampDiff(electric_time_last_trigger, now) > treshold_trigger) &&
|
||||
((pos - electric_push_point).manhattanLength() < distance_reset)) {
|
||||
electric_time_last = now;
|
||||
|
||||
if (timestampDiff(electric_time_first, now) > treshold_set) {
|
||||
electric_current_border = ElectricNone;
|
||||
electric_time_last_trigger = now;
|
||||
if (movingClient) {
|
||||
// If moving a client or have force doing the desktop switch
|
||||
if (options->electricBorders() != Options::ElectricDisabled)
|
||||
electricBorderSwitchDesktop(border, pos);
|
||||
return; // Don't reset cursor position
|
||||
} else {
|
||||
if (options->electricBorders() == Options::ElectricAlways &&
|
||||
(border == ElectricTop || border == ElectricRight ||
|
||||
border == ElectricBottom || border == ElectricLeft)) {
|
||||
// If desktop switching is always enabled don't apply it to the corners if
|
||||
// an effect is applied to it (We will check that later).
|
||||
electricBorderSwitchDesktop(border, pos);
|
||||
return; // Don't reset cursor position
|
||||
}
|
||||
switch(options->electricBorderAction(border)) {
|
||||
case ElectricActionDashboard: { // Display Plasma dashboard
|
||||
QDBusInterface plasmaApp("org.kde.plasma-desktop", "/App");
|
||||
plasmaApp.call("toggleDashboard");
|
||||
}
|
||||
break;
|
||||
case ElectricActionShowDesktop: {
|
||||
setShowingDesktop(!showingDesktop());
|
||||
break;
|
||||
}
|
||||
case ElectricActionLockScreen: { // Lock the screen
|
||||
QDBusInterface screenSaver("org.kde.screensaver", "/ScreenSaver");
|
||||
screenSaver.call("Lock");
|
||||
}
|
||||
break;
|
||||
case ElectricActionPreventScreenLocking: {
|
||||
break;
|
||||
}
|
||||
case ElectricActionNone: // Either desktop switching or an effect
|
||||
default: {
|
||||
if (effects && static_cast<EffectsHandlerImpl*>(effects)->borderActivated(border))
|
||||
{} // Handled by effects
|
||||
else {
|
||||
electricBorderSwitchDesktop(border, pos);
|
||||
return; // Don't reset cursor position
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
electric_current_border = border;
|
||||
electric_time_first = now;
|
||||
electric_time_last = now;
|
||||
electric_push_point = pos;
|
||||
}
|
||||
|
||||
// Reset the pointer to find out whether the user is really pushing
|
||||
// (the direction back from which it came, starting from top clockwise)
|
||||
const int xdiff[ELECTRIC_COUNT] = { 0,
|
||||
-pushback_pixels,
|
||||
-pushback_pixels,
|
||||
-pushback_pixels,
|
||||
0,
|
||||
pushback_pixels,
|
||||
pushback_pixels,
|
||||
pushback_pixels
|
||||
};
|
||||
const int ydiff[ELECTRIC_COUNT] = { pushback_pixels,
|
||||
pushback_pixels,
|
||||
0,
|
||||
-pushback_pixels,
|
||||
-pushback_pixels,
|
||||
-pushback_pixels,
|
||||
0,
|
||||
pushback_pixels
|
||||
};
|
||||
QCursor::setPos(pos.x() + xdiff[border], pos.y() + ydiff[border]);
|
||||
}
|
||||
|
||||
void Workspace::electricBorderSwitchDesktop(ElectricBorder border, const QPoint& _pos)
|
||||
{
|
||||
QPoint pos = _pos;
|
||||
int desk = currentDesktop();
|
||||
const int OFFSET = 2;
|
||||
if (border == ElectricLeft || border == ElectricTopLeft || border == ElectricBottomLeft) {
|
||||
desk = desktopToLeft(desk, options->rollOverDesktops);
|
||||
pos.setX(displayWidth() - 1 - OFFSET);
|
||||
}
|
||||
if (border == ElectricRight || border == ElectricTopRight || border == ElectricBottomRight) {
|
||||
desk = desktopToRight(desk, options->rollOverDesktops);
|
||||
pos.setX(OFFSET);
|
||||
}
|
||||
if (border == ElectricTop || border == ElectricTopLeft || border == ElectricTopRight) {
|
||||
desk = desktopAbove(desk, options->rollOverDesktops);
|
||||
pos.setY(displayHeight() - 1 - OFFSET);
|
||||
}
|
||||
if (border == ElectricBottom || border == ElectricBottomLeft || border == ElectricBottomRight) {
|
||||
desk = desktopBelow(desk, options->rollOverDesktops);
|
||||
pos.setY(OFFSET);
|
||||
}
|
||||
int desk_before = currentDesktop();
|
||||
setCurrentDesktop(desk);
|
||||
if (currentDesktop() != desk_before)
|
||||
QCursor::setPos(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user entered an electric border with the mouse.
|
||||
* It may switch to another virtual desktop.
|
||||
*/
|
||||
bool Workspace::electricBorderEvent(XEvent* e)
|
||||
{
|
||||
if (e->type == EnterNotify) {
|
||||
for (int i = 0; i < ELECTRIC_COUNT; ++i)
|
||||
if (electric_windows[i] != None && e->xcrossing.window == electric_windows[i]) {
|
||||
// The user entered an electric border
|
||||
checkElectricBorder(QPoint(e->xcrossing.x_root, e->xcrossing.y_root), e->xcrossing.time);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (e->type == ClientMessage) {
|
||||
if (e->xclient.message_type == atoms->xdnd_position) {
|
||||
for (int i = 0; i < ELECTRIC_COUNT; ++i)
|
||||
if (electric_windows[i] != None && e->xclient.window == electric_windows[i]) {
|
||||
updateXTime();
|
||||
checkElectricBorder(QPoint(
|
||||
e->xclient.data.l[2] >> 16, e->xclient.data.l[2] & 0xffff), xTime());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
KDecoration* Workspace::createDecoration(KDecorationBridge* bridge)
|
||||
{
|
||||
if (!hasDecorationPlugin()) {
|
||||
|
|
26
workspace.h
26
workspace.h
|
@ -174,13 +174,6 @@ public:
|
|||
void clientHidden(Client*);
|
||||
void clientAttentionChanged(Client* c, bool set);
|
||||
|
||||
void checkElectricBorder(const QPoint& pos, Time time);
|
||||
void restoreElectricBorderSize(ElectricBorder border);
|
||||
void reserveElectricBorder(ElectricBorder border);
|
||||
void unreserveElectricBorder(ElectricBorder border);
|
||||
void reserveElectricBorderActions(bool reserve);
|
||||
void reserveElectricBorderSwitching(bool reserve);
|
||||
|
||||
/**
|
||||
* @return List of clients currently managed by Workspace
|
||||
**/
|
||||
|
@ -551,7 +544,6 @@ public:
|
|||
void startMousePolling();
|
||||
void stopMousePolling();
|
||||
|
||||
void raiseElectricBorderWindows();
|
||||
Client* getMovingClient() {
|
||||
return movingClient;
|
||||
}
|
||||
|
@ -717,7 +709,6 @@ private slots:
|
|||
void performCompositing();
|
||||
void performMousePoll();
|
||||
void lostCMSelection();
|
||||
void updateElectricBorders();
|
||||
void resetCursorPosTime();
|
||||
void delayedCheckUnredirect();
|
||||
|
||||
|
@ -809,11 +800,6 @@ private:
|
|||
void tabBoxKeyPress(int key);
|
||||
void tabBoxKeyRelease(const XKeyEvent& ev);
|
||||
|
||||
// Electric borders
|
||||
void destroyElectricBorders();
|
||||
bool electricBorderEvent(XEvent * e);
|
||||
void electricBorderSwitchDesktop(ElectricBorder border, const QPoint& pos);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void helperDialog(const QString& message, const Client* c);
|
||||
|
@ -968,18 +954,6 @@ private:
|
|||
|
||||
KStartupInfo* startup;
|
||||
|
||||
ElectricBorder electric_current_border;
|
||||
Window electric_windows[ELECTRIC_COUNT];
|
||||
int electricLeft;
|
||||
int electricRight;
|
||||
int electricTop;
|
||||
int electricBottom;
|
||||
Time electric_time_first;
|
||||
Time electric_time_last;
|
||||
Time electric_time_last_trigger;
|
||||
QPoint electric_push_point;
|
||||
int electric_reserved[ELECTRIC_COUNT]; // Corners/edges used by something
|
||||
|
||||
Placement* initPositioning;
|
||||
|
||||
QVector<QRect> workarea; // Array of workareas for virtual desktops
|
||||
|
|
Loading…
Reference in a new issue