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
This commit is contained in:
parent
8bdbe4dc15
commit
f0e1e3187e
9 changed files with 85 additions and 0 deletions
|
@ -56,6 +56,7 @@ Atoms::Atoms()
|
||||||
, kde_color_sheme(QByteArrayLiteral("_KDE_NET_WM_COLOR_SCHEME"))
|
, kde_color_sheme(QByteArrayLiteral("_KDE_NET_WM_COLOR_SCHEME"))
|
||||||
, kde_skip_close_animation(QByteArrayLiteral("_KDE_NET_WM_SKIP_CLOSE_ANIMATION"))
|
, kde_skip_close_animation(QByteArrayLiteral("_KDE_NET_WM_SKIP_CLOSE_ANIMATION"))
|
||||||
, kde_screen_edge_show(QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW"))
|
, kde_screen_edge_show(QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW"))
|
||||||
|
, gtk_frame_extents(QByteArrayLiteral("_GTK_FRAME_EXTENTS"))
|
||||||
, m_dtSmWindowInfo(QByteArrayLiteral("_DT_SM_WINDOW_INFO"))
|
, m_dtSmWindowInfo(QByteArrayLiteral("_DT_SM_WINDOW_INFO"))
|
||||||
, m_motifSupport(QByteArrayLiteral("_MOTIF_WM_INFO"))
|
, m_motifSupport(QByteArrayLiteral("_MOTIF_WM_INFO"))
|
||||||
, m_helpersRetrieved(false)
|
, m_helpersRetrieved(false)
|
||||||
|
|
1
atoms.h
1
atoms.h
|
@ -65,6 +65,7 @@ public:
|
||||||
Xcb::Atom kde_color_sheme;
|
Xcb::Atom kde_color_sheme;
|
||||||
Xcb::Atom kde_skip_close_animation;
|
Xcb::Atom kde_skip_close_animation;
|
||||||
Xcb::Atom kde_screen_edge_show;
|
Xcb::Atom kde_screen_edge_show;
|
||||||
|
Xcb::Atom gtk_frame_extents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
|
@ -232,6 +232,7 @@ Client::Client()
|
||||||
, m_decoInputExtent()
|
, m_decoInputExtent()
|
||||||
, m_focusOutTimer(nullptr)
|
, m_focusOutTimer(nullptr)
|
||||||
, m_palette(QApplication::palette())
|
, m_palette(QApplication::palette())
|
||||||
|
, m_clientSideDecorated(false)
|
||||||
{
|
{
|
||||||
// TODO: Do all as initialization
|
// TODO: Do all as initialization
|
||||||
syncRequest.counter = syncRequest.alarm = XCB_NONE;
|
syncRequest.counter = syncRequest.alarm = XCB_NONE;
|
||||||
|
@ -739,6 +740,13 @@ void Client::updateFrameExtents()
|
||||||
info->setFrameExtents(strut);
|
info->setFrameExtents(strut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::detectGtkFrameExtents()
|
||||||
|
{
|
||||||
|
Xcb::Property prop(false, m_client, atoms->gtk_frame_extents, XCB_ATOM_CARDINAL, 0, 4);
|
||||||
|
m_clientSideDecorated = !prop.isNull() && prop->type != 0;
|
||||||
|
emit clientSideDecoratedChanged();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resizes the decoration, and makes sure the decoration widget gets resize event
|
* Resizes the decoration, and makes sure the decoration widget gets resize event
|
||||||
* even if the size hasn't changed. This is needed to make sure the decoration
|
* even if the size hasn't changed. This is needed to make sure the decoration
|
||||||
|
|
14
client.h
14
client.h
|
@ -278,6 +278,11 @@ class Client
|
||||||
* Whether the decoration is currently using an alpha channel.
|
* Whether the decoration is currently using an alpha channel.
|
||||||
**/
|
**/
|
||||||
Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha)
|
Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha)
|
||||||
|
/**
|
||||||
|
* Whether the Client uses client side window decorations.
|
||||||
|
* Only GTK+ are detected.
|
||||||
|
**/
|
||||||
|
Q_PROPERTY(bool clientSideDecorated READ isClientSideDecorated NOTIFY clientSideDecoratedChanged)
|
||||||
public:
|
public:
|
||||||
explicit Client();
|
explicit Client();
|
||||||
xcb_window_t wrapperId() const;
|
xcb_window_t wrapperId() const;
|
||||||
|
@ -608,6 +613,7 @@ public:
|
||||||
QRegion decorationPendingRegion() const;
|
QRegion decorationPendingRegion() const;
|
||||||
|
|
||||||
bool decorationHasAlpha() const;
|
bool decorationHasAlpha() const;
|
||||||
|
bool isClientSideDecorated() const;
|
||||||
|
|
||||||
Position titlebarPosition() const;
|
Position titlebarPosition() const;
|
||||||
|
|
||||||
|
@ -780,6 +786,7 @@ Q_SIGNALS:
|
||||||
* Emitted whenever the Client's block compositing state changes.
|
* Emitted whenever the Client's block compositing state changes.
|
||||||
**/
|
**/
|
||||||
void blockingCompositingChanged(KWin::Client *client);
|
void blockingCompositingChanged(KWin::Client *client);
|
||||||
|
void clientSideDecoratedChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void exportMappingState(int s); // ICCCM 4.1.3.1, 4.1.4, NETWM 2.5.1
|
void exportMappingState(int s); // ICCCM 4.1.3.1, 4.1.4, NETWM 2.5.1
|
||||||
|
@ -827,6 +834,7 @@ private:
|
||||||
|
|
||||||
void embedClient(xcb_window_t w, xcb_visualid_t visualid, xcb_colormap_t colormap, uint8_t depth);
|
void embedClient(xcb_window_t w, xcb_visualid_t visualid, xcb_colormap_t colormap, uint8_t depth);
|
||||||
void detectNoBorder();
|
void detectNoBorder();
|
||||||
|
void detectGtkFrameExtents();
|
||||||
void destroyDecoration();
|
void destroyDecoration();
|
||||||
void updateFrameExtents();
|
void updateFrameExtents();
|
||||||
|
|
||||||
|
@ -1016,6 +1024,7 @@ private:
|
||||||
|
|
||||||
QPalette m_palette;
|
QPalette m_palette;
|
||||||
QList<QMetaObject::Connection> m_connections;
|
QList<QMetaObject::Connection> m_connections;
|
||||||
|
bool m_clientSideDecorated;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1049,6 +1058,11 @@ inline xcb_window_t Client::decorationId() const
|
||||||
return XCB_WINDOW_NONE;
|
return XCB_WINDOW_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool Client::isClientSideDecorated() const
|
||||||
|
{
|
||||||
|
return m_clientSideDecorated;
|
||||||
|
}
|
||||||
|
|
||||||
inline const Client* Client::transientFor() const
|
inline const Client* Client::transientFor() const
|
||||||
{
|
{
|
||||||
return transient_for;
|
return transient_for;
|
||||||
|
|
|
@ -869,6 +869,8 @@ void Client::propertyNotifyEvent(xcb_property_notify_event_t *e)
|
||||||
updateColorScheme();
|
updateColorScheme();
|
||||||
else if (e->atom == atoms->kde_screen_edge_show)
|
else if (e->atom == atoms->kde_screen_edge_show)
|
||||||
updateShowOnScreenEdge();
|
updateShowOnScreenEdge();
|
||||||
|
else if (e->atom == atoms->gtk_frame_extents)
|
||||||
|
detectGtkFrameExtents();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,6 +120,7 @@ bool Client::manage(xcb_window_t w, bool isMapped)
|
||||||
if (Xcb::Extensions::self()->isShapeAvailable())
|
if (Xcb::Extensions::self()->isShapeAvailable())
|
||||||
xcb_shape_select_input(connection(), window(), true);
|
xcb_shape_select_input(connection(), window(), true);
|
||||||
detectShape(window());
|
detectShape(window());
|
||||||
|
detectGtkFrameExtents();
|
||||||
detectNoBorder();
|
detectNoBorder();
|
||||||
fetchIconicName();
|
fetchIconicName();
|
||||||
getWMHints(); // Needs to be done before readTransient() because of reading the group
|
getWMHints(); // Needs to be done before readTransient() because of reading the group
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
install( DIRECTORY videowall DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/scripts )
|
install( DIRECTORY videowall DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/scripts )
|
||||||
install( DIRECTORY synchronizeskipswitcher DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/scripts )
|
install( DIRECTORY synchronizeskipswitcher DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/scripts )
|
||||||
install( DIRECTORY desktopchangeosd DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/scripts )
|
install( DIRECTORY desktopchangeosd DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/scripts )
|
||||||
|
install( DIRECTORY enforcedeco DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/scripts )
|
||||||
|
|
||||||
# service files
|
# service files
|
||||||
install( FILES videowall/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-videowall.desktop )
|
install( FILES videowall/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-videowall.desktop )
|
||||||
install( FILES synchronizeskipswitcher/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-synchronizeskipswitcher.desktop )
|
install( FILES synchronizeskipswitcher/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-synchronizeskipswitcher.desktop )
|
||||||
install( FILES desktopchangeosd/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-desktopchangeosd.desktop )
|
install( FILES desktopchangeosd/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-desktopchangeosd.desktop )
|
||||||
|
install( FILES enforcedeco/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-enforcedeco.desktop )
|
||||||
|
|
38
scripts/enforcedeco/contents/code/main.js
Normal file
38
scripts/enforcedeco/contents/code/main.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 Martin Gräßlin <mgraesslin@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) version 3 or any later version
|
||||||
|
* accepted by the membership of KDE e.V. (or its successor approved
|
||||||
|
* by the membership of KDE e.V.), which shall act as a proxy
|
||||||
|
* defined in Section 14 of version 3 of the license.
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
function enforceDeco(client) {
|
||||||
|
if (client.noBorder && client.clientSideDecorated) {
|
||||||
|
client.noBorder = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupConnection(client) {
|
||||||
|
enforceDeco(client);
|
||||||
|
client.clientSideDecoratedChanged.connect(client, function () {
|
||||||
|
enforceDeco(this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
workspace.clientAdded.connect(setupConnection);
|
||||||
|
// connect all existing clients
|
||||||
|
var clients = workspace.clientList();
|
||||||
|
for (var i=0; i<clients.length; i++) {
|
||||||
|
setupConnection(clients[i]);
|
||||||
|
}
|
18
scripts/enforcedeco/metadata.desktop
Normal file
18
scripts/enforcedeco/metadata.desktop
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=Enforces Window Decorations on GTK+ window
|
||||||
|
Comment=Fixes functional deficits for client side decorated windows.
|
||||||
|
Icon=preferences-system-windows-script-enforcedeco
|
||||||
|
|
||||||
|
X-Plasma-API=javascript
|
||||||
|
X-Plasma-MainScript=code/main.js
|
||||||
|
|
||||||
|
X-KDE-PluginInfo-Author=Martin Gräßlin
|
||||||
|
X-KDE-PluginInfo-Email=mgraesslin@kde.org
|
||||||
|
X-KDE-PluginInfo-Name=enforcedeco
|
||||||
|
X-KDE-PluginInfo-Version=1.0
|
||||||
|
X-KDE-PluginInfo-EnabledByDefault=true
|
||||||
|
|
||||||
|
X-KDE-PluginInfo-Depends=
|
||||||
|
X-KDE-PluginInfo-License=GPL
|
||||||
|
X-KDE-ServiceTypes=KWin/Script
|
||||||
|
Type=Service
|
Loading…
Reference in a new issue