Minor cosmetic improvements in Window

This change reorders some things in Window header so related things are
kept spatially close to make the code easier to navigate.
This commit is contained in:
Vlad Zahorodnii 2023-03-30 22:17:46 +03:00
parent fe935c0dc8
commit 050336e421
2 changed files with 197 additions and 206 deletions

View file

@ -309,18 +309,6 @@ bool Window::isUnmanaged() const
return false;
}
bool Window::isOnCurrentActivity() const
{
#if KWIN_BUILD_ACTIVITIES
if (!Workspace::self()->activities()) {
return true;
}
return isOnActivity(Workspace::self()->activities()->current());
#else
return true;
#endif
}
void Window::elevate(bool elevate)
{
if (!effectWindow()) {
@ -447,16 +435,6 @@ QMargins Window::frameMargins() const
return QMargins(borderLeft(), borderTop(), borderRight(), borderBottom());
}
bool Window::isOnDesktop(VirtualDesktop *desktop) const
{
return isOnAllDesktops() || desktops().contains(desktop);
}
bool Window::isOnCurrentDesktop() const
{
return isOnDesktop(VirtualDesktopManager::self()->currentDesktop());
}
void Window::updateMouseGrab()
{
}
@ -466,11 +444,6 @@ bool Window::belongToSameApplication(const Window *c1, const Window *c2, SameApp
return c1->belongsToSameApplication(c2, checks);
}
bool Window::isTransient() const
{
return false;
}
xcb_timestamp_t Window::userTime() const
{
return XCB_TIME_CURRENT_TIME;
@ -908,7 +881,17 @@ QStringList Window::desktopIds() const
return vd->id();
});
return ids;
};
}
bool Window::isOnDesktop(VirtualDesktop *desktop) const
{
return isOnAllDesktops() || desktops().contains(desktop);
}
bool Window::isOnCurrentDesktop() const
{
return isOnDesktop(VirtualDesktopManager::self()->currentDesktop());
}
ShadeMode Window::shadeMode() const
{
@ -2343,6 +2326,11 @@ bool Window::isModal() const
return m_modal;
}
bool Window::isTransient() const
{
return false;
}
// check whether a transient should be actually kept above its mainwindow
// there may be some special cases where this rule shouldn't be enfored
static bool shouldKeepTransientAbove(const Window *parent, const Window *transient)
@ -3130,17 +3118,6 @@ QString Window::caption() const
return cap;
}
void Window::removeRule(Rules *rule)
{
m_rules.remove(rule);
}
void Window::evaluateWindowRules()
{
setupWindowRules();
applyWindowRules();
}
/**
* Returns the list of activities the window window is on.
* if it's on all activities, the list will be empty.
@ -3151,6 +3128,18 @@ QStringList Window::activities() const
return m_activityList;
}
bool Window::isOnCurrentActivity() const
{
#if KWIN_BUILD_ACTIVITIES
if (!Workspace::self()->activities()) {
return true;
}
return isOnActivity(Workspace::self()->activities()->current());
#else
return true;
#endif
}
/**
* Sets whether the window is on @p activity.
* If you remove it from its last activity, then it's on all activities.
@ -3275,11 +3264,6 @@ void Window::blockActivityUpdates(bool b)
}
}
void Window::checkNoBorder()
{
setNoBorder(false);
}
bool Window::groupTransient() const
{
return false;
@ -3295,11 +3279,6 @@ Group *Window::group()
return nullptr;
}
bool Window::supportsWindowRules() const
{
return false;
}
QPointF Window::framePosToClientPos(const QPointF &point) const
{
return point + QPointF(borderLeft(), borderTop());
@ -3948,6 +3927,16 @@ QSizeF Window::constrainFrameSize(const QSizeF &size, SizeMode mode) const
return clientSizeToFrameSize(constrainedClientSize);
}
QRectF Window::fullscreenGeometryRestore() const
{
return m_fullscreenGeometryRestore;
}
void Window::setFullscreenGeometryRestore(const QRectF &geom)
{
m_fullscreenGeometryRestore = geom;
}
/**
* Returns @c true if the Window can be shown in full screen mode; otherwise @c false.
*
@ -4075,6 +4064,11 @@ void Window::setNoBorder(bool set)
qCWarning(KWIN_CORE, "%s doesn't support setting decorations", metaObject()->className());
}
void Window::checkNoBorder()
{
setNoBorder(false);
}
void Window::showOnScreenEdge()
{
qCWarning(KWIN_CORE, "%s doesn't support screen edge activation", metaObject()->className());
@ -4085,16 +4079,6 @@ bool Window::isPlaceable() const
return true;
}
QRectF Window::fullscreenGeometryRestore() const
{
return m_fullscreenGeometryRestore;
}
void Window::setFullscreenGeometryRestore(const QRectF &geom)
{
m_fullscreenGeometryRestore = geom;
}
void Window::cleanTabBox()
{
#if KWIN_BUILD_TABBOX
@ -4105,6 +4089,22 @@ void Window::cleanTabBox()
#endif
}
bool Window::supportsWindowRules() const
{
return false;
}
void Window::removeRule(Rules *rule)
{
m_rules.remove(rule);
}
void Window::evaluateWindowRules()
{
setupWindowRules();
applyWindowRules();
}
void Window::setupWindowRules()
{
disconnect(this, &Window::captionChanged, this, &Window::evaluateWindowRules);

View file

@ -543,6 +543,24 @@ public:
void ref();
void unref();
/**
* Returns the last requested geometry. The returned value indicates the bounding
* geometry, meaning that the client can commit smaller window geometry if the window
* is resized.
*
* The main difference between the frame geometry and the move-resize geometry is
* that the former specifies the current geometry while the latter specifies the next
* geometry.
*/
QRectF moveResizeGeometry() const;
/**
* Returns the output where the last move or resize operation has occurred. The
* window is expected to land on this output after the move/resize operation completes.
*/
Output *moveResizeOutput() const;
void setMoveResizeOutput(Output *output);
/**
* Returns the geometry of the pixmap or buffer attached to this Window.
*
@ -577,6 +595,8 @@ public:
* Default implementation returns same as geometry.
*/
virtual QRectF inputGeometry() const;
virtual QSizeF minSize() const;
virtual QSizeF maxSize() const;
QSizeF size() const;
QPointF pos() const;
QRectF rect() const;
@ -597,9 +617,6 @@ public:
* Returns a rectangle that the window occupies on the screen, including drop-shadows.
*/
QRectF visibleGeometry() const;
virtual bool isClient() const;
bool isDeleted() const;
virtual bool isUnmanaged() const;
/**
* Maps the specified @a point from the global screen coordinates to the frame coordinates.
@ -613,6 +630,69 @@ public:
QPointF mapToLocal(const QPointF &point) const;
QPointF mapFromLocal(const QPointF &point) const;
/**
* Calculates the matching client position for the given frame position @p point.
*/
virtual QPointF framePosToClientPos(const QPointF &point) const;
/**
* Calculates the matching frame position for the given client position @p point.
*/
virtual QPointF clientPosToFramePos(const QPointF &point) const;
/**
* Calculates the matching client size for the given frame size @p size.
*
* Notice that size constraints won't be applied.
*
* Default implementation returns the frame size with frame margins being excluded.
*/
virtual QSizeF frameSizeToClientSize(const QSizeF &size) const;
/**
* Calculates the matching frame size for the given client size @p size.
*
* Notice that size constraints won't be applied.
*
* Default implementation returns the client size with frame margins being included.
*/
virtual QSizeF clientSizeToFrameSize(const QSizeF &size) const;
/**
* Calculates the matching client rect for the given frame rect @p rect.
*
* Notice that size constraints won't be applied.
*/
QRectF frameRectToClientRect(const QRectF &rect) const;
/**
* Calculates the matching frame rect for the given client rect @p rect.
*
* Notice that size constraints won't be applied.
*/
QRectF clientRectToFrameRect(const QRectF &rect) const;
/**
* How to resize the window in order to obey constraints (mainly aspect ratios).
*/
enum SizeMode {
SizeModeAny,
SizeModeFixedW, ///< Try not to affect width
SizeModeFixedH, ///< Try not to affect height
SizeModeMax ///< Try not to make it larger in either direction
};
virtual QSizeF constrainClientSize(const QSizeF &size, SizeMode mode = SizeModeAny) const;
QSizeF constrainFrameSize(const QSizeF &size, SizeMode mode = SizeModeAny) const;
void move(const QPointF &point);
void resize(const QSizeF &size);
void moveResize(const QRectF &rect);
void growHorizontal();
void shrinkHorizontal();
void growVertical();
void shrinkVertical();
virtual QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &s) = 0;
void keepInArea(QRectF area, bool partial = false);
QRectF keepInArea(QRectF geometry, QRectF area, bool partial = false);
// prefer isXXX() instead
virtual NET::WindowType windowType(bool direct = false) const = 0;
bool hasNETSupport() const;
@ -638,6 +718,11 @@ public:
virtual bool isInputMethod() const;
virtual bool isOutline() const;
virtual bool isInternal() const;
virtual bool isPopupWindow() const;
virtual bool isClient() const;
bool isDeleted() const;
virtual bool isUnmanaged() const;
bool isLockScreenOverlay() const;
void setLockScreenOverlay(bool allowed);
@ -765,15 +850,6 @@ public:
template<class T, class U>
static T *findInList(const QList<T *> &list, std::function<bool(const U *)> func);
/**
* Whether the window is a popup.
*
* Popups can be used to implement popup menus, tooltips, combo boxes, etc.
*
* @since 5.15
*/
virtual bool isPopupWindow() const;
/**
* A UUID to uniquely identify this Window independent of windowing system.
*/
@ -848,8 +924,6 @@ public:
void cancelAutoRaise();
bool wantsTabFocus() const;
virtual void updateMouseGrab();
/**
* @returns The caption consisting of captionNormal and captionSuffix
@ -875,9 +949,6 @@ public:
virtual bool isHiddenInternal() const = 0;
virtual void hideClient() = 0;
virtual void showClient() = 0;
virtual bool isFullScreenable() const;
virtual bool isFullScreen() const;
virtual bool isRequestedFullScreen() const;
// TODO: remove boolean trap
virtual Window *findModal(bool allow_itself = false) = 0;
virtual bool isTransient() const;
@ -919,16 +990,25 @@ public:
return _shortcut;
}
void setShortcut(const QString &cut);
bool performMouseCommand(Options::MouseCommand, const QPointF &globalPos);
virtual QRectF iconGeometry() const;
void setMinimized(bool set);
bool isMinimized() const
{
return m_minimized;
}
virtual bool isMinimizable() const;
QRectF fullscreenGeometryRestore() const;
virtual bool isFullScreenable() const;
virtual bool isFullScreen() const;
virtual bool isRequestedFullScreen() const;
virtual bool userCanSetFullScreen() const;
virtual void setFullScreen(bool set, bool user = true);
QRectF geometryRestore() const;
virtual bool isMaximizable() const;
virtual MaximizeMode maximizeMode() const;
virtual MaximizeMode requestedMaximizeMode() const;
virtual void maximize(MaximizeMode mode);
@ -936,10 +1016,10 @@ public:
* Sets the maximization according to @p vertically and @p horizontally.
*/
Q_INVOKABLE void setMaximize(bool vertically, bool horizontally);
virtual bool noBorder() const;
virtual void setNoBorder(bool set);
QPalette palette();
const Decoration::DecorationPalette *decorationPalette();
/**
* Returns whether the window is resizable or has a fixed size.
*/
@ -952,6 +1032,7 @@ public:
* Returns whether the window can be moved to another screen.
*/
virtual bool isMovableAcrossScreens() const = 0;
/**
* Returns @c true if the window is shaded and shadeMode is @c ShadeNormal; otherwise returns @c false.
*/
@ -968,12 +1049,6 @@ public:
* Whether the Window can be shaded. Default implementation returns @c false.
*/
virtual bool isShadeable() const;
virtual bool isMaximizable() const;
virtual bool isMinimizable() const;
virtual QRectF iconGeometry() const;
virtual bool userCanSetFullScreen() const;
virtual bool userCanSetNoBorder() const;
virtual void checkNoBorder();
const WindowRules *rules() const
{
@ -981,8 +1056,13 @@ public:
}
void removeRule(Rules *r);
void setupWindowRules();
void finishWindowRules();
void evaluateWindowRules();
virtual void updateWindowRules(Rules::Types selection);
virtual void applyWindowRules();
virtual bool supportsWindowRules() const;
bool wantsTabFocus() const;
virtual bool takeFocus() = 0;
virtual bool wantsInput() const = 0;
/**
@ -999,28 +1079,18 @@ public:
virtual bool dockWantsInput() const;
void checkWorkspacePosition(QRectF oldGeometry = QRectF(), const VirtualDesktop *oldDesktop = nullptr);
virtual xcb_timestamp_t userTime() const;
virtual void updateWindowRules(Rules::Types selection);
void growHorizontal();
void shrinkHorizontal();
void growVertical();
void shrinkVertical();
void updateInteractiveMoveResize(const QPointF &currentGlobalCursor);
/**
* Ends move resize when all pointer buttons are up again.
*/
void endInteractiveMoveResize();
void keyPressEvent(uint key_code);
virtual void pointerEnterEvent(const QPointF &globalPos);
virtual void pointerLeaveEvent();
Qt::Edge titlebarPosition() const;
bool titlebarPositionUnderMouse() const;
// a helper for the workspace window packing. tests for screen validity and updates since in maximization case as with normal moving
void packTo(qreal left, qreal top);
Tile *tile() const;
void setTile(Tile *tile);
/**
* Sets the quick tile mode ("snap") of this window.
* This will also handle preserving and restoring of window geometry as necessary.
@ -1032,89 +1102,10 @@ public:
{
return QuickTileMode(m_quickTileMode);
}
Layer layer() const;
void updateLayer();
Tile *tile() const;
void move(const QPointF &point);
void resize(const QSizeF &size);
void moveResize(const QRectF &rect);
virtual QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &s) = 0;
void keepInArea(QRectF area, bool partial = false);
QRectF keepInArea(QRectF geometry, QRectF area, bool partial = false);
virtual QSizeF minSize() const;
virtual QSizeF maxSize() const;
/**
* How to resize the window in order to obey constraints (mainly aspect ratios).
*/
enum SizeMode {
SizeModeAny,
SizeModeFixedW, ///< Try not to affect width
SizeModeFixedH, ///< Try not to affect height
SizeModeMax ///< Try not to make it larger in either direction
};
virtual QSizeF constrainClientSize(const QSizeF &size, SizeMode mode = SizeModeAny) const;
QSizeF constrainFrameSize(const QSizeF &size, SizeMode mode = SizeModeAny) const;
/**
* Calculates the matching client position for the given frame position @p point.
*/
virtual QPointF framePosToClientPos(const QPointF &point) const;
/**
* Calculates the matching frame position for the given client position @p point.
*/
virtual QPointF clientPosToFramePos(const QPointF &point) const;
/**
* Calculates the matching client size for the given frame size @p size.
*
* Notice that size constraints won't be applied.
*
* Default implementation returns the frame size with frame margins being excluded.
*/
virtual QSizeF frameSizeToClientSize(const QSizeF &size) const;
/**
* Calculates the matching frame size for the given client size @p size.
*
* Notice that size constraints won't be applied.
*
* Default implementation returns the client size with frame margins being included.
*/
virtual QSizeF clientSizeToFrameSize(const QSizeF &size) const;
/**
* Calculates the matching client rect for the given frame rect @p rect.
*
* Notice that size constraints won't be applied.
*/
QRectF frameRectToClientRect(const QRectF &rect) const;
/**
* Calculates the matching frame rect for the given client rect @p rect.
*
* Notice that size constraints won't be applied.
*/
QRectF clientRectToFrameRect(const QRectF &rect) const;
/**
* Returns the last requested geometry. The returned value indicates the bounding
* geometry, meaning that the client can commit smaller window geometry if the window
* is resized.
*
* The main difference between the frame geometry and the move-resize geometry is
* that the former specifies the current geometry while the latter specifies the next
* geometry.
*/
QRectF moveResizeGeometry() const;
/**
* Returns the output where the last move or resize operation has occurred. The
* window is expected to land on this output after the move/resize operation completes.
*/
Output *moveResizeOutput() const;
void setMoveResizeOutput(Output *output);
/**
* Returns @c true if the Client is being interactively moved; otherwise @c false.
*/
@ -1136,6 +1127,13 @@ public:
{
return m_interactiveMoveResize.cursor;
}
uint32_t interactiveMoveResizeCount() const;
void updateInteractiveMoveResize(const QPointF &currentGlobalCursor);
/**
* Ends move resize when all pointer buttons are up again.
*/
void endInteractiveMoveResize();
virtual StrutRect strutRect(StrutArea area) const;
StrutRects strutRects() const;
@ -1153,8 +1151,11 @@ public:
*/
Options::MouseCommand getMouseCommand(Qt::MouseButton button, bool *handled) const;
Options::MouseCommand getWheelCommand(Qt::Orientation orientation, bool *handled) const;
bool performMouseCommand(Options::MouseCommand, const QPointF &globalPos);
// decoration related
Qt::Edge titlebarPosition() const;
bool titlebarPositionUnderMouse() const;
KDecoration2::Decoration *decoration()
{
return m_decoration.decoration.get();
@ -1178,6 +1179,11 @@ public:
virtual void invalidateDecoration();
virtual bool noBorder() const;
virtual void setNoBorder(bool set);
virtual bool userCanSetNoBorder() const;
virtual void checkNoBorder();
/**
* Returns whether the window provides context help or not. If it does,
* you should show a help menu item or a help button like '?' and call
@ -1222,6 +1228,15 @@ public:
return m_desktopFileName;
}
/**
* Helper function to compute the icon out of an application id defined by @p fileName
*
* @returns an icon name that can be used with QIcon::fromTheme()
*/
static QString iconFromDesktopFile(const QString &fileName);
static QString findDesktopFile(const QString &fileName);
/**
* Tries to terminate the process of this Window.
*
@ -1253,16 +1268,16 @@ public:
return m_applicationMenuObjectPath;
}
virtual QString preferredColorScheme() const;
QString colorScheme() const;
void setColorScheme(const QString &colorScheme);
/**
* Request showing the application menu bar
* @param actionId The DBus menu ID of the action that should be highlighted, 0 for the root menu
*/
void showApplicationMenu(int actionId);
virtual QString preferredColorScheme() const;
QString colorScheme() const;
void setColorScheme(const QString &colorScheme);
bool unresponsive() const;
/**
@ -1290,13 +1305,6 @@ public:
*/
virtual Group *group();
/**
* Returns whether window rules can be applied to this client.
*
* Default implementation returns @c false.
*/
virtual bool supportsWindowRules() const;
/**
* Return window management interface
*/
@ -1305,27 +1313,12 @@ public:
return m_windowManagementInterface;
}
QRectF fullscreenGeometryRestore() const;
/**
* Helper function to compute the icon out of an application id defined by @p fileName
*
* @returns an icon name that can be used with QIcon::fromTheme()
*/
static QString iconFromDesktopFile(const QString &fileName);
static QString findDesktopFile(const QString &fileName);
/**
* Sets the last user usage serial of the surface as @p serial
*/
void setLastUsageSerial(quint32 serial);
quint32 lastUsageSerial() const;
uint32_t interactiveMoveResizeCount() const;
void setTile(Tile *tile);
void refOffscreenRendering();
void unrefOffscreenRendering();
@ -1721,8 +1714,6 @@ protected:
*/
Window *findWindowWithSameCaption() const;
void finishWindowRules();
bool tabTo(Window *other, bool behind, bool activate);
void startShadeHoverTimer();