remove some macros with questionable usefulness
This commit is contained in:
parent
d312ee24b8
commit
b4e8d44967
10 changed files with 116 additions and 110 deletions
|
@ -37,8 +37,6 @@
|
|||
|
||||
#include "../drm/gbm_dmabuf.h"
|
||||
|
||||
#define QSIZE_TO_QPOINT(size) QPointF(size.width(), size.height())
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
|
@ -46,6 +44,11 @@ namespace Wayland
|
|||
|
||||
using namespace KWayland::Client;
|
||||
|
||||
inline static QPointF sizeToPoint(const QSizeF &size)
|
||||
{
|
||||
return QPointF(size.width(), size.height());
|
||||
}
|
||||
|
||||
WaylandInputDevice::WaylandInputDevice(KWayland::Client::Keyboard *keyboard, WaylandSeat *seat)
|
||||
: m_seat(seat)
|
||||
, m_keyboard(keyboard)
|
||||
|
@ -131,7 +134,7 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::Pointer *pointer, Wayla
|
|||
Q_EMIT pinchGestureBegin(m_pinchGesture->fingerCount(), std::chrono::milliseconds(time), this);
|
||||
});
|
||||
connect(m_pinchGesture.get(), &PointerPinchGesture::updated, this, [this](const QSizeF &delta, qreal scale, qreal rotation, quint32 time) {
|
||||
Q_EMIT pinchGestureUpdate(scale, rotation, QSIZE_TO_QPOINT(delta), std::chrono::milliseconds(time), this);
|
||||
Q_EMIT pinchGestureUpdate(scale, rotation, sizeToPoint(delta), std::chrono::milliseconds(time), this);
|
||||
});
|
||||
connect(m_pinchGesture.get(), &PointerPinchGesture::ended, this, [this](quint32 serial, quint32 time) {
|
||||
Q_EMIT pinchGestureEnd(std::chrono::milliseconds(time), this);
|
||||
|
@ -145,7 +148,7 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::Pointer *pointer, Wayla
|
|||
Q_EMIT swipeGestureBegin(m_swipeGesture->fingerCount(), std::chrono::milliseconds(time), this);
|
||||
});
|
||||
connect(m_swipeGesture.get(), &PointerSwipeGesture::updated, this, [this](const QSizeF &delta, quint32 time) {
|
||||
Q_EMIT swipeGestureUpdate(QSIZE_TO_QPOINT(delta), std::chrono::milliseconds(time), this);
|
||||
Q_EMIT swipeGestureUpdate(sizeToPoint(delta), std::chrono::milliseconds(time), this);
|
||||
});
|
||||
connect(m_swipeGesture.get(), &PointerSwipeGesture::ended, this, [this](quint32 serial, quint32 time) {
|
||||
Q_EMIT swipeGestureEnd(std::chrono::milliseconds(time), this);
|
||||
|
@ -161,7 +164,7 @@ WaylandInputDevice::WaylandInputDevice(KWayland::Client::RelativePointer *relati
|
|||
, m_relativePointer(relativePointer)
|
||||
{
|
||||
connect(relativePointer, &RelativePointer::relativeMotion, this, [this](const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 timestamp) {
|
||||
Q_EMIT pointerMotion(QSIZE_TO_QPOINT(delta), QSIZE_TO_QPOINT(deltaNonAccelerated), std::chrono::microseconds(timestamp), this);
|
||||
Q_EMIT pointerMotion(sizeToPoint(delta), sizeToPoint(deltaNonAccelerated), std::chrono::microseconds(timestamp), this);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -62,43 +62,30 @@ bool DBusInterface::showingDesktop() const
|
|||
return workspace()->showingDesktop();
|
||||
}
|
||||
|
||||
// wrap void methods with no arguments to Workspace
|
||||
#define WRAP(name) \
|
||||
void DBusInterface::name() \
|
||||
{ \
|
||||
Workspace::self()->name(); \
|
||||
}
|
||||
|
||||
WRAP(reconfigure)
|
||||
|
||||
#undef WRAP
|
||||
void DBusInterface::reconfigure()
|
||||
{
|
||||
Workspace::self()->reconfigure();
|
||||
}
|
||||
|
||||
void DBusInterface::killWindow()
|
||||
{
|
||||
Workspace::self()->slotKillWindow();
|
||||
}
|
||||
|
||||
#define WRAP(name) \
|
||||
void DBusInterface::name() \
|
||||
{ \
|
||||
workspace()->placement()->name(); \
|
||||
}
|
||||
void DBusInterface::cascadeDesktop()
|
||||
{
|
||||
workspace()->placement()->cascadeDesktop();
|
||||
}
|
||||
|
||||
WRAP(cascadeDesktop)
|
||||
WRAP(unclutterDesktop)
|
||||
void DBusInterface::unclutterDesktop()
|
||||
{
|
||||
workspace()->placement()->unclutterDesktop();
|
||||
}
|
||||
|
||||
#undef WRAP
|
||||
|
||||
// wrap returning methods with no arguments to Workspace
|
||||
#define WRAP(rettype, name) \
|
||||
rettype DBusInterface::name() \
|
||||
{ \
|
||||
return Workspace::self()->name(); \
|
||||
}
|
||||
|
||||
WRAP(QString, supportInformation)
|
||||
|
||||
#undef WRAP
|
||||
QString DBusInterface::supportInformation()
|
||||
{
|
||||
return Workspace::self()->supportInformation();
|
||||
}
|
||||
|
||||
QString DBusInterface::activeOutputName()
|
||||
{
|
||||
|
|
|
@ -364,21 +364,19 @@ EffectLoader::~EffectLoader()
|
|||
{
|
||||
}
|
||||
|
||||
#define BOOL_MERGE(method) \
|
||||
bool EffectLoader::method(const QString &name) const \
|
||||
{ \
|
||||
for (auto it = m_loaders.constBegin(); it != m_loaders.constEnd(); ++it) { \
|
||||
if ((*it)->method(name)) { \
|
||||
return true; \
|
||||
} \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
bool EffectLoader::hasEffect(const QString &name) const
|
||||
{
|
||||
return std::any_of(m_loaders.cbegin(), m_loaders.cend(), [&name](const auto &loader) {
|
||||
return loader->hasEffect(name);
|
||||
});
|
||||
}
|
||||
|
||||
BOOL_MERGE(hasEffect)
|
||||
BOOL_MERGE(isEffectSupported)
|
||||
|
||||
#undef BOOL_MERGE
|
||||
bool EffectLoader::isEffectSupported(const QString &name) const
|
||||
{
|
||||
return std::any_of(m_loaders.cbegin(), m_loaders.cend(), [&name](const auto &loader) {
|
||||
return loader->isEffectSupported(name);
|
||||
});
|
||||
}
|
||||
|
||||
QStringList EffectLoader::listOfKnownEffects() const
|
||||
{
|
||||
|
|
|
@ -181,14 +181,6 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi
|
|||
}
|
||||
}
|
||||
|
||||
#define SANITIZE_PROGRESS \
|
||||
if (p_progress[0] < 0) { \
|
||||
p_progress[0] = -p_progress[0]; \
|
||||
} \
|
||||
if (p_progress[1] < 0) { \
|
||||
p_progress[1] = -p_progress[1]; \
|
||||
}
|
||||
|
||||
#define SET_QUADS(_SET_A_, _A_, _DA_, _SET_B_, _B_, _O0_, _O1_, _O2_, _O3_) \
|
||||
quad[0]._SET_A_((icon._A_() + icon._DA_() * (quad[0]._A_() / geo._DA_()) - (quad[0]._A_() + geo._A_())) * p_progress[_O0_] + quad[0]._A_()); \
|
||||
quad[1]._SET_A_((icon._A_() + icon._DA_() * (quad[1]._A_() / geo._DA_()) - (quad[1]._A_() + geo._A_())) * p_progress[_O1_] + quad[1]._A_()); \
|
||||
|
@ -231,7 +223,8 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi
|
|||
lastQuad = quad;
|
||||
}
|
||||
|
||||
SANITIZE_PROGRESS;
|
||||
p_progress[0] = std::abs(p_progress[0]);
|
||||
p_progress[1] = std::abs(p_progress[1]);
|
||||
// x values are moved towards the center of the icon
|
||||
SET_QUADS(setX, x, width, setY, y, 0, 0, 1, 1);
|
||||
}
|
||||
|
@ -253,7 +246,8 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi
|
|||
offset[0] = -offset[0];
|
||||
offset[1] = -offset[1];
|
||||
|
||||
SANITIZE_PROGRESS;
|
||||
p_progress[0] = std::abs(p_progress[0]);
|
||||
p_progress[1] = std::abs(p_progress[1]);
|
||||
// x values are moved towards the center of the icon
|
||||
SET_QUADS(setX, x, width, setY, y, 0, 0, 1, 1);
|
||||
}
|
||||
|
@ -275,7 +269,8 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi
|
|||
offset[0] = -offset[0];
|
||||
offset[1] = -offset[1];
|
||||
|
||||
SANITIZE_PROGRESS;
|
||||
p_progress[0] = std::abs(p_progress[0]);
|
||||
p_progress[1] = std::abs(p_progress[1]);
|
||||
// y values are moved towards the center of the icon
|
||||
SET_QUADS(setY, y, height, setX, x, 0, 1, 1, 0);
|
||||
}
|
||||
|
@ -294,7 +289,8 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi
|
|||
lastQuad = quad;
|
||||
}
|
||||
|
||||
SANITIZE_PROGRESS;
|
||||
p_progress[0] = std::abs(p_progress[0]);
|
||||
p_progress[1] = std::abs(p_progress[1]);
|
||||
// y values are moved towards the center of the icon
|
||||
SET_QUADS(setY, y, height, setX, x, 0, 1, 1, 0);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
#define NULL_POINT (QPoint(-1, -1)) // null point is (0,0), which is valid :-/
|
||||
static consteval QPoint nullPoint()
|
||||
{
|
||||
return QPoint(-1, -1);
|
||||
}
|
||||
|
||||
MouseMarkEffect::MouseMarkEffect()
|
||||
{
|
||||
|
@ -47,7 +50,7 @@ MouseMarkEffect::MouseMarkEffect()
|
|||
connect(effects, &EffectsHandler::mouseChanged, this, &MouseMarkEffect::slotMouseChanged);
|
||||
connect(effects, &EffectsHandler::screenLockingChanged, this, &MouseMarkEffect::screenLockingChanged);
|
||||
reconfigure(ReconfigureAll);
|
||||
arrow_start = NULL_POINT;
|
||||
arrow_start = nullPoint();
|
||||
effects->startMousePolling(); // We require it to detect activation as well
|
||||
}
|
||||
|
||||
|
@ -141,16 +144,16 @@ void MouseMarkEffect::slotMouseChanged(const QPoint &pos, const QPoint &,
|
|||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers)
|
||||
{
|
||||
if (modifiers == (Qt::META | Qt::SHIFT | Qt::CTRL)) { // start/finish arrow
|
||||
if (arrow_start != NULL_POINT) {
|
||||
if (arrow_start != nullPoint()) {
|
||||
marks.append(createArrow(arrow_start, pos));
|
||||
arrow_start = NULL_POINT;
|
||||
arrow_start = nullPoint();
|
||||
effects->addRepaintFull();
|
||||
return;
|
||||
} else {
|
||||
arrow_start = pos;
|
||||
}
|
||||
}
|
||||
if (arrow_start != NULL_POINT) {
|
||||
if (arrow_start != nullPoint()) {
|
||||
return;
|
||||
}
|
||||
// TODO the shortcuts now trigger this right before they're activated
|
||||
|
@ -182,8 +185,8 @@ void MouseMarkEffect::clear()
|
|||
|
||||
void MouseMarkEffect::clearLast()
|
||||
{
|
||||
if (arrow_start != NULL_POINT) {
|
||||
arrow_start = NULL_POINT;
|
||||
if (arrow_start != nullPoint()) {
|
||||
arrow_start = nullPoint();
|
||||
} else if (!drawing.isEmpty()) {
|
||||
drawing.clear();
|
||||
effects->addRepaintFull();
|
||||
|
|
|
@ -698,10 +698,8 @@ void X11Window::enterNotifyEvent(xcb_enter_notify_event_t *e)
|
|||
return; // care only about entering the whole frame
|
||||
}
|
||||
|
||||
#define MOUSE_DRIVEN_FOCUS (!options->focusPolicyIsReasonable() || (options->focusPolicy() == Options::FocusFollowsMouse && options->isNextFocusPrefersMouse()))
|
||||
if (e->mode == XCB_NOTIFY_MODE_NORMAL || (e->mode == XCB_NOTIFY_MODE_UNGRAB && MOUSE_DRIVEN_FOCUS)) {
|
||||
#undef MOUSE_DRIVEN_FOCUS
|
||||
|
||||
const bool mouseDrivenFocus = !options->focusPolicyIsReasonable() || (options->focusPolicy() == Options::FocusFollowsMouse && options->isNextFocusPrefersMouse());
|
||||
if (e->mode == XCB_NOTIFY_MODE_NORMAL || (e->mode == XCB_NOTIFY_MODE_UNGRAB && mouseDrivenFocus)) {
|
||||
pointerEnterEvent(QPoint(e->root_x, e->root_y));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
//#define QT_CLEAN_NAMESPACE
|
||||
|
||||
#include "group.h"
|
||||
#include "effects.h"
|
||||
#include "workspace.h"
|
||||
|
|
|
@ -206,22 +206,34 @@ Borders::~Borders()
|
|||
{
|
||||
}
|
||||
|
||||
#define SETTER(methodName, name) \
|
||||
void Borders::methodName(int name) \
|
||||
{ \
|
||||
if (m_##name == name) { \
|
||||
return; \
|
||||
} \
|
||||
m_##name = name; \
|
||||
Q_EMIT name##Changed(); \
|
||||
void Borders::setLeft(int left)
|
||||
{
|
||||
if (m_left != left) {
|
||||
m_left = left;
|
||||
Q_EMIT leftChanged();
|
||||
}
|
||||
|
||||
SETTER(setLeft, left)
|
||||
SETTER(setRight, right)
|
||||
SETTER(setTop, top)
|
||||
SETTER(setBottom, bottom)
|
||||
|
||||
#undef SETTER
|
||||
}
|
||||
void Borders::setRight(int right)
|
||||
{
|
||||
if (m_right != right) {
|
||||
m_right = right;
|
||||
Q_EMIT rightChanged();
|
||||
}
|
||||
}
|
||||
void Borders::setTop(int top)
|
||||
{
|
||||
if (m_top != top) {
|
||||
m_top = top;
|
||||
Q_EMIT topChanged();
|
||||
}
|
||||
}
|
||||
void Borders::setBottom(int bottom)
|
||||
{
|
||||
if (m_bottom != bottom) {
|
||||
m_bottom = bottom;
|
||||
Q_EMIT bottomChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Borders::setAllBorders(int border)
|
||||
{
|
||||
|
|
|
@ -194,20 +194,23 @@ void KeyboardInterface::sendKey(quint32 key, KeyboardKeyState state)
|
|||
void KeyboardInterface::sendModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group)
|
||||
{
|
||||
bool changed = false;
|
||||
#define UPDATE(value) \
|
||||
if (d->modifiers.value != value) { \
|
||||
d->modifiers.value = value; \
|
||||
changed = true; \
|
||||
if (d->modifiers.depressed != depressed) {
|
||||
d->modifiers.depressed = depressed;
|
||||
changed = true;
|
||||
}
|
||||
UPDATE(depressed)
|
||||
UPDATE(latched)
|
||||
UPDATE(locked)
|
||||
UPDATE(group)
|
||||
if (!changed) {
|
||||
return;
|
||||
if (d->modifiers.latched != latched) {
|
||||
d->modifiers.latched = latched;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!d->focusedSurface) {
|
||||
if (d->modifiers.locked != locked) {
|
||||
d->modifiers.locked = locked;
|
||||
changed = true;
|
||||
}
|
||||
if (d->modifiers.group != group) {
|
||||
d->modifiers.group = group;
|
||||
changed = true;
|
||||
}
|
||||
if (!changed || !d->focusedSurface) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2729,17 +2729,25 @@ bool Window::isActiveFullScreen() const
|
|||
return ac && (ac == this || !ac->isOnOutput(output()) || ac->allMainWindows().contains(const_cast<Window *>(this)));
|
||||
}
|
||||
|
||||
#define BORDER(which) \
|
||||
int Window::border##which() const \
|
||||
{ \
|
||||
return isDecorated() ? decoration()->border##which() : 0; \
|
||||
}
|
||||
int Window::borderBottom() const
|
||||
{
|
||||
return isDecorated() ? decoration()->borderBottom() : 0;
|
||||
}
|
||||
|
||||
BORDER(Bottom)
|
||||
BORDER(Left)
|
||||
BORDER(Right)
|
||||
BORDER(Top)
|
||||
#undef BORDER
|
||||
int Window::borderLeft() const
|
||||
{
|
||||
return isDecorated() ? decoration()->borderLeft() : 0;
|
||||
}
|
||||
|
||||
int Window::borderRight() const
|
||||
{
|
||||
return isDecorated() ? decoration()->borderRight() : 0;
|
||||
}
|
||||
|
||||
int Window::borderTop() const
|
||||
{
|
||||
return isDecorated() ? decoration()->borderTop() : 0;
|
||||
}
|
||||
|
||||
void Window::updateInitialMoveResizeGeometry()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue