Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
fix: use floating geometry to be compatible with KWin 5.26
Browse files Browse the repository at this point in the history
  • Loading branch information
gikari committed Sep 19, 2022
1 parent 042123b commit 8fd8a0f
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/core/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void Engine::arrangeWindowsOnSurface(const Surface &surface)
layout.apply(tilingArea, windowsThatCanBeTiled);
}

QRect Engine::workingArea(const Surface &surface) const
QRectF Engine::workingArea(const Surface &surface) const
{
return m_plasmaApi.workspace().clientArea(PlasmaApi::Workspace::PlacementArea, surface.screen(), surface.desktop());
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/engine/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct Engine {
Surface activeSurface() const;

void arrangeWindowsOnSurface(const Surface &);
QRect workingArea(const Surface &surface) const;
QRectF workingArea(const Surface &surface) const;

const Bismuth::Config &m_config;
WindowsList m_windows;
Expand Down
2 changes: 1 addition & 1 deletion src/core/engine/layout/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Layout::Layout(const Bismuth::Config &config)
{
}

QRect Layout::tilingArea(QRect workingArea) const
QRectF Layout::tilingArea(QRectF workingArea) const
{
auto marginLeft = m_config.screenGapLeft();
auto marginTop = m_config.screenGapTop();
Expand Down
4 changes: 2 additions & 2 deletions src/core/engine/layout/layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ struct Layout {
* Apply layout for the @p windows on tiling @p area. Method changes the
* geometry of the windows to match the particular layout.
*/
virtual void apply(QRect area, std::vector<Window> &windows) const = 0;
virtual void apply(QRectF area, std::vector<Window> &windows) const = 0;

/**
* Get the area on which tiled windows could be placed given the general @p workingArea
*/
virtual QRect tilingArea(QRect workingArea) const;
virtual QRectF tilingArea(QRectF workingArea) const;

protected:
const Bismuth::Config &m_config;
Expand Down
2 changes: 1 addition & 1 deletion src/core/engine/layout/monocle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Bismuth
{
void Monocle::apply(QRect area, std::vector<Window> &windows) const
void Monocle::apply(QRectF area, std::vector<Window> &windows) const
{
for (auto &window : windows) {
// Place the window on the all available area
Expand Down
2 changes: 1 addition & 1 deletion src/core/engine/layout/monocle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace Bismuth
struct Monocle : Layout {
using Layout::Layout;

virtual void apply(QRect area, std::vector<Window> &windows) const override;
virtual void apply(QRectF area, std::vector<Window> &windows) const override;
};
}
2 changes: 1 addition & 1 deletion src/core/engine/layout/stacked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Bismuth
{
void Stacked::apply(QRect area, std::vector<Window> &windows) const
void Stacked::apply(QRectF area, std::vector<Window> &windows) const
{
}
}
2 changes: 1 addition & 1 deletion src/core/engine/layout/stacked.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace Bismuth
struct Stacked : Layout {
using Layout::Layout;

virtual void apply(QRect area, std::vector<Window> &windows) const override;
virtual void apply(QRectF area, std::vector<Window> &windows) const override;
};
}
4 changes: 2 additions & 2 deletions src/core/engine/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ void Window::activate()
m_workspace.get().setActiveClient(m_client);
}

QRect Window::geometry() const
QRectF Window::geometry() const
{
return m_client.frameGeometry();
}

void Window::setGeometry(QRect newGeometry)
void Window::setGeometry(QRectF newGeometry)
{
m_client.setFrameGeometry(newGeometry);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/engine/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct Window {

void activate();

QRect geometry() const;
void setGeometry(QRect);
QRectF geometry() const;
void setGeometry(QRectF);

void setMode(Mode);
Mode mode() const;
Expand Down
22 changes: 11 additions & 11 deletions src/core/plasma-api/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Window : public QObject
* occupies on the screen. This rectangle includes invisible portions of the
* window, e.g. client-side drop shadows, etc.
*/
BI_READONLY_PROPERTY(QRect, bufferGeometry)
// Q_PROPERTY(QRect bufferGeometry READ bufferGeometry)
BI_READONLY_PROPERTY(QRectF, bufferGeometry)
// Q_PROPERTY(QRectF bufferGeometry READ bufferGeometry)

/**
* This property holds the position of the Window's frame geometry.
Expand Down Expand Up @@ -84,8 +84,8 @@ class Window : public QObject
BI_READONLY_PROPERTY(int, height)
// Q_PROPERTY(int height READ height NOTIFY frameGeometryChanged)

BI_READONLY_PROPERTY(QRect, visibleRect)
// Q_PROPERTY(QRect visibleRect READ visibleGeometry)
BI_READONLY_PROPERTY(QRectF, visibleRect)
// Q_PROPERTY(QRectF visibleRect READ visibleGeometry)

BI_READONLY_PROPERTY(qreal, opacity)
// Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
Expand All @@ -96,8 +96,8 @@ class Window : public QObject
BI_READONLY_PROPERTY(qulonglong, windowId)
// Q_PROPERTY(qulonglong windowId READ window CONSTANT)

BI_READONLY_PROPERTY(QRect, rect)
// Q_PROPERTY(QRect rect READ rect)
BI_READONLY_PROPERTY(QRectF, rect)
// Q_PROPERTY(QRectF rect READ rect)

BI_READONLY_PROPERTY(QPoint, clientPos)
// Q_PROPERTY(QPoint clientPos READ clientPos)
Expand Down Expand Up @@ -432,8 +432,8 @@ class Window : public QObject
* The value is evaluated each time the getter is called.
* Because of that no changed signal is provided.
*/
BI_READONLY_PROPERTY(QRect, iconGeometry)
// Q_PROPERTY(QRect iconGeometry READ iconGeometry)
BI_READONLY_PROPERTY(QRectF, iconGeometry)
// Q_PROPERTY(QRectF iconGeometry READ iconGeometry)

/**
* Returns whether the window is any of special windows types (desktop, dock, splash, ...),
Expand Down Expand Up @@ -507,14 +507,14 @@ class Window : public QObject
*
* @deprecated Use frameGeometry
*/
// Q_PROPERTY(QRect geometry READ frameGeometry WRITE moveResize NOTIFY frameGeometryChanged)
// Q_PROPERTY(QRectF geometry READ frameGeometry WRITE moveResize NOTIFY frameGeometryChanged)

/**
* The geometry of this Window. Be aware that depending on resize mode the frameGeometryChanged
* signal might be emitted at each resize step or only at the end of the resize operation.
*/
BI_PROPERTY(QRect, frameGeometry, setFrameGeometry)
// Q_PROPERTY(QRect frameGeometry READ frameGeometry WRITE moveResize NOTIFY frameGeometryChanged)
BI_PROPERTY(QRectF, frameGeometry, setFrameGeometry)
// Q_PROPERTY(QRectF frameGeometry READ frameGeometry WRITE moveResize NOTIFY frameGeometryChanged)

/**
* Whether the Window is currently being moved by the user.
Expand Down
4 changes: 2 additions & 2 deletions src/core/plasma-api/workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ void Workspace::wrapSignals()
WRAP_SIGNAL_WITH_KWIN_TYPE(clientMaximizeSet(KWin::Window *, bool, bool));
};

QRect Workspace::clientArea(ClientAreaOption option, int screen, int desktop)
QRectF Workspace::clientArea(ClientAreaOption option, int screen, int desktop)
{
BI_METHOD_IMPL_WRAP(QRect, "clientArea(ClientAreaOption, int, int)", Q_ARG(ClientAreaOption, option), Q_ARG(int, screen), Q_ARG(int, desktop));
BI_METHOD_IMPL_WRAP(QRectF, "clientArea(ClientAreaOption, int, int)", Q_ARG(ClientAreaOption, option), Q_ARG(int, screen), Q_ARG(int, desktop));
};

std::vector<PlasmaApi::Window> Workspace::clientList() const
Expand Down
2 changes: 1 addition & 1 deletion src/core/plasma-api/workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Workspace : public QObject
* @param desktop The desktop for which the area should be considered, in general there should not be a difference
* @returns The specified screen geometry
*/
Q_INVOKABLE QRect clientArea(ClientAreaOption, int screen, int desktop);
Q_INVOKABLE QRectF clientArea(ClientAreaOption, int screen, int desktop);

Q_INVOKABLE std::vector<PlasmaApi::Window> clientList() const;

Expand Down
4 changes: 2 additions & 2 deletions src/kwinscript/extern/kwin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ declare namespace KWin {

/* functions */
clientList(): Client[];
clientArea(option: number, screen: number, desktop: number): QRect;
clientArea(option: number, screen: number, desktop: number): QRectF;
}

interface Options {
Expand Down Expand Up @@ -231,7 +231,7 @@ declare namespace KWin {
* This property holds the geometry of the Toplevel, excluding invisible
* portions, e.g. server-side and client-side drop-shadows, etc.
*/
frameGeometry: QRect;
frameGeometry: QRectF;

/**
* Whether the window is set to be above all
Expand Down
4 changes: 2 additions & 2 deletions src/kwinscript/extern/qt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface QByteArray {
/* keep it empty for now */
}

interface QRect {
interface QRectF {
height: number;
width: number;
x: number;
Expand Down Expand Up @@ -49,5 +49,5 @@ interface QQmlTimer {
declare namespace Qt {
function createQmlObject(qml: string, parent: object, filepath?: string): any;

function rect(x: number, y: number, width: number, height: number): QRect;
function rect(x: number, y: number, width: number, height: number): QRectF;
}
4 changes: 2 additions & 2 deletions src/kwinscript/util/rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class Rect {
public height: number
) {}

public static fromQRect(qRect: QRect): Rect {
public static fromQRect(qRect: QRectF): Rect {
return new Rect(qRect.x, qRect.y, qRect.width, qRect.height);
}

Expand Down Expand Up @@ -86,7 +86,7 @@ export class Rect {
);
}

public toQRect(): QRect {
public toQRect(): QRectF {
return Qt.rect(this.x, this.y, this.width, this.height);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/core/plasma-api/window.mock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FakeKWinClient : public QObject
Q_PROPERTY(int desktop MEMBER m_desktop)
Q_PROPERTY(int screen MEMBER m_screen)
Q_PROPERTY(QStringList activities MEMBER m_activities)
Q_PROPERTY(QRect frameGeometry MEMBER m_frameGeometry)
Q_PROPERTY(QRectF frameGeometry MEMBER m_frameGeometry)

public:
FakeKWinClient &operator=(const FakeKWinClient &);
Expand All @@ -26,5 +26,5 @@ class FakeKWinClient : public QObject
int m_desktop{};
int m_screen{};
QStringList m_activities{};
QRect m_frameGeometry{};
QRectF m_frameGeometry{};
};

0 comments on commit 8fd8a0f

Please sign in to comment.