kwin/client.h

1248 lines
42 KiB
C
Raw Normal View History

/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
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_CLIENT_H
#define KWIN_CLIENT_H
// kwin
#include "options.h"
#include "rules.h"
#include "tabgroup.h"
#include "abstract_client.h"
#include "xcbutils.h"
#include "decorations/decorationpalette.h"
// Qt
#include <QElapsedTimer>
2014-12-02 12:50:26 +00:00
#include <QFlags>
#include <QPointer>
#include <QPixmap>
#include <QWindow>
// X
2013-07-31 08:11:39 +00:00
#include <xcb/sync.h>
// TODO: Cleanup the order of things in this .h file
class QTimer;
class KStartupInfoData;
class KStartupInfoId;
struct xcb_sync_alarm_notify_event_t;
namespace KDecoration2
{
class Decoration;
}
namespace KWin
{
namespace Decoration
{
class DecoratedClientImpl;
}
/**
* @brief Defines Predicates on how to search for a Client.
*
* Used by Workspace::findClient.
*/
enum class Predicate {
WindowMatch,
WrapperIdMatch,
FrameIdMatch,
InputIdMatch
};
class Client
: public AbstractClient
2011-01-30 14:34:42 +00:00
{
Q_OBJECT
/**
* Whether this Client is active or not. Use Workspace::activateClient() to activate a Client.
* @see Workspace::activateClient
**/
Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
/**
* The Caption of the Client. Read from WM_NAME property together with a suffix for hostname and shortcut.
* To read only the caption as provided by WM_NAME, use the getter with an additional @c false value.
**/
Q_PROPERTY(QString caption READ caption NOTIFY captionChanged)
/**
* Whether the window can be closed by the user. The value is evaluated each time the getter is called.
* Because of that no changed signal is provided.
**/
Q_PROPERTY(bool closeable READ isCloseable)
2011-12-22 14:02:35 +00:00
/**
* The desktop this Client is on. If the Client is on all desktops the property has value -1.
**/
Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged)
/**
* Whether the Client is on all desktops. That is desktop is -1.
**/
Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops WRITE setOnAllDesktops NOTIFY desktopChanged)
/**
* Whether this Client is fullScreen. A Client might either be fullScreen due to the _NET_WM property
* or through a legacy support hack. The fullScreen state can only be changed if the Client does not
* use the legacy hack. To be sure whether the state changed, connect to the notify signal.
**/
Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
/**
* Whether the Client can be set to fullScreen. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
**/
Q_PROPERTY(bool fullScreenable READ isFullScreenable)
/**
* The geometry of this Client. Be aware that depending on resize mode the geometryChanged signal
* might be emitted at each resize step or only at the end of the resize operation.
**/
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
2011-12-22 17:28:24 +00:00
/**
* Whether the Client is set to be kept above other windows.
**/
Q_PROPERTY(bool keepAbove READ keepAbove WRITE setKeepAbove NOTIFY keepAboveChanged)
/**
* Whether the Client is set to be kept below other windows.
**/
Q_PROPERTY(bool keepBelow READ keepBelow WRITE setKeepBelow NOTIFY keepBelowChanged)
/**
* Whether the Client can be maximized both horizontally and vertically.
* The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
**/
Q_PROPERTY(bool maximizable READ isMaximizable)
/**
* Whether the Client can be minimized. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
**/
Q_PROPERTY(bool minimizable READ isMinimizable)
/**
* Whether the Client is minimized.
**/
Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized NOTIFY minimizedChanged)
2011-12-22 16:54:07 +00:00
/**
* Whether the Client represents a modal window.
**/
Q_PROPERTY(bool modal READ isModal NOTIFY modalChanged)
/**
* Whether the Client is moveable. Even if it is not moveable, it might be possible to move
* it to another screen. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
* @see moveableAcrossScreens
**/
Q_PROPERTY(bool moveable READ isMovable)
/**
* Whether the Client can be moved to another screen. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
* @see moveable
**/
Q_PROPERTY(bool moveableAcrossScreens READ isMovableAcrossScreens)
2011-12-22 16:54:59 +00:00
/**
* Whether the Client provides context help. Mostly needed by decorations to decide whether to
* show the help button or not.
**/
Q_PROPERTY(bool providesContextHelp READ providesContextHelp CONSTANT)
/**
* Whether the Client can be resized. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
**/
Q_PROPERTY(bool resizeable READ isResizable)
/**
* Whether the Client can be shaded. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
**/
Q_PROPERTY(bool shadeable READ isShadeable)
/**
* Whether the Client is shaded.
**/
Q_PROPERTY(bool shade READ isShade WRITE setShade NOTIFY shadeChanged)
/**
* Whether the Client is a transient Window to another Window.
* @see transientFor
**/
Q_PROPERTY(bool transient READ isTransient NOTIFY transientChanged)
/**
* The Client to which this Client is a transient if any.
**/
Q_PROPERTY(KWin::Client *transientFor READ transientFor NOTIFY transientChanged)
/**
* By how much the window wishes to grow/shrink at least. Usually QSize(1,1).
* MAY BE DISOBEYED BY THE WM! It's only for information, do NOT rely on it at all.
* The value is evaluated each time the getter is called.
* Because of that no changed signal is provided.
*/
Q_PROPERTY(QSize basicUnit READ basicUnit)
/**
* Whether the Client is currently being moved by the user.
* Notify signal is emitted when the Client starts or ends move/resize mode.
**/
Q_PROPERTY(bool move READ isMove NOTIFY moveResizedChanged)
/**
* Whether the Client is currently being resized by the user.
* Notify signal is emitted when the Client starts or ends move/resize mode.
**/
Q_PROPERTY(bool resize READ isResize NOTIFY moveResizedChanged)
/**
* The optional geometry representing the minimized Client in e.g a taskbar.
* See _NET_WM_ICON_GEOMETRY at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
* The value is evaluated each time the getter is called.
* Because of that no changed signal is provided.
**/
Q_PROPERTY(QRect iconGeometry READ iconGeometry)
/**
* Returns whether the window is any of special windows types (desktop, dock, splash, ...),
* i.e. window types that usually don't have a window frame and the user does not use window
* management (moving, raising,...) on them.
* The value is evaluated each time the getter is called.
* Because of that no changed signal is provided.
**/
Q_PROPERTY(bool specialWindow READ isSpecialWindow)
/**
* Whether the Client can accept keyboard focus.
* The value is evaluated each time the getter is called.
* Because of that no changed signal is provided.
**/
Q_PROPERTY(bool wantsInput READ wantsInput)
Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
/**
* Indicates that the window should not be included on a taskbar.
**/
Q_PROPERTY(bool skipTaskbar READ skipTaskbar WRITE setSkipTaskbar NOTIFY skipTaskbarChanged)
/**
* Indicates that the window should not be included on a Pager.
**/
Q_PROPERTY(bool skipPager READ skipPager WRITE setSkipPager NOTIFY skipPagerChanged)
/**
* The "Window Tabs" Group this Client belongs to.
**/
Q_PROPERTY(KWin::TabGroup* tabGroup READ tabGroup NOTIFY tabGroupChanged SCRIPTABLE false)
/**
* Minimum size as specified in WM_NORMAL_HINTS
**/
Q_PROPERTY(QSize minSize READ minSize)
/**
* Maximum size as specified in WM_NORMAL_HINTS
**/
Q_PROPERTY(QSize maxSize READ maxSize)
/**
* Whether the window has a decoration or not.
* This property is not allowed to be set by applications themselves.
* The decision whether a window has a border or not belongs to the window manager.
* If this property gets abused by application developers, it will be removed again.
**/
Q_PROPERTY(bool noBorder READ noBorder WRITE setNoBorder)
/**
* Whether window state _NET_WM_STATE_DEMANDS_ATTENTION is set. This state indicates that some
* action in or with the window happened. For example, it may be set by the Window Manager if
* the window requested activation but the Window Manager refused it, or the application may set
* it if it finished some work. This state may be set by both the Client and the Window Manager.
* It should be unset by the Window Manager when it decides the window got the required attention
* (usually, that it got activated).
**/
Q_PROPERTY(bool demandsAttention READ isDemandingAttention WRITE demandAttention NOTIFY demandsAttentionChanged)
/**
* A client can block compositing. That is while the Client is alive and the state is set,
* Compositing is suspended and is resumed when there are no Clients blocking compositing any
* more.
*
* This is actually set by a window property, unfortunately not used by the target application
* group. For convenience it's exported as a property to the scripts.
*
* Use with care!
**/
Q_PROPERTY(bool blocksCompositing READ isBlockingCompositing WRITE setBlockingCompositing NOTIFY blockingCompositingChanged)
/**
* Whether the decoration is currently using an alpha channel.
**/
Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha)
Add a script to enforce window decorations for GTK windows This is going to be a controversal change. It enforces KWin decorations on all client side decorated windows from GTK+. Unfortunately we are caught between a rock and a hard place. Keeping the status quo means having broken windows and a more or less broken window manager due to GTK+ including the shadow in the windows. This is no solution. Enforcing server side decorations visually breaks the windows. This is also no solution. So why do it? It's our task to provide the best possible user experience and KWin is a window manager which has always done great efforts to fix misbehaving windows. One can think of the focus stealing prevention, the window rules and lately the scripts. The best possible window management experience is our aim. This means we cannot leave the users with the broken windows from GTK. The issues we noticed were reported to GTK+ about 2 months ago and we are working on improving the situation. Unfortunately several issues are not yet addressed and others will only be addressed in the next GTK+ release. We are working on improving the NETWM spec (see [1]) to ensure that the client side decorated windows are not in a broken state. This means the enforcment is a temporary solution and will be re-evaluated with the next GTK release. I would prefer to not have to do such a change, if some of the bugs were fixed or GTK+ would not use client-side-decos on wms not yet supporting those all of this would be a no issue. For a complete list of the problems caused by GTK's decos see bug [2] and the linked bug reports from there. The change is done in a least inversive way in KWin. We just check for the property _GTK_FRAME_EXTENTS and create a Q_PROPERTY in Client for it. If we add support for the frame extents in future we would also need this. So it's not a change just for enforcing the decoration. The actual enforcing is done through a KWin script so users can still disable it. REVIEW: 119062 [1] https://mail.gnome.org/archives/wm-spec-list/2014-June/msg00002.html [2] https://bugzilla.gnome.org/show_bug.cgi?id=729721
2014-07-01 13:44:02 +00:00
/**
* Whether the Client uses client side window decorations.
* Only GTK+ are detected.
**/
Q_PROPERTY(bool clientSideDecorated READ isClientSideDecorated NOTIFY clientSideDecoratedChanged)
2011-01-30 14:34:42 +00:00
public:
explicit Client();
xcb_window_t wrapperId() const;
xcb_window_t inputId() const { return m_decoInputExtent; }
virtual xcb_window_t frameId() const override;
2011-01-30 14:34:42 +00:00
const Client* transientFor() const;
Client* transientFor();
bool isTransient() const override;
2011-01-30 14:34:42 +00:00
bool groupTransient() const;
bool wasOriginallyGroupTransient() const;
ClientList mainClients() const; // Call once before loop , is not indirect
ClientList allMainClients() const; // Call once before loop , is indirect
bool hasTransient(const Client* c, bool indirect) const;
const ClientList& transients() const; // Is not indirect
void checkTransient(xcb_window_t w);
AbstractClient* findModal(bool allow_itself = false) override;
2011-01-30 14:34:42 +00:00
const Group* group() const;
Group* group();
void checkGroup(Group* gr = NULL, bool force = false);
void changeClientLeaderGroup(Group* gr);
const WindowRules* rules() const override;
2011-01-30 14:34:42 +00:00
void removeRule(Rules* r);
void setupWindowRules(bool ignore_temporary);
void applyWindowRules();
void updateWindowRules(Rules::Types selection) override;
2011-01-30 14:34:42 +00:00
void updateFullscreenMonitors(NETFullscreenMonitors topology);
/**
* Returns true for "special" windows and false for windows which are "normal"
* (normal=window which has a border, can be moved by the user, can be closed, etc.)
* true for Desktop, Dock, Splash, Override and TopMenu (and Toolbar??? - for now)
* false for Normal, Dialog, Utility and Menu (and Toolbar??? - not yet) TODO
*/
bool isSpecialWindow() const override;
2011-01-30 14:34:42 +00:00
bool hasNETSupport() const;
QSize minSize() const;
QSize maxSize() const;
QSize basicUnit() const;
2011-01-30 14:34:42 +00:00
virtual QPoint clientPos() const; // Inside of geometry()
virtual QSize clientSize() const;
QPoint inputPos() const { return input_offset; } // Inside of geometry()
2011-01-30 14:34:42 +00:00
bool windowEvent(xcb_generic_event_t *e);
void syncEvent(xcb_sync_alarm_notify_event_t* e);
NET::WindowType windowType(bool direct = false, int supported_types = 0) const;
bool manage(xcb_window_t w, bool isMapped);
2011-01-30 14:34:42 +00:00
void releaseWindow(bool on_shutdown = false);
void destroyClient();
/// How to resize the window in order to obey constains (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
};
QSize adjustedSize(const QSize&, Sizemode mode = SizemodeAny) const;
QSize adjustedSize() const;
const QIcon &icon() const override;
2011-01-30 14:34:42 +00:00
bool isActive() const override;
void setActive(bool) override;
2011-01-30 14:34:42 +00:00
virtual int desktop() const;
void setDesktop(int) override;
void setOnAllDesktops(bool set) override;
2011-01-30 14:34:42 +00:00
void sendToScreen(int screen) override;
2011-01-30 14:34:42 +00:00
virtual QStringList activities() const;
void setOnActivity(const QString &activity, bool enable);
void setOnAllActivities(bool set) override;
2011-01-30 14:34:42 +00:00
void setOnActivities(QStringList newActivitiesList);
void updateActivities(bool includeTransients);
void blockActivityUpdates(bool b = true) override;
2011-01-30 14:34:42 +00:00
/// Is not minimized and not hidden. I.e. normally visible on some virtual desktop.
bool isShown(bool shaded_is_shown) const override;
2011-01-30 14:34:42 +00:00
bool isHiddenInternal() const; // For compositing
bool isShade() const override; // True only for ShadeNormal
ShadeMode shadeMode() const override; // Prefer isShade()
void setShade(bool set) override;
void setShade(ShadeMode mode) override;
bool isShadeable() const override;
2011-01-30 14:34:42 +00:00
bool isMinimized() const override;
bool isMaximizable() const override;
2011-01-30 14:34:42 +00:00
QRect geometryRestore() const;
MaximizeMode maximizeMode() const override;
QuickTileMode quickTileMode() const;
bool isMinimizable() const override;
2011-01-30 14:34:42 +00:00
void setMaximize(bool vertically, bool horizontally);
QRect iconGeometry() const;
void setFullScreen(bool set, bool user = true) override;
bool isFullScreen() const override;
2011-01-30 14:34:42 +00:00
bool isFullScreenable(bool fullscreen_hack = false) const;
bool isActiveFullScreen() const;
bool userCanSetFullScreen() const override;
2011-01-30 14:34:42 +00:00
QRect geometryFSRestore() const {
return geom_fs_restore; // Only for session saving
}
int fullScreenMode() const {
return fullscreen_mode; // only for session saving
}
bool noBorder() const override;
void setNoBorder(bool set) override;
bool userCanSetNoBorder() const override;
2011-01-30 14:34:42 +00:00
void checkNoBorder();
bool skipTaskbar(bool from_outside = false) const;
void setSkipTaskbar(bool set, bool from_outside = false);
2011-01-30 14:34:42 +00:00
bool skipPager() const;
void setSkipPager(bool);
bool keepAbove() const override;
void setKeepAbove(bool) override;
bool keepBelow() const override;
void setKeepBelow(bool) override;
virtual Layer layer() const;
2011-01-30 14:34:42 +00:00
Layer belongsToLayer() const;
void invalidateLayer();
void updateLayer();
2011-01-30 14:34:42 +00:00
int sessionStackingOrder() const;
void setModal(bool modal);
bool isModal() const;
// Auxiliary functions, depend on the windowType
bool wantsTabFocus() const override;
bool wantsInput() const override;
2011-01-30 14:34:42 +00:00
bool isResizable() const override;
bool isMovable() const override;
bool isMovableAcrossScreens() const override;
bool isCloseable() const override; ///< May be closed by the user (May have a close button)
2011-01-30 14:34:42 +00:00
void takeFocus() override;
bool isDemandingAttention() const {
return demands_attention;
}
void demandAttention(bool set = true) override;
2011-01-30 14:34:42 +00:00
void updateDecoration(bool check_workspace_pos, bool force = false);
void triggerDecorationRepaint();
void updateShape();
enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet };
void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet);
void setGeometry(const QRect& r, ForceGeometry_t force = NormalGeometrySet);
2011-01-30 14:34:42 +00:00
void move(int x, int y, ForceGeometry_t force = NormalGeometrySet);
void move(const QPoint& p, ForceGeometry_t force = NormalGeometrySet);
/// plainResize() simply resizes
void plainResize(int w, int h, ForceGeometry_t force = NormalGeometrySet);
void plainResize(const QSize& s, ForceGeometry_t force = NormalGeometrySet);
2011-01-30 14:34:42 +00:00
/// resizeWithChecks() resizes according to gravity, and checks workarea position
void resizeWithChecks(int w, int h, xcb_gravity_t gravity = XCB_GRAVITY_BIT_FORGET, ForceGeometry_t force = NormalGeometrySet);
void resizeWithChecks(const QSize& s, xcb_gravity_t gravity = XCB_GRAVITY_BIT_FORGET, ForceGeometry_t force = NormalGeometrySet);
2011-01-30 14:34:42 +00:00
void keepInArea(QRect area, bool partial = false);
2011-03-07 21:31:44 +00:00
void setElectricBorderMode(QuickTileMode mode);
QuickTileMode electricBorderMode() const;
2011-01-30 14:34:42 +00:00
void setElectricBorderMaximizing(bool maximizing);
bool isElectricBorderMaximizing() const;
2011-03-07 21:31:44 +00:00
QRect electricBorderMaximizeGeometry(QPoint pos, int desktop);
2011-01-30 14:34:42 +00:00
QSize sizeForClientSize(const QSize&, Sizemode mode = SizemodeAny, bool noframe = false) const;
/** Set the quick tile mode ("snap") of this window.
* This will also handle preserving and restoring of window geometry as necessary.
* @param mode The tile mode (left/right) to give this window.
*/
void setQuickTileMode(QuickTileMode mode, bool keyboard = false) override;
2011-01-30 14:34:42 +00:00
void growHorizontal() override;
void shrinkHorizontal() override;
void growVertical() override;
void shrinkVertical() override;
2011-01-30 14:34:42 +00:00
bool providesContextHelp() const;
const QKeySequence &shortcut() const override;
void setShortcut(const QString& cut) override;
2011-01-30 14:34:42 +00:00
Options::WindowOperation mouseButtonToWindowOperation(Qt::MouseButtons button);
bool performMouseCommand(Options::MouseCommand, const QPoint& globalPos) override;
2011-01-30 14:34:42 +00:00
QRect adjustedClientArea(const QRect& desktop, const QRect& area) const;
xcb_colormap_t colormap() const;
2011-01-30 14:34:42 +00:00
/// Updates visibility depending on being shaded, virtual desktop, etc.
void updateVisibility();
/// Hides a client - Basically like minimize, but without effects, it's simply hidden
void hideClient(bool hide);
bool hiddenPreview() const; ///< Window is mapped in order to get a window pixmap
virtual bool setupCompositing();
void finishCompositing(ReleaseReason releaseReason = ReleaseReason::Release) override;
void setBlockingCompositing(bool block);
inline bool isBlockingCompositing() { return blocks_compositing; }
2011-01-30 14:34:42 +00:00
QString caption(bool full = true, bool stripped = false) const override;
2011-01-30 14:34:42 +00:00
void keyPressEvent(uint key_code, xcb_timestamp_t time = XCB_TIME_CURRENT_TIME); // FRAME ??
void updateMouseGrab() override;
xcb_window_t moveResizeGrabWindow() const;
2011-01-30 14:34:42 +00:00
const QPoint calculateGravitation(bool invert, int gravity = 0) const; // FRAME public?
void NETMoveResize(int x_root, int y_root, NET::Direction direction);
void NETMoveResizeWindow(int flags, int x, int y, int width, int height);
void restackWindow(xcb_window_t above, int detail, NET::RequestSource source, xcb_timestamp_t timestamp,
2011-01-30 14:34:42 +00:00
bool send_event = false);
void gotPing(xcb_timestamp_t timestamp);
2011-01-30 14:34:42 +00:00
void checkWorkspacePosition(QRect oldGeometry = QRect(), int oldDesktop = -2) override;
void updateUserTime(xcb_timestamp_t time = XCB_TIME_CURRENT_TIME);
xcb_timestamp_t userTime() const override;
2011-01-30 14:34:42 +00:00
bool hasUserTimeSupport() const;
/// Does 'delete c;'
static void deleteClient(Client* c);
2011-01-30 14:34:42 +00:00
static bool belongToSameApplication(const Client* c1, const Client* c2, bool active_hack = false);
static bool sameAppWindowRoleMatch(const Client* c1, const Client* c2, bool active_hack);
void setMinimized(bool set);
void minimize(bool avoid_animation = false) override;
void unminimize(bool avoid_animation = false) override;
2011-01-30 14:34:42 +00:00
void killWindow();
void maximize(MaximizeMode) override;
2011-01-30 14:34:42 +00:00
void toggleShade();
void showContextHelp();
void cancelShadeHoverTimer();
void cancelAutoRaise() override;
2011-01-30 14:34:42 +00:00
void checkActiveModal();
StrutRect strutRect(StrutArea area) const;
StrutRects strutRects() const;
bool hasStrut() const;
// Tabbing functions
TabGroup* tabGroup() const override; // Returns a pointer to client_group
Q_INVOKABLE inline bool tabBefore(Client *other, bool activate) { return tabTo(other, false, activate); }
Q_INVOKABLE inline bool tabBehind(Client *other, bool activate) { return tabTo(other, true, activate); }
/**
* Syncs the *dynamic* @param property @param fromThisClient or the @link currentTab() to
* all members of the @link tabGroup() (if there is one)
*
* eg. if you call:
* client->setProperty("kwin_tiling_floats", true);
* client->syncTabGroupFor("kwin_tiling_floats", true)
* all clients in this tabGroup will have ::property("kwin_tiling_floats").toBool() == true
*
* WARNING: non dynamic properties are ignored - you're not supposed to alter/update such explicitly
*/
Q_INVOKABLE void syncTabGroupFor(QString property, bool fromThisClient = false);
Q_INVOKABLE bool untab(const QRect &toGeometry = QRect(), bool clientRemoved = false) override;
/**
* Set tab group - this is to be invoked by TabGroup::add/remove(client) and NO ONE ELSE
*/
void setTabGroup(TabGroup* group);
2011-01-30 14:34:42 +00:00
/*
* If shown is true the client is mapped and raised, if false
* the client is unmapped and hidden, this function is called
* when the tabbing group of the client switches its visible
* client.
*/
void setClientShown(bool shown);
/*
* When a click is done in the decoration and it calls the group
* to change the visible client it starts to move-resize the new
* client, this function stops it.
*/
void dontMoveResize();
bool isCurrentTab() const override;
2011-01-30 14:34:42 +00:00
/**
* Whether or not the window has a strut that expands through the invisible area of
* an xinerama setup where the monitors are not the same resolution.
*/
bool hasOffscreenXineramaStrut() const;
bool isMove() const {
return moveResizeMode && mode == PositionCenter;
}
bool isResize() const {
return moveResizeMode && mode != PositionCenter;
}
// Decorations <-> Effects
KDecoration2::Decoration *decoration() {
return m_decoration;
2011-01-30 14:34:42 +00:00
}
const KDecoration2::Decoration *decoration() const {
return m_decoration;
2011-01-30 14:34:42 +00:00
}
QPointer<Decoration::DecoratedClientImpl> decoratedClient() const;
bool isDecorated() const {
return m_decoration != nullptr;
2011-01-30 14:34:42 +00:00
}
void setDecoratedClient(QPointer<Decoration::DecoratedClientImpl> client);
2011-01-30 14:34:42 +00:00
QRect decorationRect() const;
2011-01-30 14:34:42 +00:00
QRect transparentRect() const;
bool decorationHasAlpha() const;
Add a script to enforce window decorations for GTK windows This is going to be a controversal change. It enforces KWin decorations on all client side decorated windows from GTK+. Unfortunately we are caught between a rock and a hard place. Keeping the status quo means having broken windows and a more or less broken window manager due to GTK+ including the shadow in the windows. This is no solution. Enforcing server side decorations visually breaks the windows. This is also no solution. So why do it? It's our task to provide the best possible user experience and KWin is a window manager which has always done great efforts to fix misbehaving windows. One can think of the focus stealing prevention, the window rules and lately the scripts. The best possible window management experience is our aim. This means we cannot leave the users with the broken windows from GTK. The issues we noticed were reported to GTK+ about 2 months ago and we are working on improving the situation. Unfortunately several issues are not yet addressed and others will only be addressed in the next GTK+ release. We are working on improving the NETWM spec (see [1]) to ensure that the client side decorated windows are not in a broken state. This means the enforcment is a temporary solution and will be re-evaluated with the next GTK release. I would prefer to not have to do such a change, if some of the bugs were fixed or GTK+ would not use client-side-decos on wms not yet supporting those all of this would be a no issue. For a complete list of the problems caused by GTK's decos see bug [2] and the linked bug reports from there. The change is done in a least inversive way in KWin. We just check for the property _GTK_FRAME_EXTENTS and create a Q_PROPERTY in Client for it. If we add support for the frame extents in future we would also need this. So it's not a change just for enforcing the decoration. The actual enforcing is done through a KWin script so users can still disable it. REVIEW: 119062 [1] https://mail.gnome.org/archives/wm-spec-list/2014-June/msg00002.html [2] https://bugzilla.gnome.org/show_bug.cgi?id=729721
2014-07-01 13:44:02 +00:00
bool isClientSideDecorated() const;
bool wantsShadowToBeRendered() const override;
Position titlebarPosition() const override;
void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const;
2011-01-30 14:34:42 +00:00
Xcb::Property fetchFirstInTabBox() const;
void readFirstInTabBox(Xcb::Property &property);
void updateFirstInTabBox();
Xcb::StringProperty fetchColorScheme() const;
void readColorScheme(Xcb::StringProperty &property);
void updateColorScheme();
2011-01-30 14:34:42 +00:00
//sets whether the client should be treated as a SessionInteract window
void setSessionInteract(bool needed);
virtual bool isClient() const;
// a helper for the workspace window packing. tests for screen validity and updates since in maximization case as with normal moving
void packTo(int left, int top) override;
2011-01-30 14:34:42 +00:00
template <typename T>
void print(T &stream) const;
void cancelFocusOutTimer();
QPalette palette() const override;
const Decoration::DecorationPalette *decorationPalette() const;
Screenedge show support for Clients This provides a new protocol intended to be used by auto-hiding panels to make use of the centralized screen edges. To use it a Client can set an X11 property of type _KDE_NET_WM_SCREEN_EDGE_SHOW to KWin. As value it takes: * 0: top edge * 1: right edge * 2: bottom edge * 3: left edge KWin will hide the Client (hide because unmap or minimize would break it) and create an Edge. If that Edge gets triggered the Client is shown again and the property gets deleted. If the Client doesn't border the specified screen edge the Client gets shown immediately so that we never end in a situation that we cannot unhide the auto-hidden panel again. The exact process is described in the documentation of ScreenEdges. The Client can request to be shown again by deleting the property. If KWin gets restarted the state is read from the property and it is tried to create the edge as described. As this is a KWin specific extension we need to discuss what it means for Clients using this feature with other WMs: it does nothing. As the Client gets hidden by KWin and not by the Client, it just doesn't get hidden if the WM doesn't provide the feature. In case of an auto-hiding panel this seems like a good solution given that we don't want to hide it if we cannot unhide it. Of course there's the option for the Client to provide that feature itself and if that's wanted we would need to announce the feature in the _NET_SUPPORTED atom. At the moment that doesn't sound like being needed as Plasma doesn't want to provide an own implementation. The implementation comes with a small test application showing how the feature is intended to be used. REVIEW: 115910
2014-02-20 11:39:23 +00:00
/**
* Restores the Client after it had been hidden due to show on screen edge functionality.
* In addition the property gets deleted so that the Client knows that it is visible again.
**/
void showOnScreenEdge();
public Q_SLOTS:
void closeWindow() override;
Improved resolving whether a window is on local machine Most windows use the hostname in WM_CLIENT_MACHINE, but there are windows using the FQDN (for example libreoffice). So instead of "foo" it is "foo.local.net" or similar. The logic so far has been unable to properly determine whether windows with FQDN are on the local system. In order to solve this problem the handling is split out into an own class which stores the information of hostname and whether it is a local machine. This is to not query multiple times. To determine whether the Client is on the local system getaddrinfo is used for the own hostname and the FQDN provided in WM_CLIENT_MACHINE. If one of the queried names matches, we know that it is on the local machine. The old logic to compare the hostname is still used and getaddrinfo is only a fallback in case hostname does not match. The problem with getaddrinfo is, that it accesses the network and by that could block. To circumvent this problem the calls are moved into threads by using QtConcurrent::run. Obviously this brings disadvantages. When trying to resolve whether a Client is on the local machine and a FQDN is used, the information is initially wrong. The new ClientMachine class emits a signal when the information that the system is local becomes available, but for some things this is just too late: * window rules are already gathered * Session Management has already taken place In both cases this is an acceptable loss. For window rules it just needs a proper matching of the machine in case of localhost (remote hosts are not affected). And the case of session management is very academic as it is unlikely that a restoring session contains remote windows. BUG: 308391 FIXED-IN: 4.11 REVIEW: 108235
2013-01-07 07:07:27 +00:00
void updateCaption();
private Q_SLOTS:
2011-01-30 14:34:42 +00:00
void autoRaise();
void shadeHover();
void shadeUnhover();
private:
// Use Workspace::createClient()
virtual ~Client(); ///< Use destroyClient() or releaseWindow()
Position mousePosition(const QPoint&) const;
void updateCursor();
// Handlers for X11 events
bool mapRequestEvent(xcb_map_request_event_t *e);
void unmapNotifyEvent(xcb_unmap_notify_event_t *e);
void destroyNotifyEvent(xcb_destroy_notify_event_t *e);
void configureRequestEvent(xcb_configure_request_event_t *e);
virtual void propertyNotifyEvent(xcb_property_notify_event_t *e) override;
void clientMessageEvent(xcb_client_message_event_t *e) override;
void enterNotifyEvent(xcb_enter_notify_event_t *e);
void leaveNotifyEvent(xcb_leave_notify_event_t *e);
void focusInEvent(xcb_focus_in_event_t *e);
void focusOutEvent(xcb_focus_out_event_t *e);
virtual void damageNotifyEvent();
bool buttonPressEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root, xcb_timestamp_t time = XCB_CURRENT_TIME);
bool buttonReleaseEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root);
bool motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x_root, int y_root);
2011-01-30 14:34:42 +00:00
void checkQuickTilingMaximizationZones(int xroot, int yroot);
bool processDecorationButtonPress(int button, int state, int x, int y, int x_root, int y_root,
bool ignoreMenu = false);
Client* findAutogroupCandidate() const;
void resetShowingDesktop();
2011-01-30 14:34:42 +00:00
protected:
virtual void debug(QDebug& stream) const;
virtual bool shouldUnredirect() const;
void addDamage(const QRegion &damage) override;
bool belongsToSameApplication(const AbstractClient *other, bool active_hack) const override;
2011-01-30 14:34:42 +00:00
private Q_SLOTS:
void delayedSetShortcut();
void performMoveResize();
2011-01-30 14:34:42 +00:00
//Signals for the scripting interface
//Signals make an excellent way for communication
//in between objects as compared to simple function
//calls
Q_SIGNALS:
2011-01-30 14:34:42 +00:00
void clientManaging(KWin::Client*);
void clientFullScreenSet(KWin::Client*, bool, bool);
void clientMaximizedStateChanged(KWin::Client*, MaximizeMode);
void clientMaximizedStateChanged(KWin::Client* c, bool h, bool v);
2011-03-06 09:55:27 +00:00
void clientMinimized(KWin::Client* client, bool animate);
2011-03-06 10:08:19 +00:00
void clientUnminimized(KWin::Client* client, bool animate);
void clientStartUserMovedResized(KWin::Client*);
void clientStepUserMovedResized(KWin::Client *, const QRect&);
void clientFinishUserMovedResized(KWin::Client*);
void activeChanged();
void captionChanged();
2011-12-22 14:02:35 +00:00
void desktopChanged();
void desktopPresenceChanged(KWin::Client*, int); // to be forwarded by Workspace
void fullScreenChanged();
void transientChanged();
2011-12-22 16:54:07 +00:00
void modalChanged();
void shadeChanged();
void keepAboveChanged(bool);
void keepBelowChanged(bool);
void minimizedChanged();
void moveResizedChanged();
void iconChanged();
void skipTaskbarChanged();
void skipPagerChanged();
void paletteChanged(const QPalette &p);
/**
* Emitted whenever the Client's TabGroup changed. That is whenever the Client is moved to
* another group, but not when a Client gets added or removed to the Client's ClientGroup.
**/
void tabGroupChanged();
/**
* Emitted whenever the Client want to show it menu
*/
void showRequest();
/**
* Emitted whenever the Client's menu is closed
*/
void menuHidden();
/**
* Emitted whenever the Client's menu is available
**/
void appMenuAvailable();
/**
* Emitted whenever the Client's menu is unavailable
*/
void appMenuUnavailable();
/**
* Emitted whenever the demands attention state changes.
**/
void demandsAttentionChanged();
/**
* Emitted whenever the Client's block compositing state changes.
**/
void blockingCompositingChanged(KWin::Client *client);
Add a script to enforce window decorations for GTK windows This is going to be a controversal change. It enforces KWin decorations on all client side decorated windows from GTK+. Unfortunately we are caught between a rock and a hard place. Keeping the status quo means having broken windows and a more or less broken window manager due to GTK+ including the shadow in the windows. This is no solution. Enforcing server side decorations visually breaks the windows. This is also no solution. So why do it? It's our task to provide the best possible user experience and KWin is a window manager which has always done great efforts to fix misbehaving windows. One can think of the focus stealing prevention, the window rules and lately the scripts. The best possible window management experience is our aim. This means we cannot leave the users with the broken windows from GTK. The issues we noticed were reported to GTK+ about 2 months ago and we are working on improving the situation. Unfortunately several issues are not yet addressed and others will only be addressed in the next GTK+ release. We are working on improving the NETWM spec (see [1]) to ensure that the client side decorated windows are not in a broken state. This means the enforcment is a temporary solution and will be re-evaluated with the next GTK release. I would prefer to not have to do such a change, if some of the bugs were fixed or GTK+ would not use client-side-decos on wms not yet supporting those all of this would be a no issue. For a complete list of the problems caused by GTK's decos see bug [2] and the linked bug reports from there. The change is done in a least inversive way in KWin. We just check for the property _GTK_FRAME_EXTENTS and create a Q_PROPERTY in Client for it. If we add support for the frame extents in future we would also need this. So it's not a change just for enforcing the decoration. The actual enforcing is done through a KWin script so users can still disable it. REVIEW: 119062 [1] https://mail.gnome.org/archives/wm-spec-list/2014-June/msg00002.html [2] https://bugzilla.gnome.org/show_bug.cgi?id=729721
2014-07-01 13:44:02 +00:00
void clientSideDecoratedChanged();
void quickTileModeChanged();
2011-01-30 14:34:42 +00:00
void closeableChanged(bool);
void minimizeableChanged(bool);
void shadeableChanged(bool);
void maximizeableChanged(bool);
2011-01-30 14:34:42 +00:00
private:
int borderLeft() const;
int borderRight() const;
int borderTop() const;
int borderBottom() const;
2011-01-30 14:34:42 +00:00
void exportMappingState(int s); // ICCCM 4.1.3.1, 4.1.4, NETWM 2.5.1
bool isManaged() const; ///< Returns false if this client is not yet managed
void updateAllowedActions(bool force = false);
QRect fullscreenMonitorsArea(NETFullscreenMonitors topology) const;
void changeMaximize(bool horizontal, bool vertical, bool adjust);
int checkFullScreenHack(const QRect& geom) const; // 0 - None, 1 - One xinerama screen, 2 - Full area
void updateFullScreenHack(const QRect& geom);
void getWmNormalHints();
void getMotifHints();
void getIcons();
void fetchName();
void fetchIconicName();
QString readName() const;
void setCaption(const QString& s, bool force = false);
bool hasTransientInternal(const Client* c, bool indirect, ConstClientList& set) const;
void finishWindowRules();
void setShortcutInternal(const QKeySequence &cut = QKeySequence());
2011-01-30 14:34:42 +00:00
void configureRequest(int value_mask, int rx, int ry, int rw, int rh, int gravity, bool from_tool);
NETExtendedStrut strut() const;
int checkShadeGeometry(int w, int h);
void blockGeometryUpdates(bool block);
void getSyncCounter();
void sendSyncRequest();
bool startMoveResize();
void finishMoveResize(bool cancel);
void leaveMoveResize();
void checkUnrestrictedMoveResize();
void handleMoveResize(int x, int y, int x_root, int y_root);
void startDelayedMoveResize();
void stopDelayedMoveResize();
void positionGeometryTip();
void grabButton(int mod);
void ungrabButton(int mod);
void resizeDecoration();
void createDecoration(const QRect &oldgeom);
2011-01-30 14:34:42 +00:00
void pingWindow();
void killProcess(bool ask, xcb_timestamp_t timestamp = XCB_TIME_CURRENT_TIME);
2011-01-30 14:34:42 +00:00
void updateUrgency();
2013-05-03 08:55:37 +00:00
static void sendClientMessage(xcb_window_t w, xcb_atom_t a, xcb_atom_t protocol,
uint32_t data1 = 0, uint32_t data2 = 0, uint32_t data3 = 0);
2011-01-30 14:34:42 +00:00
void embedClient(xcb_window_t w, xcb_visualid_t visualid, xcb_colormap_t colormap, uint8_t depth);
2011-01-30 14:34:42 +00:00
void detectNoBorder();
Xcb::Property fetchGtkFrameExtents() const;
void readGtkFrameExtents(Xcb::Property &prop);
Add a script to enforce window decorations for GTK windows This is going to be a controversal change. It enforces KWin decorations on all client side decorated windows from GTK+. Unfortunately we are caught between a rock and a hard place. Keeping the status quo means having broken windows and a more or less broken window manager due to GTK+ including the shadow in the windows. This is no solution. Enforcing server side decorations visually breaks the windows. This is also no solution. So why do it? It's our task to provide the best possible user experience and KWin is a window manager which has always done great efforts to fix misbehaving windows. One can think of the focus stealing prevention, the window rules and lately the scripts. The best possible window management experience is our aim. This means we cannot leave the users with the broken windows from GTK. The issues we noticed were reported to GTK+ about 2 months ago and we are working on improving the situation. Unfortunately several issues are not yet addressed and others will only be addressed in the next GTK+ release. We are working on improving the NETWM spec (see [1]) to ensure that the client side decorated windows are not in a broken state. This means the enforcment is a temporary solution and will be re-evaluated with the next GTK release. I would prefer to not have to do such a change, if some of the bugs were fixed or GTK+ would not use client-side-decos on wms not yet supporting those all of this would be a no issue. For a complete list of the problems caused by GTK's decos see bug [2] and the linked bug reports from there. The change is done in a least inversive way in KWin. We just check for the property _GTK_FRAME_EXTENTS and create a Q_PROPERTY in Client for it. If we add support for the frame extents in future we would also need this. So it's not a change just for enforcing the decoration. The actual enforcing is done through a KWin script so users can still disable it. REVIEW: 119062 [1] https://mail.gnome.org/archives/wm-spec-list/2014-June/msg00002.html [2] https://bugzilla.gnome.org/show_bug.cgi?id=729721
2014-07-01 13:44:02 +00:00
void detectGtkFrameExtents();
2011-01-30 14:34:42 +00:00
void destroyDecoration();
void updateFrameExtents();
void internalShow();
void internalHide();
void internalKeep();
void map();
void unmap();
2011-01-30 14:34:42 +00:00
void updateHiddenPreview();
void updateInputShape();
xcb_timestamp_t readUserTimeMapTimestamp(const KStartupInfoId* asn_id, const KStartupInfoData* asn_data,
2011-01-30 14:34:42 +00:00
bool session) const;
xcb_timestamp_t readUserCreationTime() const;
2011-01-30 14:34:42 +00:00
void startupIdChanged();
void checkOffscreenPosition (QRect* geom, const QRect& screenArea);
void updateInputWindow();
bool tabTo(Client *other, bool behind, bool activate);
Xcb::Property fetchShowOnScreenEdge() const;
void readShowOnScreenEdge(Xcb::Property &property);
Screenedge show support for Clients This provides a new protocol intended to be used by auto-hiding panels to make use of the centralized screen edges. To use it a Client can set an X11 property of type _KDE_NET_WM_SCREEN_EDGE_SHOW to KWin. As value it takes: * 0: top edge * 1: right edge * 2: bottom edge * 3: left edge KWin will hide the Client (hide because unmap or minimize would break it) and create an Edge. If that Edge gets triggered the Client is shown again and the property gets deleted. If the Client doesn't border the specified screen edge the Client gets shown immediately so that we never end in a situation that we cannot unhide the auto-hidden panel again. The exact process is described in the documentation of ScreenEdges. The Client can request to be shown again by deleting the property. If KWin gets restarted the state is read from the property and it is tried to create the edge as described. As this is a KWin specific extension we need to discuss what it means for Clients using this feature with other WMs: it does nothing. As the Client gets hidden by KWin and not by the Client, it just doesn't get hidden if the WM doesn't provide the feature. In case of an auto-hiding panel this seems like a good solution given that we don't want to hide it if we cannot unhide it. Of course there's the option for the Client to provide that feature itself and if that's wanted we would need to announce the feature in the _NET_SUPPORTED atom. At the moment that doesn't sound like being needed as Plasma doesn't want to provide an own implementation. The implementation comes with a small test application showing how the feature is intended to be used. REVIEW: 115910
2014-02-20 11:39:23 +00:00
/**
* Reads the property and creates/destroys the screen edge if required
* and shows/hides the client.
**/
void updateShowOnScreenEdge();
void handlePaletteChange();
Xcb::Window m_client;
Xcb::Window m_wrapper;
Xcb::Window m_frame;
// wrapper around m_frame to use as a parent for the decoration
QScopedPointer<QWindow> m_frameWrapper;
KDecoration2::Decoration *m_decoration;
QPointer<Decoration::DecoratedClientImpl> m_decoratedClient;
QElapsedTimer m_decorationDoubleClickTimer;
2011-01-30 14:34:42 +00:00
int desk;
QStringList activityList;
int m_activityUpdatesBlocked;
bool m_blockedActivityUpdatesRequireTransients;
2011-01-30 14:34:42 +00:00
bool buttonDown;
bool moveResizeMode;
Xcb::Window m_moveResizeGrabWindow;
2011-01-30 14:34:42 +00:00
bool move_resize_has_keyboard_grab;
bool unrestrictedMoveResize;
int moveResizeStartScreen;
static bool s_haveResizeEffect;
bool m_managed;
2011-01-30 14:34:42 +00:00
Position mode;
QPoint moveOffset;
QPoint invertedMoveOffset;
QRect moveResizeGeom;
QRect initialMoveResizeGeom;
Xcb::GeometryHints m_geometryHints;
2011-01-30 14:34:42 +00:00
void sendSyntheticConfigureNotify();
enum MappingState {
Withdrawn, ///< Not handled, as per ICCCM WithdrawnState
Mapped, ///< The frame is mapped
Unmapped, ///< The frame is not mapped
Kept ///< The frame should be unmapped, but is kept (For compositing)
};
MappingState mapping_state;
/** The quick tile mode of this window.
*/
2011-03-07 21:31:44 +00:00
int quick_tile_mode;
2011-01-30 14:34:42 +00:00
Xcb::TransientFor fetchTransient() const;
void readTransientProperty(Xcb::TransientFor &transientFor);
2011-01-30 14:34:42 +00:00
void readTransient();
xcb_window_t verifyTransientFor(xcb_window_t transient_for, bool set);
2011-01-30 14:34:42 +00:00
void addTransient(Client* cl);
void removeTransient(Client* cl);
void removeFromMainClients();
void cleanGrouping();
void checkGroupTransients();
void setTransient(xcb_window_t new_transient_for_id);
2011-01-30 14:34:42 +00:00
Client* transient_for;
xcb_window_t m_transientForId;
xcb_window_t m_originalTransientForId;
2011-01-30 14:34:42 +00:00
ClientList transients_list; // SELI TODO: Make this ordered in stacking order?
ShadeMode shade_mode;
Client *shade_below;
2011-01-30 14:34:42 +00:00
uint active : 1;
uint deleting : 1; ///< True when doing cleanup and destroying the client
uint keep_above : 1; ///< NET::KeepAbove (was stays_on_top)
uint skip_taskbar : 1;
uint original_skip_taskbar : 1; ///< Unaffected by KWin
uint skip_pager : 1;
Xcb::MotifHints m_motif;
2011-01-30 14:34:42 +00:00
uint keep_below : 1; ///< NET::KeepBelow
uint minimized : 1;
uint hidden : 1; ///< Forcibly hidden by calling hide()
uint modal : 1; ///< NET::Modal
uint noborder : 1;
uint app_noborder : 1; ///< App requested no border via window type, shape extension, etc.
uint ignore_focus_stealing : 1; ///< Don't apply focus stealing prevention to this client
uint demands_attention : 1;
bool blocks_compositing;
2011-01-30 14:34:42 +00:00
WindowRules client_rules;
QIcon m_icon;
Qt::CursorShape m_cursor;
2011-01-30 14:34:42 +00:00
// DON'T reorder - Saved to config files !!!
enum FullScreenMode {
FullScreenNone,
FullScreenNormal,
FullScreenHack ///< Non-NETWM fullscreen (noborder and size of desktop)
};
FullScreenMode fullscreen_mode;
MaximizeMode max_mode;
QRect geom_restore;
QRect geom_fs_restore;
QTimer* autoRaiseTimer;
QTimer* shadeHoverTimer;
QTimer* delayedMoveResizeTimer;
xcb_colormap_t m_colormap;
QString cap_normal, cap_iconic, cap_suffix, cap_deco;
2011-01-30 14:34:42 +00:00
Group* in_group;
TabGroup* tab_group;
2011-01-30 14:34:42 +00:00
Layer in_layer;
QTimer* ping_timer;
qint64 m_killHelperPID;
xcb_timestamp_t m_pingTimestamp;
xcb_timestamp_t m_userTime;
NET::Actions allowed_actions;
2011-01-30 14:34:42 +00:00
QSize client_size;
int block_geometry_updates; // > 0 = New geometry is remembered, but not actually set
enum PendingGeometry_t {
PendingGeometryNone,
PendingGeometryNormal,
PendingGeometryForced
};
PendingGeometry_t pending_geometry_update;
QRect geom_before_block;
QRect deco_rect_before_block;
bool shade_geometry_change;
struct {
2013-07-31 08:11:39 +00:00
xcb_sync_counter_t counter;
xcb_sync_int64_t value;
xcb_sync_alarm_t alarm;
xcb_timestamp_t lastTimestamp;
QTimer *timeout, *failsafeTimeout;
bool isPending;
} syncRequest;
2011-01-30 14:34:42 +00:00
static bool check_active_modal; ///< \see Client::checkActiveModal()
QKeySequence _shortcut;
2011-01-30 14:34:42 +00:00
int sm_stacking_order;
friend struct ResetupRulesProcedure;
friend class GeometryUpdatesBlocker;
bool electricMaximizing;
2011-03-07 21:31:44 +00:00
QuickTileMode electricMode;
2011-01-30 14:34:42 +00:00
friend bool performTransiencyCheck();
Xcb::StringProperty fetchActivities() const;
void readActivities(Xcb::StringProperty &property);
2011-01-30 14:34:42 +00:00
void checkActivities();
bool activitiesDefined; //whether the x property was actually set
bool needsSessionInteract;
bool needsXWindowMove;
Xcb::Window m_decoInputExtent;
QPoint input_offset;
QTimer *m_focusOutTimer;
QString m_colorScheme;
std::shared_ptr<Decoration::DecorationPalette> m_palette;
static QHash<QString, std::weak_ptr<Decoration::DecorationPalette>> s_palettes;
static std::shared_ptr<Decoration::DecorationPalette> s_defaultPalette;
QList<QMetaObject::Connection> m_connections;
Add a script to enforce window decorations for GTK windows This is going to be a controversal change. It enforces KWin decorations on all client side decorated windows from GTK+. Unfortunately we are caught between a rock and a hard place. Keeping the status quo means having broken windows and a more or less broken window manager due to GTK+ including the shadow in the windows. This is no solution. Enforcing server side decorations visually breaks the windows. This is also no solution. So why do it? It's our task to provide the best possible user experience and KWin is a window manager which has always done great efforts to fix misbehaving windows. One can think of the focus stealing prevention, the window rules and lately the scripts. The best possible window management experience is our aim. This means we cannot leave the users with the broken windows from GTK. The issues we noticed were reported to GTK+ about 2 months ago and we are working on improving the situation. Unfortunately several issues are not yet addressed and others will only be addressed in the next GTK+ release. We are working on improving the NETWM spec (see [1]) to ensure that the client side decorated windows are not in a broken state. This means the enforcment is a temporary solution and will be re-evaluated with the next GTK release. I would prefer to not have to do such a change, if some of the bugs were fixed or GTK+ would not use client-side-decos on wms not yet supporting those all of this would be a no issue. For a complete list of the problems caused by GTK's decos see bug [2] and the linked bug reports from there. The change is done in a least inversive way in KWin. We just check for the property _GTK_FRAME_EXTENTS and create a Q_PROPERTY in Client for it. If we add support for the frame extents in future we would also need this. So it's not a change just for enforcing the decoration. The actual enforcing is done through a KWin script so users can still disable it. REVIEW: 119062 [1] https://mail.gnome.org/archives/wm-spec-list/2014-June/msg00002.html [2] https://bugzilla.gnome.org/show_bug.cgi?id=729721
2014-07-01 13:44:02 +00:00
bool m_clientSideDecorated;
2011-01-30 14:34:42 +00:00
};
/**
* Helper for Client::blockGeometryUpdates() being called in pairs (true/false)
*/
class GeometryUpdatesBlocker
2011-01-30 14:34:42 +00:00
{
public:
explicit GeometryUpdatesBlocker(Client* c)
2011-01-30 14:34:42 +00:00
: cl(c) {
cl->blockGeometryUpdates(true);
}
~GeometryUpdatesBlocker() {
cl->blockGeometryUpdates(false);
}
private:
Client* cl;
};
inline xcb_window_t Client::wrapperId() const
2011-01-30 14:34:42 +00:00
{
return m_wrapper;
2011-01-30 14:34:42 +00:00
}
Add a script to enforce window decorations for GTK windows This is going to be a controversal change. It enforces KWin decorations on all client side decorated windows from GTK+. Unfortunately we are caught between a rock and a hard place. Keeping the status quo means having broken windows and a more or less broken window manager due to GTK+ including the shadow in the windows. This is no solution. Enforcing server side decorations visually breaks the windows. This is also no solution. So why do it? It's our task to provide the best possible user experience and KWin is a window manager which has always done great efforts to fix misbehaving windows. One can think of the focus stealing prevention, the window rules and lately the scripts. The best possible window management experience is our aim. This means we cannot leave the users with the broken windows from GTK. The issues we noticed were reported to GTK+ about 2 months ago and we are working on improving the situation. Unfortunately several issues are not yet addressed and others will only be addressed in the next GTK+ release. We are working on improving the NETWM spec (see [1]) to ensure that the client side decorated windows are not in a broken state. This means the enforcment is a temporary solution and will be re-evaluated with the next GTK release. I would prefer to not have to do such a change, if some of the bugs were fixed or GTK+ would not use client-side-decos on wms not yet supporting those all of this would be a no issue. For a complete list of the problems caused by GTK's decos see bug [2] and the linked bug reports from there. The change is done in a least inversive way in KWin. We just check for the property _GTK_FRAME_EXTENTS and create a Q_PROPERTY in Client for it. If we add support for the frame extents in future we would also need this. So it's not a change just for enforcing the decoration. The actual enforcing is done through a KWin script so users can still disable it. REVIEW: 119062 [1] https://mail.gnome.org/archives/wm-spec-list/2014-June/msg00002.html [2] https://bugzilla.gnome.org/show_bug.cgi?id=729721
2014-07-01 13:44:02 +00:00
inline bool Client::isClientSideDecorated() const
{
return m_clientSideDecorated;
}
inline const Client* Client::transientFor() const
2011-01-30 14:34:42 +00:00
{
return transient_for;
2011-01-30 14:34:42 +00:00
}
inline Client* Client::transientFor()
2011-01-30 14:34:42 +00:00
{
return transient_for;
2011-01-30 14:34:42 +00:00
}
inline bool Client::groupTransient() const
2011-01-30 14:34:42 +00:00
{
return m_transientForId == rootWindow();
2011-01-30 14:34:42 +00:00
}
// Needed because verifyTransientFor() may set transient_for_id to root window,
// if the original value has a problem (window doesn't exist, etc.)
inline bool Client::wasOriginallyGroupTransient() const
2011-01-30 14:34:42 +00:00
{
return m_originalTransientForId == rootWindow();
2011-01-30 14:34:42 +00:00
}
inline bool Client::isTransient() const
2011-01-30 14:34:42 +00:00
{
return m_transientForId != XCB_WINDOW_NONE;
2011-01-30 14:34:42 +00:00
}
inline const ClientList& Client::transients() const
2011-01-30 14:34:42 +00:00
{
return transients_list;
2011-01-30 14:34:42 +00:00
}
inline const Group* Client::group() const
2011-01-30 14:34:42 +00:00
{
return in_group;
2011-01-30 14:34:42 +00:00
}
inline Group* Client::group()
2011-01-30 14:34:42 +00:00
{
return in_group;
2011-01-30 14:34:42 +00:00
}
inline TabGroup* Client::tabGroup() const
2011-01-30 14:34:42 +00:00
{
return tab_group;
2011-01-30 14:34:42 +00:00
}
inline bool Client::isMinimized() const
2011-01-30 14:34:42 +00:00
{
return minimized;
2011-01-30 14:34:42 +00:00
}
inline bool Client::isActive() const
2011-01-30 14:34:42 +00:00
{
return active;
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
inline bool Client::isShown(bool shaded_is_shown) const
{
return !isMinimized() && (!isShade() || shaded_is_shown) && !hidden &&
(!tabGroup() || tabGroup()->current() == this);
2011-01-30 14:34:42 +00:00
}
inline bool Client::isHiddenInternal() const
2011-01-30 14:34:42 +00:00
{
return hidden;
2011-01-30 14:34:42 +00:00
}
inline bool Client::isShade() const
2011-01-30 14:34:42 +00:00
{
return shade_mode == ShadeNormal;
2011-01-30 14:34:42 +00:00
}
inline ShadeMode Client::shadeMode() const
2011-01-30 14:34:42 +00:00
{
return shade_mode;
2011-01-30 14:34:42 +00:00
}
inline const QIcon &Client::icon() const
2011-01-30 14:34:42 +00:00
{
return m_icon;
2011-01-30 14:34:42 +00:00
}
inline QRect Client::geometryRestore() const
2011-01-30 14:34:42 +00:00
{
return geom_restore;
2011-01-30 14:34:42 +00:00
}
inline MaximizeMode Client::maximizeMode() const
2011-01-30 14:34:42 +00:00
{
return max_mode;
2011-01-30 14:34:42 +00:00
}
inline Client::QuickTileMode Client::quickTileMode() const
{
return (Client::QuickTileMode)quick_tile_mode;
}
2011-01-30 14:34:42 +00:00
inline bool Client::skipTaskbar(bool from_outside) const
{
return from_outside ? original_skip_taskbar : skip_taskbar;
2011-01-30 14:34:42 +00:00
}
inline bool Client::skipPager() const
2011-01-30 14:34:42 +00:00
{
return skip_pager;
2011-01-30 14:34:42 +00:00
}
inline bool Client::keepAbove() const
2011-01-30 14:34:42 +00:00
{
return keep_above;
2011-01-30 14:34:42 +00:00
}
inline bool Client::keepBelow() const
2011-01-30 14:34:42 +00:00
{
return keep_below;
2011-01-30 14:34:42 +00:00
}
inline bool Client::isFullScreen() const
2011-01-30 14:34:42 +00:00
{
return fullscreen_mode != FullScreenNone;
2011-01-30 14:34:42 +00:00
}
inline bool Client::isModal() const
2011-01-30 14:34:42 +00:00
{
return modal;
2011-01-30 14:34:42 +00:00
}
inline bool Client::hasNETSupport() const
2011-01-30 14:34:42 +00:00
{
return info->hasNETSupport();
2011-01-30 14:34:42 +00:00
}
inline xcb_colormap_t Client::colormap() const
2011-01-30 14:34:42 +00:00
{
return m_colormap;
2011-01-30 14:34:42 +00:00
}
inline void Client::invalidateLayer()
2011-01-30 14:34:42 +00:00
{
in_layer = UnknownLayer;
2011-01-30 14:34:42 +00:00
}
inline int Client::sessionStackingOrder() const
2011-01-30 14:34:42 +00:00
{
return sm_stacking_order;
2011-01-30 14:34:42 +00:00
}
inline bool Client::isManaged() const
2011-01-30 14:34:42 +00:00
{
return m_managed;
2011-01-30 14:34:42 +00:00
}
inline QPoint Client::clientPos() const
2011-01-30 14:34:42 +00:00
{
return QPoint(borderLeft(), borderTop());
2011-01-30 14:34:42 +00:00
}
inline QSize Client::clientSize() const
2011-01-30 14:34:42 +00:00
{
return client_size;
2011-01-30 14:34:42 +00:00
}
inline void Client::setGeometry(const QRect& r, ForceGeometry_t force)
2011-01-30 14:34:42 +00:00
{
setGeometry(r.x(), r.y(), r.width(), r.height(), force);
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
inline void Client::move(const QPoint& p, ForceGeometry_t force)
{
move(p.x(), p.y(), force);
}
inline void Client::plainResize(const QSize& s, ForceGeometry_t force)
2011-01-30 14:34:42 +00:00
{
plainResize(s.width(), s.height(), force);
2011-01-30 14:34:42 +00:00
}
inline void Client::resizeWithChecks(const QSize& s, xcb_gravity_t gravity, ForceGeometry_t force)
2011-01-30 14:34:42 +00:00
{
resizeWithChecks(s.width(), s.height(), gravity, force);
2011-01-30 14:34:42 +00:00
}
inline bool Client::hasUserTimeSupport() const
2011-01-30 14:34:42 +00:00
{
return info->userTime() != -1U;
2011-01-30 14:34:42 +00:00
}
inline const WindowRules* Client::rules() const
2011-01-30 14:34:42 +00:00
{
return &client_rules;
2011-01-30 14:34:42 +00:00
}
inline xcb_window_t Client::moveResizeGrabWindow() const
2011-01-30 14:34:42 +00:00
{
return m_moveResizeGrabWindow;
2011-01-30 14:34:42 +00:00
}
inline const QKeySequence &Client::shortcut() const
2011-01-30 14:34:42 +00:00
{
return _shortcut;
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
inline void Client::removeRule(Rules* rule)
{
client_rules.remove(rule);
}
inline bool Client::hiddenPreview() const
2011-01-30 14:34:42 +00:00
{
return mapping_state == Kept;
2011-01-30 14:34:42 +00:00
}
inline QPalette Client::palette() const
{
return m_palette->palette();
}
inline const Decoration::DecorationPalette *Client::decorationPalette() const
{
return m_palette.get();
}
template <typename T>
inline void Client::print(T &stream) const
{
stream << "\'ID:" << window() << ";WMCLASS:" << resourceClass() << ":"
<< resourceName() << ";Caption:" << caption() << "\'";
}
} // namespace
Q_DECLARE_METATYPE(KWin::Client*)
Q_DECLARE_METATYPE(QList<KWin::Client*>)
#endif