Refactor KWin Outline code into an own class

This change unduplicates some code and merges it into one class
allowing us to use an replacement effect for the outline in
future.
CCMAIL: a.arlt@stud.uni-heidelberg.de
REVIEW: 100848
This commit is contained in:
Martin Gräßlin 2011-04-28 11:16:27 +02:00
parent 9586c0b8d4
commit ff3900d825
10 changed files with 343 additions and 188 deletions

View file

@ -94,6 +94,7 @@ set(kwin_KDEINIT_SRCS
tabbox/tabboxview.cpp tabbox/tabboxview.cpp
desktopchangeosd.cpp desktopchangeosd.cpp
options.cpp options.cpp
outline.cpp
plugins.cpp plugins.cpp
events.cpp events.cpp
killwindow.cpp killwindow.cpp

View file

@ -47,6 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kephal/screens.h> #include <kephal/screens.h>
#include <KDE/KGlobalSettings> #include <KDE/KGlobalSettings>
#include "outline.h"
namespace KWin namespace KWin
{ {
@ -2683,7 +2684,7 @@ void Client::finishMoveResize(bool cancel)
else else
workspace()->restoreElectricBorderSize(border); workspace()->restoreElectricBorderSize(border);
electricMaximizing = false; electricMaximizing = false;
workspace()->hideElectricBorderWindowOutline(); workspace()->outline()->hide();
} }
// FRAME update(); // FRAME update();
@ -3114,9 +3115,9 @@ void Client::setElectricBorderMaximizing(bool maximizing)
{ {
electricMaximizing = maximizing; electricMaximizing = maximizing;
if (maximizing) if (maximizing)
workspace()->showElectricBorderWindowOutline(); workspace()->outline()->show(electricBorderMaximizeGeometry(cursorPos(), desktop()));
else else
workspace()->hideElectricBorderWindowOutline(); workspace()->outline()->hide();
} }
QRect Client::electricBorderMaximizeGeometry(QPoint pos, int desktop) QRect Client::electricBorderMaximizeGeometry(QPoint pos, int desktop)

172
outline.cpp Normal file
View file

@ -0,0 +1,172 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2011 Arthur Arlt <a.arlt@stud.uni-heidelberg.de>
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 "outline.h"
#include <QtCore/QRect>
#include <QtGui/QX11Info>
#include <QtGui/QPainter>
#include <X11/Xlib.h>
namespace KWin {
Outline::Outline()
: m_initialized(false)
{
}
Outline::~Outline()
{
if (m_initialized) {
XDestroyWindow(QX11Info::display(), m_leftOutline);
XDestroyWindow(QX11Info::display(), m_rightOutline);
XDestroyWindow(QX11Info::display(), m_topOutline);
XDestroyWindow(QX11Info::display(), m_bottomOutline);
}
}
void Outline::show()
{
showWithX();
}
void Outline::hide()
{
hideWithX();
}
void Outline::show(const QRect& outlineGeometry)
{
setGeometry(outlineGeometry);
show();
}
void Outline::setGeometry(const QRect& outlineGeometry)
{
m_outlineGeometry = outlineGeometry;
}
QVector< Window > Outline::windowIds() const
{
QVector<Window> windows;
if (m_initialized) {
windows.reserve(4);
windows << m_leftOutline << m_topOutline << m_rightOutline << m_bottomOutline;
}
return windows;
}
void Outline::showWithX()
{
if (!m_initialized) {
XSetWindowAttributes attr;
attr.override_redirect = 1;
m_leftOutline = XCreateWindow(QX11Info::display(), QX11Info::appRootWindow(), 0, 0, 1, 1, 0,
CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr);
m_rightOutline = XCreateWindow(QX11Info::display(), QX11Info::appRootWindow(), 0, 0, 1, 1, 0,
CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr);
m_topOutline = XCreateWindow(QX11Info::display(), QX11Info::appRootWindow(), 0, 0, 1, 1, 0,
CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr);
m_bottomOutline = XCreateWindow(QX11Info::display(), QX11Info::appRootWindow(), 0, 0, 1, 1, 0,
CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr);
m_initialized = true;
}
// left/right parts are between top/bottom, they don't reach as far as the corners
XMoveResizeWindow(QX11Info::display(), m_leftOutline, m_outlineGeometry.x(), m_outlineGeometry.y() + 5, 5, m_outlineGeometry.height() - 10);
XMoveResizeWindow(QX11Info::display(), m_rightOutline, m_outlineGeometry.x() + m_outlineGeometry.width() - 5, m_outlineGeometry.y() + 5, 5, m_outlineGeometry.height() - 10);
XMoveResizeWindow(QX11Info::display(), m_topOutline, m_outlineGeometry.x(), m_outlineGeometry.y(), m_outlineGeometry.width(), 5);
XMoveResizeWindow(QX11Info::display(), m_bottomOutline, m_outlineGeometry.x(), m_outlineGeometry.y() + m_outlineGeometry.height() - 5, m_outlineGeometry.width(), 5);
{
QPixmap pix(5, m_outlineGeometry.height() - 10);
QPainter p(&pix);
p.setPen(Qt::white);
p.drawLine(0, 0, 0, pix.height() - 1);
p.drawLine(4, 0, 4, pix.height() - 1);
p.setPen(Qt::gray);
p.drawLine(1, 0, 1, pix.height() - 1);
p.drawLine(3, 0, 3, pix.height() - 1);
p.setPen(Qt::black);
p.drawLine(2, 0, 2, pix.height() - 1);
p.end();
XSetWindowBackgroundPixmap(QX11Info::display(), m_leftOutline, pix.handle());
XSetWindowBackgroundPixmap(QX11Info::display(), m_rightOutline, pix.handle());
}
{
QPixmap pix(m_outlineGeometry.width(), 5);
QPainter p(&pix);
p.setPen(Qt::white);
p.drawLine(0, 0, pix.width() - 1 - 0, 0);
p.drawLine(4, 4, pix.width() - 1 - 4, 4);
p.drawLine(0, 0, 0, 4);
p.drawLine(pix.width() - 1 - 0, 0, pix.width() - 1 - 0, 4);
p.setPen(Qt::gray);
p.drawLine(1, 1, pix.width() - 1 - 1, 1);
p.drawLine(3, 3, pix.width() - 1 - 3, 3);
p.drawLine(1, 1, 1, 4);
p.drawLine(3, 3, 3, 4);
p.drawLine(pix.width() - 1 - 1, 1, pix.width() - 1 - 1, 4);
p.drawLine(pix.width() - 1 - 3, 3, pix.width() - 1 - 3, 4);
p.setPen(Qt::black);
p.drawLine(2, 2, pix.width() - 1 - 2, 2);
p.drawLine(2, 2, 2, 4);
p.drawLine(pix.width() - 1 - 2, 2, pix.width() - 1 - 2, 4);
p.end();
XSetWindowBackgroundPixmap(QX11Info::display(), m_topOutline, pix.handle());
}
{
QPixmap pix(m_outlineGeometry.width(), 5);
QPainter p(&pix);
p.setPen(Qt::white);
p.drawLine(4, 0, pix.width() - 1 - 4, 0);
p.drawLine(0, 4, pix.width() - 1 - 0, 4);
p.drawLine(0, 4, 0, 0);
p.drawLine(pix.width() - 1 - 0, 4, pix.width() - 1 - 0, 0);
p.setPen(Qt::gray);
p.drawLine(3, 1, pix.width() - 1 - 3, 1);
p.drawLine(1, 3, pix.width() - 1 - 1, 3);
p.drawLine(3, 1, 3, 0);
p.drawLine(1, 3, 1, 0);
p.drawLine(pix.width() - 1 - 3, 1, pix.width() - 1 - 3, 0);
p.drawLine(pix.width() - 1 - 1, 3, pix.width() - 1 - 1, 0);
p.setPen(Qt::black);
p.drawLine(2, 2, pix.width() - 1 - 2, 2);
p.drawLine(2, 0, 2, 2);
p.drawLine(pix.width() - 1 - 2, 0, pix.width() - 1 - 2, 2);
p.end();
XSetWindowBackgroundPixmap(QX11Info::display(), m_bottomOutline, pix.handle());
}
XClearWindow(QX11Info::display(), m_leftOutline);
XClearWindow(QX11Info::display(), m_rightOutline);
XClearWindow(QX11Info::display(), m_topOutline);
XClearWindow(QX11Info::display(), m_bottomOutline);
XMapWindow(QX11Info::display(), m_leftOutline);
XMapWindow(QX11Info::display(), m_rightOutline);
XMapWindow(QX11Info::display(), m_topOutline);
XMapWindow(QX11Info::display(), m_bottomOutline);
}
void Outline::hideWithX()
{
XUnmapWindow(QX11Info::display(), m_leftOutline);
XUnmapWindow(QX11Info::display(), m_rightOutline);
XUnmapWindow(QX11Info::display(), m_topOutline);
XUnmapWindow(QX11Info::display(), m_bottomOutline);
}
} // namespace

103
outline.h Normal file
View file

@ -0,0 +1,103 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2011 Arthur Arlt <a.arlt@stud.uni-heidelberg.de>
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_OUTLINE_H
#define KWIN_OUTLINE_H
#include <X11/X.h>
#include <fixx11h.h>
#include <QtCore/QRect>
#include <QtCore/QVector>
namespace KWin {
/**
* @short This class is used to show the outline of a given geometry.
*
* The class renders an outline by using four windows. One for each border of
* the geometry. It is possible to replace the outline with an effect. If an
* effect is available the effect will be used, otherwise the outline will be
* rendered by using the X implementation.
*
* @author Arthur Arlt
* @since 4.7
*/
class Outline {
public:
Outline();
~Outline();
/**
* Set the outline geometry.
* To show the outline use @link showOutline.
* @param outlineGeometry The geometry of the outline to be shown
* @see showOutline
*/
void setGeometry(const QRect &outlineGeometry);
/**
* Shows the outline of a window using either an effect or the X implementation.
* To stop the outline process use @link hideOutline.
* @see hideOutline
*/
void show();
/**
* Shows the outline for the given @p outlineGeometry.
* This is the same as setOutlineGeometry followed by showOutline directly.
* To stop the outline process use @link hideOutline.
* @param outlineGeometry The geometry of the outline to be shown
* @see hideOutline
*/
void show(const QRect &outlineGeometry);
/**
* Hides shown outline.
* @see showOutline
*/
void hide();
/**
* Return outline window ids
* @return The window ids created to represent the outline
*/
QVector<Window> windowIds() const;
private:
/**
* Show the window outline using the X implementation
*/
void showWithX();
/**
* Hide previously shown outline used the X implementation
*/
void hideWithX();
Window m_topOutline;
Window m_rightOutline;
Window m_bottomOutline;
Window m_leftOutline;
QRect m_outlineGeometry;
bool m_initialized;
};
}
#endif

View file

@ -45,6 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <fixx11h.h> #include <fixx11h.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/keysymdef.h> #include <X11/keysymdef.h>
#include "outline.h"
// specify externals before namespace // specify externals before namespace
@ -195,6 +196,22 @@ TabBoxClient* TabBoxHandlerImpl::desktopClient() const
return NULL; return NULL;
} }
void TabBoxHandlerImpl::showOutline(const QRect &outline)
{
Workspace::self()->outline()->show(outline);
}
void TabBoxHandlerImpl::hideOutline()
{
Workspace::self()->outline()->hide();
}
QVector< Window > TabBoxHandlerImpl::outlineWindowIds() const
{
return Workspace::self()->outline()->windowIds();
}
/********************************************************* /*********************************************************
* TabBoxClientImpl * TabBoxClientImpl
*********************************************************/ *********************************************************/

