move all the window system classes into a kwindowsystem module with tier1 compliant deps

* classes in kdeui/windowmanagement moved to kwindowsystem
* Plasma::WindowEffects moved to kwindowsystem
* helper KSystemEventFilter and KSystemEventfilter, only used by these classes, move to kwindowsystem
* copy of helper KXerrorHandler, which is also used by KManagerSelection in kdeui

helpers are made private, KManagerSelection usage needs to be profiled and the duplication of
KXErrorHandler rectified

note: this commit breaks the build of other parts of kdelibs; cleaned up in commits to follow
This commit is contained in:
Aaron Seigo 2012-02-19 13:03:26 +01:00
parent 729988ffb1
commit d758c96faf
3 changed files with 0 additions and 514 deletions

View File

@ -168,7 +168,6 @@ set(plasma_LIB_SRCS
version.cpp
view.cpp
wallpaper.cpp
windoweffects.cpp
#Temporary QtJolie branch
@ -335,7 +334,6 @@ set(plasma_LIB_INCLUDES
dialog.h
pluginloader.h
paintutils.h
windoweffects.h
framesvg.h
package.h
packagestructure.h

View File

@ -1,343 +0,0 @@
/*
* Copyright 2009 Marco Martin <notmart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "windoweffects.h"
#include <QVarLengthArray>
#include <kwindowsystem.h>
#include "theme.h"
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <QX11Info>
static const char *DASHBOARD_WIN_NAME = "dashboard";
static const char *DASHBOARD_WIN_CLASS = "dashboard";
#endif
namespace Plasma
{
namespace WindowEffects
{
//FIXME: check if this works for any atom?
bool isEffectAvailable(Effect effect)
{
if (!Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) {
return false;
}
#ifdef Q_WS_X11
QString effectName;
switch (effect) {
case Slide:
effectName = "_KDE_SLIDE";
break;
case WindowPreview:
effectName = "_KDE_WINDOW_PREVIEW";
break;
case PresentWindows:
effectName = "_KDE_PRESENT_WINDOWS_DESKTOP";
break;
case PresentWindowsGroup:
effectName = "_KDE_PRESENT_WINDOWS_GROUP";
break;
case HighlightWindows:
effectName = "_KDE_WINDOW_HIGHLIGHT";
break;
case OverrideShadow:
effectName = "_KDE_SHADOW_OVERRIDE";
break;
case BlurBehind:
effectName = "_KDE_NET_WM_BLUR_BEHIND_REGION";
break;
case Dashboard:
// TODO: Better namespacing for atoms
effectName = "_WM_EFFECT_KDE_DASHBOARD";
break;
default:
return false;
}
// hackish way to find out if KWin has the effect enabled,
// TODO provide proper support
Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, effectName.toLatin1(), False);
int cnt;
Atom *list = XListProperties(dpy, DefaultRootWindow(dpy), &cnt);
if (list != NULL) {
bool ret = (qFind(list, list + cnt, atom) != list + cnt);
XFree(list);
return ret;
}
#endif
return false;
}
void slideWindow(WId id, Plasma::Location location, int offset)
{
#ifdef Q_WS_X11
Display *dpy = QX11Info::display();
Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False );
QVarLengthArray<long, 2> data(2);
data[0] = offset;
switch (location) {
case LeftEdge:
data[1] = 0;
break;
case TopEdge:
data[1] = 1;
break;
case RightEdge:
data[1] = 2;
break;
case BottomEdge:
data[1] = 3;
default:
break;
}
if (location == Desktop || location == Floating) {
XDeleteProperty(dpy, id, atom);
} else {
XChangeProperty(dpy, id, atom, atom, 32, PropModeReplace,
reinterpret_cast<unsigned char *>(data.data()), data.size());
}
#endif
}
void slideWindow(QWidget *widget, Plasma::Location location)
{
#ifdef Q_WS_X11
Display *dpy = QX11Info::display();
Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False );
QVarLengthArray<long, 2> data(2);
data[0] = -1;
switch (location) {
case LeftEdge:
data[1] = 0;
break;
case TopEdge:
data[1] = 1;
break;
case RightEdge:
data[1] = 2;
break;
case BottomEdge:
data[1] = 3;
default:
break;
}
if (location == Desktop || location == Floating) {
XDeleteProperty(dpy, widget->effectiveWinId(), atom);
} else {
XChangeProperty(dpy, widget->effectiveWinId(), atom, atom, 32, PropModeReplace,
reinterpret_cast<unsigned char *>(data.data()), data.size());
}
#endif
}
QList<QSize> windowSizes(const QList<WId> &ids)
{
QList<QSize> windowSizes;
foreach (WId id, ids) {
#ifdef Q_WS_X11
if (id > 0) {
KWindowInfo info = KWindowSystem::windowInfo(id, NET::WMGeometry|NET::WMFrameExtents);
windowSizes.append(info.frameGeometry().size());
} else {
windowSizes.append(QSize());
}
#else
windowSizes.append(QSize());
#endif
}
return windowSizes;
}
void showWindowThumbnails(WId parent, const QList<WId> &windows, const QList<QRect> &rects)
{
if (windows.size() != rects.size()) {
return;
}
#ifdef Q_WS_X11
Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, "_KDE_WINDOW_PREVIEW", False);
if (windows.isEmpty()) {
XDeleteProperty(dpy, parent, atom);
return;
}
int numWindows = windows.size();
// 64 is enough for 10 windows and is a nice base 2 number
QVarLengthArray<long, 64> data(1 + (6 * numWindows));
data[0] = numWindows;
QList<WId>::const_iterator windowsIt;
QList<QRect>::const_iterator rectsIt = rects.constBegin();
int i = 0;
for (windowsIt = windows.constBegin(); windowsIt != windows.constEnd(); ++windowsIt) {
const int start = (i * 6) + 1;
const QRect thumbnailRect = (*rectsIt);
data[start] = 5;
data[start+1] = (*windowsIt);
data[start+2] = thumbnailRect.x();
data[start+3] = thumbnailRect.y();
data[start+4] = thumbnailRect.width();
data[start+5] = thumbnailRect.height();
++rectsIt;
++i;
}
XChangeProperty(dpy, parent, atom, atom, 32, PropModeReplace,
reinterpret_cast<unsigned char *>(data.data()), data.size());
#endif
}
void presentWindows(WId controller, const QList<WId> &ids)
{
#ifdef Q_WS_X11
const int numWindows = ids.count();
QVarLengthArray<long, 32> data(numWindows);
int actualCount = 0;
for (int i = 0; i < numWindows; ++i) {
data[i] = ids.at(i);
++actualCount;
}
if (actualCount != numWindows) {
data.resize(actualCount);
}
if (!data.isEmpty()) {
Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, "_KDE_PRESENT_WINDOWS_GROUP", False);
XChangeProperty(dpy, controller, atom, atom, 32, PropModeReplace,
reinterpret_cast<unsigned char *>(data.data()), data.size());
}
#endif
}
void presentWindows(WId controller, int desktop)
{
#ifdef Q_WS_X11
QVarLengthArray<long, 1> data(1);
data[0] = desktop;
Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, "_KDE_PRESENT_WINDOWS_DESKTOP", False);
XChangeProperty(dpy, controller, atom, atom, 32, PropModeReplace,
reinterpret_cast<unsigned char *>(data.data()), data.size());
#endif
}
void highlightWindows(WId controller, const QList<WId> &ids)
{
#ifdef Q_WS_X11
const int numWindows = ids.count();
Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, "_KDE_WINDOW_HIGHLIGHT", False);
if (numWindows == 0) {
Atom atom = XInternAtom(dpy, "_KDE_WINDOW_HIGHLIGHT", False);
XDeleteProperty(dpy, controller, atom);
}
QVarLengthArray<long, 32> data(numWindows);
int actualCount = 0;
for (int i = 0; i < numWindows; ++i) {
data[i] = ids.at(i);
++actualCount;
}
if (actualCount != numWindows) {
data.resize(actualCount);
}
if (!data.isEmpty()) {
XChangeProperty(dpy, controller, atom, atom, 32, PropModeReplace,
reinterpret_cast<unsigned char *>(data.data()), data.size());
}
#endif
}
void overrideShadow(WId window, bool override)
{
#ifdef Q_WS_X11
Display *dpy = QX11Info::display();
Atom atom = XInternAtom( dpy, "_KDE_SHADOW_OVERRIDE", False );
if (!override) {
XDeleteProperty(dpy, window, atom);
} else {
QVarLengthArray<long, 1> data(1);
data[0] = 1;
XChangeProperty(dpy, window, atom, atom, 32, PropModeReplace,
reinterpret_cast<unsigned char *>(data.data()), data.size());
}
#endif
}
void enableBlurBehind(WId window, bool enable, const QRegion &region)
{
#ifdef Q_WS_X11
Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, "_KDE_NET_WM_BLUR_BEHIND_REGION", False);
if (enable) {
QVector<QRect> rects = region.rects();
QVector<unsigned long> data;
foreach (const QRect &r, rects) {
data << r.x() << r.y() << r.width() << r.height();
}
XChangeProperty(dpy, window, atom, XA_CARDINAL, 32, PropModeReplace,
reinterpret_cast<const unsigned char *>(data.constData()), data.size());
} else {
XDeleteProperty(dpy, window, atom);
}
#endif
}
void markAsDashboard(WId window)
{
#ifdef Q_WS_X11
XClassHint classHint;
classHint.res_name = const_cast<char *>(DASHBOARD_WIN_NAME);
classHint.res_class = const_cast<char *>(DASHBOARD_WIN_CLASS);
XSetClassHint(QX11Info::display(), window, &classHint);
#endif
}
}
}

View File

@ -1,169 +0,0 @@
/*
* Copyright 2009 Marco Martin <notmart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_WINDOWEFFECTS_H
#define PLASMA_WINDOWEFFECTS_H
#include <QWidget>
#include <plasma/plasma.h>
/** @headerfile plasma/windoweffect.h <Plasma/WindowEffect> */
namespace Plasma
{
/**
* Namespace for all window effects for Plasma/KWin interaction
* @since 4.4
*/
namespace WindowEffects
{
enum Effect {
Slide = 1,
WindowPreview = 2,
PresentWindows = 3,
PresentWindowsGroup = 4,
HighlightWindows = 5,
OverrideShadow = 6,
BlurBehind = 7,
Dashboard = 8
};
/**
* @return if an atom property is available
*
* @param effect the effect we want to check
* @since 4.4
*/
PLASMA_EXPORT bool isEffectAvailable(Effect effect);
/**
* Mark a window as sliding from screen edge
*
* @param id of the window on which we want to apply the effect
* @param location edge of the screen from which we want the sliding effect.
* Desktop and Floating won't have effect.
* @param offset distance in pixels from the screen edge defined by location
* @since 4.4
*/
PLASMA_EXPORT void slideWindow(WId id, Plasma::Location location, int offset);
/**
* Mark a window as sliding from screen edge
* This is an overloaded member function provided for convenience
*
* @param widget QWidget corresponding to the top level window we want to animate
* @param location edge of the screen from which we want the sliding effect.
* Desktop and Floating won't have effect.
* @since 4.4
*/
PLASMA_EXPORT void slideWindow(QWidget *widget, Plasma::Location location);
/**
* @return dimension of all the windows passed as parameter
*
* @param ids all the windows we want the size
* @since 4.4
*/
PLASMA_EXPORT QList<QSize> windowSizes(const QList<WId> &ids);
/**
* Paint inside the window parent the thumbnails of the windows list in
* the respective rectangles of the rects list
*
* @param parent window where we should paint
* @param windows windows we want a thumbnail of.
* If it is empty any thumbnail will be deleted
* @param rects rectangles in parent coordinates where to paint the window thumbnails.
* If it is empty any thumbnail will be deleted
* @since 4.4
*/
PLASMA_EXPORT void showWindowThumbnails(WId parent, const QList<WId> &windows = QList<WId>(), const QList<QRect> &rects = QList<QRect>());
/**
* Activate the Present Windows effect for the given groups of windows.
*
* @param controller The window which is the controller of this effect. The property
* will be set on this window. It will be removed by the effect
* @param ids all the windows which should be presented.
* @since 4.4
*/
PLASMA_EXPORT void presentWindows(WId controller, const QList<WId> &ids);
/**
* Activate the Present Windows effect for the windows of the given desktop.
*
* @param controller The window which is the controller of this effect. The property
* will be set on this window. It will be removed by the effect
* @param desktop The desktop whose windows should be presented. -1 for all desktops
* @since 4.4
*/
PLASMA_EXPORT void presentWindows(WId controller, int desktop = -1);
/**
* Highlight the selected windows, making all the others translucent
*
* @param controller The window which is the controller of this effect. The property
* will be set on this window. It will be removed by the effect
* @param ids all the windows which should be highlighted.
* @since 4.4
*/
PLASMA_EXPORT void highlightWindows(WId controller, const QList<WId> &ids);
/**
* Forbid te windowmanager to automatically generate a shadow for this window
* @param window the window that won't have shadow
* @param override true if it won't have shadow, false enables it again
*
* @since 4.4
*/
PLASMA_EXPORT void overrideShadow(WId window, bool override);
/**
* Instructs the window manager to blur the background in the specified region
* behind the given window. Passing a null region will enable the blur effect
* for the whole window. The region is relative to the top-left corner of the
* client area.
*
* Note that you will usually want to set the region to the shape of the window,
* excluding any shadow or halo.
*
* @param window The window for which to enable the blur effect
* @param enable Enable the effect if @a true, disable it if @false
* @param region The region within the window where the background will be blurred
* @since 4.5
*/
PLASMA_EXPORT void enableBlurBehind(WId window, bool enable = true, const QRegion &region = QRegion());
/**
* Instructs the window manager to handle the given window as dashboard window as
* Dashboard windows should be handled diffrently and may have special effects
* applied to them.
*
* @param window The window for which to enable the blur effect
* @since 4.6
*/
PLASMA_EXPORT void markAsDashboard(WId window);
}
} // namespace Plasma
#endif