View file

@ -58,6 +58,9 @@ public:
virtual void restack(TabBoxClient *c, TabBoxClient *under); virtual void restack(TabBoxClient *c, TabBoxClient *under);
virtual TabBoxClient* clientToAddToList(TabBoxClient* client, int desktop, bool allDesktops) const; virtual TabBoxClient* clientToAddToList(TabBoxClient* client, int desktop, bool allDesktops) const;
virtual TabBoxClient* desktopClient() const; virtual TabBoxClient* desktopClient() const;
virtual void hideOutline();
virtual void showOutline(const QRect &outline);
virtual QVector< Window > outlineWindowIds() const;
}; };
class TabBoxClientImpl : public TabBoxClient class TabBoxClientImpl : public TabBoxClient

View file

@ -58,10 +58,6 @@ public:
*/ */
void updateOutline(); void updateOutline();
/** /**
* Hides the currently shown outline.
*/
void hideOutline();
/**
* Updates the current highlight window state * Updates the current highlight window state
*/ */
void updateHighlightWindows(); void updateHighlightWindows();
@ -122,10 +118,6 @@ TabBoxHandlerPrivate::TabBoxHandlerPrivate(TabBoxHandler *q)
TabBoxHandlerPrivate::~TabBoxHandlerPrivate() TabBoxHandlerPrivate::~TabBoxHandlerPrivate()
{ {
delete view; delete view;
XDestroyWindow(QX11Info::display(), outlineLeft);
XDestroyWindow(QX11Info::display(), outlineRight);
XDestroyWindow(QX11Info::display(), outlineTop);
XDestroyWindow(QX11Info::display(), outlineBottom);
} }
ClientModel* TabBoxHandlerPrivate::clientModel() const ClientModel* TabBoxHandlerPrivate::clientModel() const
@ -144,91 +136,12 @@ void TabBoxHandlerPrivate::updateOutline()
return; return;
// if ( c == NULL || !m_isShown || !c->isShown( true ) || !c->isOnCurrentDesktop()) // if ( c == NULL || !m_isShown || !c->isShown( true ) || !c->isOnCurrentDesktop())
if (!isShown || view->clientModel()->data(index, ClientModel::EmptyRole).toBool()) { if (!isShown || view->clientModel()->data(index, ClientModel::EmptyRole).toBool()) {
hideOutline(); q->hideOutline();
return; return;
} }
TabBoxClient* c = static_cast< TabBoxClient* >( TabBoxClient* c = static_cast< TabBoxClient* >(
view->clientModel()->data(index, ClientModel::ClientRole).value<void *>()); view->clientModel()->data(index, ClientModel::ClientRole).value<void *>());
// left/right parts are between top/bottom, they don't reach as far as the corners q->showOutline(QRect(c->x(), c->y(), c->width(), c->height()));
XMoveResizeWindow(QX11Info::display(), outlineLeft, c->x(), c->y() + 5, 5, c->height() - 10);
XMoveResizeWindow(QX11Info::display(), outlineRight, c->x() + c->width() - 5, c->y() + 5, 5, c->height() - 10);
XMoveResizeWindow(QX11Info::display(), outlineTop, c->x(), c->y(), c->width(), 5);
XMoveResizeWindow(QX11Info::display(), outlineBottom, c->x(), c->y() + c->height() - 5, c->width(), 5);
{
QPixmap pix(5, c->height() - 10);
QPainter p(&pix);
p.setPen(Qt::white);
p.drawLine(0, 0, 0, pix.height() - 1);
p.drawLine(4, 0, 4, pix.height() - 1);
p.setPen(Qt::gray);
p.drawLine(1, 0, 1, pix.height() - 1);
p.drawLine(3, 0, 3, pix.height() - 1);
p.setPen(Qt::black);
p.drawLine(2, 0, 2, pix.height() - 1);
p.end();
XSetWindowBackgroundPixmap(QX11Info::display(), outlineLeft, pix.handle());
XSetWindowBackgroundPixmap(QX11Info::display(), outlineRight, pix.handle());
}
{
QPixmap pix(c->width(), 5);
QPainter p(&pix);
p.setPen(Qt::white);
p.drawLine(0, 0, pix.width() - 1 - 0, 0);
p.drawLine(4, 4, pix.width() - 1 - 4, 4);
p.drawLine(0, 0, 0, 4);
p.drawLine(pix.width() - 1 - 0, 0, pix.width() - 1 - 0, 4);
p.setPen(Qt::gray);
p.drawLine(1, 1, pix.width() - 1 - 1, 1);
p.drawLine(3, 3, pix.width() - 1 - 3, 3);
p.drawLine(1, 1, 1, 4);
p.drawLine(3, 3, 3, 4);
p.drawLine(pix.width() - 1 - 1, 1, pix.width() - 1 - 1, 4);
p.drawLine(pix.width() - 1 - 3, 3, pix.width() - 1 - 3, 4);
p.setPen(Qt::black);
p.drawLine(2, 2, pix.width() - 1 - 2, 2);
p.drawLine(2, 2, 2, 4);
p.drawLine(pix.width() - 1 - 2, 2, pix.width() - 1 - 2, 4);
p.end();
XSetWindowBackgroundPixmap(QX11Info::display(), outlineTop, pix.handle());
}
{
QPixmap pix(c->width(), 5);
QPainter p(&pix);
p.setPen(Qt::white);
p.drawLine(4, 0, pix.width() - 1 - 4, 0);
p.drawLine(0, 4, pix.width() - 1 - 0, 4);
p.drawLine(0, 4, 0, 0);
p.drawLine(pix.width() - 1 - 0, 4, pix.width() - 1 - 0, 0);
p.setPen(Qt::gray);
p.drawLine(3, 1, pix.width() - 1 - 3, 1);
p.drawLine(1, 3, pix.width() - 1 - 1, 3);
p.drawLine(3, 1, 3, 0);
p.drawLine(1, 3, 1, 0);
p.drawLine(pix.width() - 1 - 3, 1, pix.width() - 1 - 3, 0);
p.drawLine(pix.width() - 1 - 1, 3, pix.width() - 1 - 1, 0);
p.setPen(Qt::black);
p.drawLine(2, 2, pix.width() - 1 - 2, 2);
p.drawLine(2, 0, 2, 2);
p.drawLine(pix.width() - 1 - 2, 0, pix.width() - 1 - 2, 2);
p.end();
XSetWindowBackgroundPixmap(QX11Info::display(), outlineBottom, pix.handle());
}
XClearWindow(QX11Info::display(), outlineLeft);
XClearWindow(QX11Info::display(), outlineRight);
XClearWindow(QX11Info::display(), outlineTop);
XClearWindow(QX11Info::display(), outlineBottom);
XMapWindow(QX11Info::display(), outlineLeft);
XMapWindow(QX11Info::display(), outlineRight);
XMapWindow(QX11Info::display(), outlineTop);
XMapWindow(QX11Info::display(), outlineBottom);
}
void TabBoxHandlerPrivate::hideOutline()
{
XUnmapWindow(QX11Info::display(), outlineLeft);
XUnmapWindow(QX11Info::display(), outlineRight);
XUnmapWindow(QX11Info::display(), outlineTop);
XUnmapWindow(QX11Info::display(), outlineBottom);
} }
void TabBoxHandlerPrivate::updateHighlightWindows() void TabBoxHandlerPrivate::updateHighlightWindows()
@ -269,11 +182,11 @@ void TabBoxHandlerPrivate::updateHighlightWindows()
} }
data[ 0 ] = currentClient ? currentClient->window() : 0L; data[ 0 ] = currentClient ? currentClient->window() : 0L;
if (config.isShowOutline()) { if (config.isShowOutline()) {
data.resize(6); QVector<Window> outlineWindows = q->outlineWindowIds();
data[ 2 ] = outlineLeft; data.resize(2+outlineWindows.size());
data[ 3 ] = outlineTop; for (int i=0; i<outlineWindows.size(); ++i) {
data[ 4 ] = outlineRight; data[2+i] = outlineWindows[i];
data[ 5 ] = outlineBottom; }
} }
Atom atom = XInternAtom(dpy, "_KDE_WINDOW_HIGHLIGHT", False); Atom atom = XInternAtom(dpy, "_KDE_WINDOW_HIGHLIGHT", False);
XChangeProperty(dpy, wId, atom, atom, 32, PropModeReplace, XChangeProperty(dpy, wId, atom, atom, 32, PropModeReplace,
@ -492,7 +405,7 @@ void TabBoxHandler::hide(bool abort)
d->endHighlightWindows(abort); d->endHighlightWindows(abort);
} }
if (d->config.isShowOutline()) { if (d->config.isShowOutline()) {
d->hideOutline(); hideOutline();
} }
d->view->hide(); d->view->hide();
} }

View file

@ -312,6 +312,27 @@ public:
*/ */
QWidget* tabBoxView() const; QWidget* tabBoxView() const;
protected:
/**
* Show the outline of the current selected window
* @param outline The geometry of the window the outline will be shown
* @since 4.7
**/
virtual void showOutline(const QRect &outline) = 0;
/**
* Hide previously shown outline
* @since 4.7
**/
virtual void hideOutline() = 0;
/**
* Return outline window ids
* @return The outline window ids given in the order left, top, right, bottom
* @since 4.7
**/
virtual QVector<Window> outlineWindowIds() const = 0;
signals: signals:
/** /**
* This signal is fired when the TabBoxConfig changes * This signal is fired when the TabBoxConfig changes
@ -320,6 +341,7 @@ signals:
void configChanged(); void configChanged();
private: private:
friend class TabBoxHandlerPrivate;
TabBoxHandlerPrivate* d; TabBoxHandlerPrivate* d;
}; };

View file

@ -50,6 +50,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "atoms.h" #include "atoms.h"
#include "placement.h" #include "placement.h"
#include "notifications.h" #include "notifications.h"
#include "outline.h"
#include "group.h" #include "group.h"
#include "rules.h" #include "rules.h"
#include "kwinadaptor.h" #include "kwinadaptor.h"
@ -239,6 +240,7 @@ Workspace::Workspace(bool restore)
client_keys = new KActionCollection(this); client_keys = new KActionCollection(this);
initShortcuts(); initShortcuts();
desktop_change_osd = new DesktopChangeOSD(this); desktop_change_osd = new DesktopChangeOSD(this);
m_outline = new Outline();
init(); init();
@ -515,6 +517,7 @@ Workspace::~Workspace()
(*it)->release(); (*it)->release();
delete tab_box; delete tab_box;
delete desktop_change_osd; delete desktop_change_osd;
delete m_outline;
discardPopup(); discardPopup();
XDeleteProperty(display(), rootWindow(), atoms->kwin_running); XDeleteProperty(display(), rootWindow(), atoms->kwin_running);
@ -2438,94 +2441,6 @@ bool Workspace::electricBorderEvent(XEvent* e)
return false; return false;
} }
void Workspace::showElectricBorderWindowOutline()
{
if (!movingClient)
return;
// code copied from TabBox::updateOutline() in tabbox.cpp
QRect c = movingClient->electricBorderMaximizeGeometry(cursorPos(), currentDesktop());
// left/right parts are between top/bottom, they don't reach as far as the corners
XMoveResizeWindow(QX11Info::display(), outline_left, c.x(), c.y() + 5, 5, c.height() - 10);
XMoveResizeWindow(QX11Info::display(), outline_right, c.x() + c.width() - 5, c.y() + 5, 5, c.height() - 10);
XMoveResizeWindow(QX11Info::display(), outline_top, c.x(), c.y(), c.width(), 5);
XMoveResizeWindow(QX11Info::display(), outline_bottom, c.x(), c.y() + c.height() - 5, c.width(), 5);
{
QPixmap pix(5, c.height() - 10);
QPainter p(&pix);
p.setPen(Qt::white);
p.drawLine(0, 0, 0, pix.height() - 1);
p.drawLine(4, 0, 4, pix.height() - 1);
p.setPen(Qt::gray);
p.drawLine(1, 0, 1, pix.height() - 1);
p.drawLine(3, 0, 3, pix.height() - 1);
p.setPen(Qt::black);
p.drawLine(2, 0, 2, pix.height() - 1);
p.end();
XSetWindowBackgroundPixmap(QX11Info::display(), outline_left, pix.handle());
XSetWindowBackgroundPixmap(QX11Info::display(), outline_right, pix.handle());
}
{
QPixmap pix(c.width(), 5);
QPainter p(&pix);
p.setPen(Qt::white);
p.drawLine(0, 0, pix.width() - 1 - 0, 0);
p.drawLine(4, 4, pix.width() - 1 - 4, 4);
p.drawLine(0, 0, 0, 4);
p.drawLine(pix.width() - 1 - 0, 0, pix.width() - 1 - 0, 4);
p.setPen(Qt::gray);
p.drawLine(1, 1, pix.width() - 1 - 1, 1);
p.drawLine(3, 3, pix.width() - 1 - 3, 3);
p.drawLine(1, 1, 1, 4);
p.drawLine(3, 3, 3, 4);
p.drawLine(pix.width() - 1 - 1, 1, pix.width() - 1 - 1, 4);
p.drawLine(pix.width() - 1 - 3, 3, pix.width() - 1 - 3, 4);
p.setPen(Qt::black);
p.drawLine(2, 2, pix.width() - 1 - 2, 2);
p.drawLine(2, 2, 2, 4);
p.drawLine(pix.width() - 1 - 2, 2, pix.width() - 1 - 2, 4);
p.end();
XSetWindowBackgroundPixmap(QX11Info::display(), outline_top, pix.handle());
}
{
QPixmap pix(c.width(), 5);
QPainter p(&pix);
p.setPen(Qt::white);
p.drawLine(4, 0, pix.width() - 1 - 4, 0);
p.drawLine(0, 4, pix.width() - 1 - 0, 4);
p.drawLine(0, 4, 0, 0);
p.drawLine(pix.width() - 1 - 0, 4, pix.width() - 1 - 0, 0);
p.setPen(Qt::gray);
p.drawLine(3, 1, pix.width() - 1 - 3, 1);
p.drawLine(1, 3, pix.width() - 1 - 1, 3);
p.drawLine(3, 1, 3, 0);
p.drawLine(1, 3, 1, 0);
p.drawLine(pix.width() - 1 - 3, 1, pix.width() - 1 - 3, 0);
p.drawLine(pix.width() - 1 - 1, 3, pix.width() - 1 - 1, 0);
p.setPen(Qt::black);
p.drawLine(2, 2, pix.width() - 1 - 2, 2);
p.drawLine(2, 0, 2, 2);
p.drawLine(pix.width() - 1 - 2, 0, pix.width() - 1 - 2, 2);
p.end();
XSetWindowBackgroundPixmap(QX11Info::display(), outline_bottom, pix.handle());
}
XClearWindow(QX11Info::display(), outline_left);
XClearWindow(QX11Info::display(), outline_right);
XClearWindow(QX11Info::display(), outline_top);
XClearWindow(QX11Info::display(), outline_bottom);
XMapWindow(QX11Info::display(), outline_left);
XMapWindow(QX11Info::display(), outline_right);
XMapWindow(QX11Info::display(), outline_top);
XMapWindow(QX11Info::display(), outline_bottom);
}
void Workspace::hideElectricBorderWindowOutline()
{
XUnmapWindow(QX11Info::display(), outline_left);
XUnmapWindow(QX11Info::display(), outline_right);
XUnmapWindow(QX11Info::display(), outline_top);
XUnmapWindow(QX11Info::display(), outline_bottom);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Top menu // Top menu
@ -2941,6 +2856,11 @@ Client* Workspace::findSimilarClient(Client* c)
return found; return found;
} }
Outline* Workspace::outline()
{
return m_outline;
}
} // namespace } // namespace
#include "workspace.moc" #include "workspace.moc"

View file

@ -68,6 +68,7 @@ class Tile;
class TilingLayout; class TilingLayout;
class ClientGroup; class ClientGroup;
class DesktopChangeOSD; class DesktopChangeOSD;
class Outline;
class RootInfo; class RootInfo;
class PluginMgr; class PluginMgr;
class Placement; class Placement;
@ -219,6 +220,8 @@ public:
Position supportedTilingResizeMode(Client *c, Position currentMode); Position supportedTilingResizeMode(Client *c, Position currentMode);
Outline* outline();
//------------------------------------------------- //-------------------------------------------------
// Desktop layout // Desktop layout
@ -327,6 +330,8 @@ private:
// without having to remember to subtract one. // without having to remember to subtract one.
QVector<TilingLayout *> tilingLayouts; QVector<TilingLayout *> tilingLayouts;
Outline* m_outline;
//------------------------------------------------- //-------------------------------------------------
// Unsorted // Unsorted
@ -549,8 +554,6 @@ public:
void stopMousePolling(); void stopMousePolling();
void raiseElectricBorderWindows(); void raiseElectricBorderWindows();
void showElectricBorderWindowOutline();
void hideElectricBorderWindowOutline();
public slots: public slots:
void addRepaintFull(); void addRepaintFull();