2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
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>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
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/>.
|
|
|
|
*********************************************************************/
|
2013-04-26 10:15:49 +00:00
|
|
|
// own
|
2019-09-24 08:48:08 +00:00
|
|
|
#include "x11client.h"
|
2013-04-26 10:15:49 +00:00
|
|
|
// kwin
|
2013-04-04 14:14:12 +00:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
|
|
|
#include "activities.h"
|
|
|
|
#endif
|
2013-04-26 10:15:49 +00:00
|
|
|
#include "atoms.h"
|
2013-01-07 07:07:27 +00:00
|
|
|
#include "client_machine.h"
|
2011-08-21 19:50:23 +00:00
|
|
|
#include "composite.h"
|
2013-02-19 16:30:59 +00:00
|
|
|
#include "cursor.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "deleted.h"
|
2013-04-26 10:15:49 +00:00
|
|
|
#include "focuschain.h"
|
|
|
|
#include "group.h"
|
|
|
|
#include "shadow.h"
|
2019-04-30 08:46:53 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
|
|
|
#include "tabbox.h"
|
|
|
|
#endif
|
2013-04-26 10:15:49 +00:00
|
|
|
#include "workspace.h"
|
2014-02-20 11:39:23 +00:00
|
|
|
#include "screenedge.h"
|
2014-07-22 11:11:19 +00:00
|
|
|
#include "decorations/decorationbridge.h"
|
|
|
|
#include "decorations/decoratedclient.h"
|
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
#include <KDecoration2/DecoratedClient>
|
2013-04-26 10:15:49 +00:00
|
|
|
// KDE
|
2017-04-05 09:16:23 +00:00
|
|
|
#include <KLocalizedString>
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KWindowSystem>
|
|
|
|
#include <KColorScheme>
|
2013-04-26 10:15:49 +00:00
|
|
|
// Qt
|
|
|
|
#include <QApplication>
|
2013-09-02 11:14:39 +00:00
|
|
|
#include <QDebug>
|
2018-11-08 21:02:32 +00:00
|
|
|
#include <QDir>
|
2014-12-02 12:50:26 +00:00
|
|
|
#include <QFile>
|
2018-11-08 21:02:32 +00:00
|
|
|
#include <QFileInfo>
|
2015-06-03 16:09:54 +00:00
|
|
|
#include <QMouseEvent>
|
2013-04-26 10:15:49 +00:00
|
|
|
#include <QProcess>
|
2019-09-06 14:30:26 +00:00
|
|
|
// xcb
|
2017-08-01 19:28:36 +00:00
|
|
|
#include <xcb/xcb_icccm.h>
|
2013-04-26 10:15:49 +00:00
|
|
|
// system
|
|
|
|
#include <unistd.h>
|
2019-07-09 19:19:26 +00:00
|
|
|
// c++
|
|
|
|
#include <csignal>
|
2009-04-22 17:29:56 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// Put all externs before the namespace statement to allow the linker
|
2007-04-29 17:35:43 +00:00
|
|
|
// to resolve them properly
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2014-03-19 13:56:34 +00:00
|
|
|
const long ClientWinMask = XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
|
|
|
|
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
|
|
|
|
XCB_EVENT_MASK_KEYMAP_STATE |
|
|
|
|
XCB_EVENT_MASK_BUTTON_MOTION |
|
|
|
|
XCB_EVENT_MASK_POINTER_MOTION | // need this, too!
|
|
|
|
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
|
|
|
|
XCB_EVENT_MASK_FOCUS_CHANGE |
|
|
|
|
XCB_EVENT_MASK_EXPOSURE |
|
|
|
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
|
|
|
|
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
|
|
|
|
|
2019-09-19 19:12:44 +00:00
|
|
|
// window types that are supported as normal windows (i.e. KWin actually manages them)
|
|
|
|
const NET::WindowTypes SUPPORTED_MANAGED_WINDOW_TYPES_MASK = NET::NormalMask | NET::DesktopMask | NET::DockMask
|
|
|
|
| NET::ToolbarMask | NET::MenuMask | NET::DialogMask /*| NET::OverrideMask*/ | NET::TopMenuMask
|
|
|
|
| NET::UtilityMask | NET::SplashMask | NET::NotificationMask | NET::OnScreenDisplayMask
|
|
|
|
| NET::CriticalNotificationMask;
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// Creating a client:
|
|
|
|
// - only by calling Workspace::createClient()
|
|
|
|
// - it creates a new client and calls manage() for it
|
|
|
|
//
|
|
|
|
// Destroying a client:
|
|
|
|
// - destroyClient() - only when the window itself has been destroyed
|
|
|
|
// - releaseWindow() - the window is kept, only the client itself is destroyed
|
|
|
|
|
|
|
|
/**
|
2019-09-24 08:48:08 +00:00
|
|
|
* \class Client x11client.h
|
2008-12-18 13:50:57 +00:00
|
|
|
* \brief The Client class encapsulates a window decoration frame.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* This ctor is "dumb" - it only initializes data. All the real initialization
|
|
|
|
* is done in manage().
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client::X11Client()
|
2015-03-05 09:21:03 +00:00
|
|
|
: AbstractClient()
|
2013-09-10 05:27:39 +00:00
|
|
|
, m_client()
|
2013-05-02 16:26:05 +00:00
|
|
|
, m_wrapper()
|
2013-09-10 06:13:33 +00:00
|
|
|
, m_frame()
|
2013-03-24 20:57:26 +00:00
|
|
|
, m_activityUpdatesBlocked(false)
|
|
|
|
, m_blockedActivityUpdatesRequireTransients(false)
|
2013-05-02 17:04:43 +00:00
|
|
|
, m_moveResizeGrabWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
, move_resize_has_keyboard_grab(false)
|
2012-06-19 21:12:37 +00:00
|
|
|
, m_managed(false)
|
2013-05-03 06:53:35 +00:00
|
|
|
, m_transientForId(XCB_WINDOW_NONE)
|
|
|
|
, m_originalTransientForId(XCB_WINDOW_NONE)
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
, shade_below(nullptr)
|
2015-02-02 13:56:21 +00:00
|
|
|
, m_motif(atoms->motif_wm_hints)
|
2011-03-20 14:42:05 +00:00
|
|
|
, blocks_compositing(false)
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
, shadeHoverTimer(nullptr)
|
2013-05-03 09:46:18 +00:00
|
|
|
, m_colormap(XCB_COLORMAP_NONE)
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
, in_group(nullptr)
|
|
|
|
, ping_timer(nullptr)
|
2012-04-16 21:52:13 +00:00
|
|
|
, m_killHelperPID(0)
|
2013-05-03 09:35:46 +00:00
|
|
|
, m_pingTimestamp(XCB_TIME_CURRENT_TIME)
|
2013-05-03 09:29:50 +00:00
|
|
|
, m_userTime(XCB_TIME_CURRENT_TIME) // Not known yet
|
2019-09-19 15:16:14 +00:00
|
|
|
, allowed_actions()
|
2011-01-30 14:34:42 +00:00
|
|
|
, shade_geometry_change(false)
|
|
|
|
, sm_stacking_order(-1)
|
|
|
|
, activitiesDefined(false)
|
2017-04-27 10:18:41 +00:00
|
|
|
, sessionActivityOverride(false)
|
2012-11-07 23:54:05 +00:00
|
|
|
, needsXWindowMove(false)
|
2013-02-04 10:20:15 +00:00
|
|
|
, m_decoInputExtent()
|
2013-08-05 07:48:14 +00:00
|
|
|
, m_focusOutTimer(nullptr)
|
2014-07-01 13:44:02 +00:00
|
|
|
, m_clientSideDecorated(false)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
// TODO: Do all as initialization
|
2013-07-31 08:11:39 +00:00
|
|
|
syncRequest.counter = syncRequest.alarm = XCB_NONE;
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
syncRequest.timeout = syncRequest.failsafeTimeout = nullptr;
|
2014-04-24 09:00:48 +00:00
|
|
|
syncRequest.lastTimestamp = xTime();
|
2011-08-13 14:39:58 +00:00
|
|
|
syncRequest.isPending = false;
|
2008-12-18 13:50:57 +00:00
|
|
|
|
|
|
|
// Set the initial mapping state
|
2008-08-12 11:02:58 +00:00
|
|
|
mapping_state = Withdrawn;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
info = nullptr;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
shade_mode = ShadeNone;
|
|
|
|
deleting = false;
|
2019-01-10 12:16:01 +00:00
|
|
|
m_fullscreenMode = FullScreenNone;
|
2007-04-29 17:35:43 +00:00
|
|
|
hidden = false;
|
|
|
|
noborder = false;
|
2008-03-23 00:12:11 +00:00
|
|
|
app_noborder = false;
|
2007-04-29 17:35:43 +00:00
|
|
|
ignore_focus_stealing = false;
|
|
|
|
check_active_modal = false;
|
|
|
|
|
|
|
|
max_mode = MaximizeRestore;
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2010-09-21 14:31:40 +00:00
|
|
|
//Client to workspace connections require that each
|
|
|
|
//client constructed be connected to the workspace wrapper
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
geom = QRect(0, 0, 100, 100); // So that decorations don't start with size being (0,0)
|
|
|
|
client_size = QSize(100, 100);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
connect(clientMachine(), &ClientMachine::localhostChanged, this, &X11Client::updateCaption);
|
|
|
|
connect(options, &Options::condensedTitleChanged, this, &X11Client::updateCaption);
|
2013-01-07 07:07:27 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
connect(this, &X11Client::moveResizeCursorChanged, this, [this] (CursorShape cursor) {
|
2015-10-16 13:27:53 +00:00
|
|
|
xcb_cursor_t nativeCursor = Cursor::x11Cursor(cursor);
|
|
|
|
m_frame.defineCursor(nativeCursor);
|
|
|
|
if (m_decoInputExtent.isValid())
|
|
|
|
m_decoInputExtent.defineCursor(nativeCursor);
|
|
|
|
if (isMoveResize()) {
|
|
|
|
// changing window attributes doesn't change cursor if there's pointer grab active
|
|
|
|
xcb_change_active_pointer_grab(connection(), nativeCursor, xTime(),
|
|
|
|
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// SELI TODO: Initialize xsizehints??
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* "Dumb" destructor.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client::~X11Client()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-08-14 19:22:30 +00:00
|
|
|
if (m_killHelperPID && !::kill(m_killHelperPID, 0)) { // means the process is alive
|
|
|
|
::kill(m_killHelperPID, SIGTERM);
|
|
|
|
m_killHelperPID = 0;
|
|
|
|
}
|
2013-07-31 08:11:39 +00:00
|
|
|
if (syncRequest.alarm != XCB_NONE)
|
|
|
|
xcb_sync_destroy_alarm(connection(), syncRequest.alarm);
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(!isMoveResize());
|
|
|
|
Q_ASSERT(m_client == XCB_WINDOW_NONE);
|
|
|
|
Q_ASSERT(m_wrapper == XCB_WINDOW_NONE);
|
2019-08-31 19:12:44 +00:00
|
|
|
Q_ASSERT(m_frame == XCB_WINDOW_NONE);
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(!check_active_modal);
|
2014-02-26 10:26:00 +00:00
|
|
|
for (auto it = m_connections.constBegin(); it != m_connections.constEnd(); ++it) {
|
|
|
|
disconnect(*it);
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// Use destroyClient() or releaseWindow(), Client instances cannot be deleted directly
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::deleteClient(X11Client *c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete c;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Releases the window. The client has done its job and the window is still existing.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::releaseWindow(bool on_shutdown)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(!deleting);
|
2007-04-29 17:35:43 +00:00
|
|
|
deleting = true;
|
2019-04-30 08:46:53 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
|
|
|
TabBox::TabBox *tabBox = TabBox::TabBox::self();
|
2019-09-24 15:10:06 +00:00
|
|
|
if (tabBox->isDisplayed() && tabBox->currentClient() == this) {
|
2019-04-30 08:46:53 +00:00
|
|
|
tabBox->nextPrev(true);
|
|
|
|
}
|
|
|
|
#endif
|
2015-07-09 07:10:33 +00:00
|
|
|
destroyWindowManagementInterface();
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
Deleted* del = nullptr;
|
2012-04-22 07:27:53 +00:00
|
|
|
if (!on_shutdown) {
|
|
|
|
del = Deleted::create(this);
|
|
|
|
}
|
2015-10-16 07:08:02 +00:00
|
|
|
if (isMoveResize())
|
2011-07-16 12:23:54 +00:00
|
|
|
emit clientFinishUserMovedResized(this);
|
2011-06-21 11:52:25 +00:00
|
|
|
emit windowClosed(this, del);
|
2007-04-29 17:35:43 +00:00
|
|
|
finishCompositing();
|
2013-04-26 12:40:35 +00:00
|
|
|
RuleBook::self()->discardUsed(this, true); // Remove ForceTemporarily rules
|
2011-01-30 14:34:42 +00:00
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
2015-10-16 07:08:02 +00:00
|
|
|
if (isMoveResize())
|
2011-01-30 14:34:42 +00:00
|
|
|
leaveMoveResize();
|
2007-04-29 17:35:43 +00:00
|
|
|
finishWindowRules();
|
2015-10-13 11:15:39 +00:00
|
|
|
blockGeometryUpdates();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isOnCurrentDesktop() && isShown(true))
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
2008-12-18 13:50:57 +00:00
|
|
|
// Grab X during the release to make removing of properties, setting to withdrawn state
|
2019-03-25 18:11:15 +00:00
|
|
|
// and repareting to root an atomic operation (https://lists.kde.org/?l=kde-devel&m=116448102901184&w=2)
|
2007-04-30 09:41:48 +00:00
|
|
|
grabXServer();
|
2019-09-06 14:30:26 +00:00
|
|
|
exportMappingState(XCB_ICCCM_WM_STATE_WITHDRAWN);
|
2011-01-30 14:34:42 +00:00
|
|
|
setModal(false); // Otherwise its mainwindow wouldn't get focus
|
2008-12-18 13:50:57 +00:00
|
|
|
hidden = true; // So that it's not considered visible anymore (can't use hideClient(), it would set flags)
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!on_shutdown)
|
|
|
|
workspace()->clientHidden(this);
|
2013-09-10 06:37:49 +00:00
|
|
|
m_frame.unmap(); // Destroying decoration would cause ugly visual effect
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyDecoration();
|
|
|
|
cleanGrouping();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!on_shutdown) {
|
2013-04-26 07:47:45 +00:00
|
|
|
workspace()->removeClient(this);
|
2008-12-18 13:50:57 +00:00
|
|
|
// Only when the window is being unmapped, not when closing down KWin (NETWM sections 5.5,5.7)
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setDesktop(0);
|
2019-09-14 21:17:53 +00:00
|
|
|
info->setState(NET::States(), info->state()); // Reset all state flags
|
2019-09-14 08:58:12 +00:00
|
|
|
}
|
2013-05-02 16:43:49 +00:00
|
|
|
xcb_connection_t *c = connection();
|
2013-09-10 07:28:22 +00:00
|
|
|
m_client.deleteProperty(atoms->kde_net_wm_user_creation_time);
|
|
|
|
m_client.deleteProperty(atoms->net_frame_extents);
|
|
|
|
m_client.deleteProperty(atoms->kde_net_wm_frame_strut);
|
2013-09-10 07:20:12 +00:00
|
|
|
m_client.reparent(rootWindow(), x(), y());
|
2013-05-02 16:43:49 +00:00
|
|
|
xcb_change_save_set(c, XCB_SET_MODE_DELETE, m_client);
|
2013-09-10 05:38:21 +00:00
|
|
|
m_client.selectInput(XCB_EVENT_MASK_NO_EVENT);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (on_shutdown)
|
2008-12-18 13:50:57 +00:00
|
|
|
// Map the window, so it can be found after another WM is started
|
2013-09-10 05:38:21 +00:00
|
|
|
m_client.map();
|
2011-01-30 14:34:42 +00:00
|
|
|
// TODO: Preserve minimized, shaded etc. state?
|
2008-12-18 13:50:57 +00:00
|
|
|
else // Make sure it's not mapped if the app unmapped it (#65279). The app
|
2011-01-30 14:34:42 +00:00
|
|
|
// may do map+unmap before we initially map the window by calling rawShow() from manage().
|
2013-09-10 05:38:21 +00:00
|
|
|
m_client.unmap();
|
2013-09-10 05:27:39 +00:00
|
|
|
m_client.reset();
|
2013-05-02 16:26:05 +00:00
|
|
|
m_wrapper.reset();
|
2013-09-10 06:13:33 +00:00
|
|
|
m_frame.reset();
|
2015-10-13 11:15:39 +00:00
|
|
|
unblockGeometryUpdates(); // Don't use GeometryUpdatesBlocker, it would now set the geometry
|
2012-04-22 07:27:53 +00:00
|
|
|
if (!on_shutdown) {
|
|
|
|
disownDataPassedToDeleted();
|
|
|
|
del->unrefWindow();
|
|
|
|
}
|
2013-04-26 07:47:45 +00:00
|
|
|
deleteClient(this);
|
2007-04-30 09:41:48 +00:00
|
|
|
ungrabXServer();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Like releaseWindow(), but this one is called when the window has been already destroyed
|
|
|
|
* (E.g. The application closed it)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::destroyClient()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(!deleting);
|
2007-04-29 17:35:43 +00:00
|
|
|
deleting = true;
|
2019-04-30 08:46:53 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
|
|
|
TabBox::TabBox *tabBox = TabBox::TabBox::self();
|
2019-07-29 20:45:21 +00:00
|
|
|
if (tabBox && tabBox->isDisplayed() && tabBox->currentClient() == this) {
|
2019-04-30 08:46:53 +00:00
|
|
|
tabBox->nextPrev(true);
|
|
|
|
}
|
|
|
|
#endif
|
2015-07-09 07:10:33 +00:00
|
|
|
destroyWindowManagementInterface();
|
2011-01-30 14:34:42 +00:00
|
|
|
Deleted* del = Deleted::create(this);
|
2015-10-16 07:08:02 +00:00
|
|
|
if (isMoveResize())
|
2011-07-16 12:23:54 +00:00
|
|
|
emit clientFinishUserMovedResized(this);
|
2011-06-21 11:52:25 +00:00
|
|
|
emit windowClosed(this, del);
|
2014-04-07 14:23:17 +00:00
|
|
|
finishCompositing(ReleaseReason::Destroyed);
|
2013-04-26 12:40:35 +00:00
|
|
|
RuleBook::self()->discardUsed(this, true); // Remove ForceTemporarily rules
|
2011-01-30 14:34:42 +00:00
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
2015-10-16 07:08:02 +00:00
|
|
|
if (isMoveResize())
|
2011-01-30 14:34:42 +00:00
|
|
|
leaveMoveResize();
|
2007-04-29 17:35:43 +00:00
|
|
|
finishWindowRules();
|
2015-10-13 11:15:39 +00:00
|
|
|
blockGeometryUpdates();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isOnCurrentDesktop() && isShown(true))
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
setModal(false);
|
2008-12-18 13:50:57 +00:00
|
|
|
hidden = true; // So that it's not considered visible anymore
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->clientHidden(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyDecoration();
|
|
|
|
cleanGrouping();
|
2013-04-26 07:47:45 +00:00
|
|
|
workspace()->removeClient(this);
|
2013-09-10 05:27:39 +00:00
|
|
|
m_client.reset(); // invalidate
|
2013-05-02 16:26:05 +00:00
|
|
|
m_wrapper.reset();
|
2013-09-10 06:13:33 +00:00
|
|
|
m_frame.reset();
|
2015-10-13 11:15:39 +00:00
|
|
|
unblockGeometryUpdates(); // Don't use GeometryUpdatesBlocker, it would now set the geometry
|
2007-04-29 17:35:43 +00:00
|
|
|
disownDataPassedToDeleted();
|
|
|
|
del->unrefWindow();
|
2013-04-26 07:47:45 +00:00
|
|
|
deleteClient(this);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateInputWindow()
|
2011-11-09 19:39:13 +00:00
|
|
|
{
|
2013-09-09 17:38:30 +00:00
|
|
|
if (!Xcb::Extensions::self()->isShapeInputAvailable())
|
|
|
|
return;
|
|
|
|
|
2011-11-09 19:39:13 +00:00
|
|
|
QRegion region;
|
|
|
|
|
2015-12-03 12:24:44 +00:00
|
|
|
if (!noBorder() && isDecorated()) {
|
|
|
|
const QMargins &r = decoration()->resizeOnlyBorders();
|
2014-11-11 10:33:02 +00:00
|
|
|
const int left = r.left();
|
|
|
|
const int top = r.top();
|
|
|
|
const int right = r.right();
|
|
|
|
const int bottom = r.bottom();
|
2014-07-25 06:55:55 +00:00
|
|
|
if (left != 0 || top != 0 || right != 0 || bottom != 0) {
|
|
|
|
region = QRegion(-left,
|
|
|
|
-top,
|
2015-12-03 12:24:44 +00:00
|
|
|
decoration()->size().width() + left + right,
|
|
|
|
decoration()->size().height() + top + bottom);
|
|
|
|
region = region.subtracted(decoration()->rect());
|
2014-07-25 06:55:55 +00:00
|
|
|
}
|
2011-11-09 19:39:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (region.isEmpty()) {
|
2013-02-04 10:20:15 +00:00
|
|
|
m_decoInputExtent.reset();
|
2011-11-09 19:39:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect bounds = region.boundingRect();
|
|
|
|
input_offset = bounds.topLeft();
|
|
|
|
|
|
|
|
// Move the bounding rect to screen coordinates
|
2019-09-27 10:01:10 +00:00
|
|
|
bounds.translate(frameGeometry().topLeft());
|
2011-11-09 19:39:13 +00:00
|
|
|
|
|
|
|
// Move the region to input window coordinates
|
|
|
|
region.translate(-input_offset);
|
|
|
|
|
2013-02-04 10:20:15 +00:00
|
|
|
if (!m_decoInputExtent.isValid()) {
|
|
|
|
const uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
|
|
|
|
const uint32_t values[] = {true,
|
|
|
|
XCB_EVENT_MASK_ENTER_WINDOW |
|
|
|
|
XCB_EVENT_MASK_LEAVE_WINDOW |
|
|
|
|
XCB_EVENT_MASK_BUTTON_PRESS |
|
|
|
|
XCB_EVENT_MASK_BUTTON_RELEASE |
|
|
|
|
XCB_EVENT_MASK_POINTER_MOTION
|
|
|
|
};
|
|
|
|
m_decoInputExtent.create(bounds, XCB_WINDOW_CLASS_INPUT_ONLY, mask, values);
|
2012-10-03 17:00:56 +00:00
|
|
|
if (mapping_state == Mapped)
|
2013-02-04 10:20:15 +00:00
|
|
|
m_decoInputExtent.map();
|
2011-11-09 19:39:13 +00:00
|
|
|
} else {
|
2013-02-04 10:20:15 +00:00
|
|
|
m_decoInputExtent.setGeometry(bounds);
|
2011-11-09 19:39:13 +00:00
|
|
|
}
|
|
|
|
|
2013-02-04 10:20:15 +00:00
|
|
|
const QVector<xcb_rectangle_t> rects = Xcb::regionToRects(region);
|
|
|
|
xcb_shape_rectangles(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
|
|
|
|
m_decoInputExtent, 0, 0, rects.count(), rects.constData());
|
2011-11-09 19:39:13 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateDecoration(bool check_workspace_pos, bool force)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!force &&
|
2015-12-03 12:24:44 +00:00
|
|
|
((!isDecorated() && noBorder()) || (isDecorated() && !noBorder())))
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2019-09-27 10:01:10 +00:00
|
|
|
QRect oldgeom = frameGeometry();
|
fix sendToScreen/checkWorkspaceGeometry
Prime target is to preserve the in-screen
condition of client AND window.i[1]
Atm. when the client is fully in sight
(but the window is not) - regardless of snapping
or screen change - a workspace update (screen change,
resolution change, adding/removing a strutting panel)
would allow the client to partiall escape screen bounds.
This is changed so that if the client is fully in sight,
it's kept fully in sight (but not the decoration)
If the entire window was fully in sight, it's also kept
(as is right now)
The code handles inner screen edges (if the client was in sight,
the entire window will be if we'd bleed to the other screen)
[1] I'd say that handling the client is more relevant,
but foresee more complaints if the window wasn't handled anymore ;-)
During that, i stumbled across some other issues.
- when a window centered on one screen is moved to a screen smaller
than the window, the window is shrinked to the dimensions of that
screen and now randomly touches eg. left AND right edge. When
moved back, the right and bottom edge were preferred
(to the window was "moved" into the lower right corner).
It's now kept centered.
- geom_restore was saved before keeping the window in the new
screen area (causing accidental drops on screen changes)
BUG: 330968
REVIEW: 122517
FIXED-IN: 5.4
Prime target is to preserve the in-screen condition
of client AND window.[1]
Atm. when the client is fully in sight (but the window is not) -
regardless of snapping or screen change - a workspace update
(screen change, resolution change, adding/removing a strutting
panel) would allow the client to partiall escape screen bounds.
This is changed so that if the client is fully in sight,
it's kept fully in sight (but not the decoration)
If the entire window was fully in sight, it's also kept
(as is right now)
The code handles inner screen edges (if the client was in sight,
the entire window will be if we'd bleed to the other screen)
[1] I'd say that handling the client is more relevant,
but foresee more complaints if the window wasn't handled anymore ;-)
During that, i stumbled across some other issues.
- when a window centered on one screen is moved to a screen
smaller than the window, the window is shrinked to the dimensions
of that screen and now randomly touches eg. left AND right edge.
When moved back, the right and bottom edge were preferred
(to the window was "moved" into the lower right corner).
It's now kept centered.
- geom_restore was saved before keeping the window in the new
screen area (causing accidental drops on screen changes)
BUG: 330968
REVIEW: 116029
FIXED-IN: 5.3
2015-02-06 21:48:12 +00:00
|
|
|
QRect oldClientGeom = oldgeom.adjusted(borderLeft(), borderTop(), -borderRight(), -borderBottom());
|
2011-01-30 14:34:42 +00:00
|
|
|
blockGeometryUpdates(true);
|
|
|
|
if (force)
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyDecoration();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!noBorder()) {
|
2013-05-07 07:46:40 +00:00
|
|
|
createDecoration(oldgeom);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyDecoration();
|
2019-09-29 11:26:04 +00:00
|
|
|
updateShadow();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (check_workspace_pos)
|
fix sendToScreen/checkWorkspaceGeometry
Prime target is to preserve the in-screen
condition of client AND window.i[1]
Atm. when the client is fully in sight
(but the window is not) - regardless of snapping
or screen change - a workspace update (screen change,
resolution change, adding/removing a strutting panel)
would allow the client to partiall escape screen bounds.
This is changed so that if the client is fully in sight,
it's kept fully in sight (but not the decoration)
If the entire window was fully in sight, it's also kept
(as is right now)
The code handles inner screen edges (if the client was in sight,
the entire window will be if we'd bleed to the other screen)
[1] I'd say that handling the client is more relevant,
but foresee more complaints if the window wasn't handled anymore ;-)
During that, i stumbled across some other issues.
- when a window centered on one screen is moved to a screen smaller
than the window, the window is shrinked to the dimensions of that
screen and now randomly touches eg. left AND right edge. When
moved back, the right and bottom edge were preferred
(to the window was "moved" into the lower right corner).
It's now kept centered.
- geom_restore was saved before keeping the window in the new
screen area (causing accidental drops on screen changes)
BUG: 330968
REVIEW: 122517
FIXED-IN: 5.4
Prime target is to preserve the in-screen condition
of client AND window.[1]
Atm. when the client is fully in sight (but the window is not) -
regardless of snapping or screen change - a workspace update
(screen change, resolution change, adding/removing a strutting
panel) would allow the client to partiall escape screen bounds.
This is changed so that if the client is fully in sight,
it's kept fully in sight (but not the decoration)
If the entire window was fully in sight, it's also kept
(as is right now)
The code handles inner screen edges (if the client was in sight,
the entire window will be if we'd bleed to the other screen)
[1] I'd say that handling the client is more relevant,
but foresee more complaints if the window wasn't handled anymore ;-)
During that, i stumbled across some other issues.
- when a window centered on one screen is moved to a screen
smaller than the window, the window is shrinked to the dimensions
of that screen and now randomly touches eg. left AND right edge.
When moved back, the right and bottom edge were preferred
(to the window was "moved" into the lower right corner).
It's now kept centered.
- geom_restore was saved before keeping the window in the new
screen area (causing accidental drops on screen changes)
BUG: 330968
REVIEW: 116029
FIXED-IN: 5.3
2015-02-06 21:48:12 +00:00
|
|
|
checkWorkspacePosition(oldgeom, -2, oldClientGeom);
|
2011-11-09 19:39:13 +00:00
|
|
|
updateInputWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
blockGeometryUpdates(false);
|
2007-04-29 17:35:43 +00:00
|
|
|
updateFrameExtents();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::createDecoration(const QRect& oldgeom)
|
2013-05-07 07:46:40 +00:00
|
|
|
{
|
2015-12-03 12:24:44 +00:00
|
|
|
KDecoration2::Decoration *decoration = Decoration::DecorationBridge::self()->createDecoration(this);
|
|
|
|
if (decoration) {
|
|
|
|
QMetaObject::invokeMethod(decoration, "update", Qt::QueuedConnection);
|
2019-09-29 11:26:04 +00:00
|
|
|
connect(decoration, &KDecoration2::Decoration::shadowChanged, this, &Toplevel::updateShadow);
|
2019-09-24 08:48:08 +00:00
|
|
|
connect(decoration, &KDecoration2::Decoration::resizeOnlyBordersChanged, this, &X11Client::updateInputWindow);
|
2015-12-03 12:24:44 +00:00
|
|
|
connect(decoration, &KDecoration2::Decoration::bordersChanged, this,
|
2014-07-25 09:18:40 +00:00
|
|
|
[this]() {
|
2015-08-14 23:26:55 +00:00
|
|
|
updateFrameExtents();
|
2014-07-25 09:18:40 +00:00
|
|
|
GeometryUpdatesBlocker blocker(this);
|
2015-05-23 08:32:32 +00:00
|
|
|
// TODO: this is obviously idempotent
|
|
|
|
// calculateGravitation(true) would have to operate on the old border sizes
|
|
|
|
// move(calculateGravitation(true));
|
|
|
|
// move(calculateGravitation(false));
|
2019-09-27 10:01:10 +00:00
|
|
|
QRect oldgeom = frameGeometry();
|
2014-07-25 09:18:40 +00:00
|
|
|
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
|
2015-05-23 08:32:32 +00:00
|
|
|
if (!isShade())
|
|
|
|
checkWorkspacePosition(oldgeom);
|
2014-07-25 09:18:40 +00:00
|
|
|
emit geometryShapeChanged(this, oldgeom);
|
|
|
|
}
|
|
|
|
);
|
2019-09-24 08:48:08 +00:00
|
|
|
connect(decoratedClient()->decoratedClient(), &KDecoration2::DecoratedClient::widthChanged, this, &X11Client::updateInputWindow);
|
|
|
|
connect(decoratedClient()->decoratedClient(), &KDecoration2::DecoratedClient::heightChanged, this, &X11Client::updateInputWindow);
|
2014-07-22 11:11:19 +00:00
|
|
|
}
|
2015-12-03 12:24:44 +00:00
|
|
|
setDecoration(decoration);
|
2014-07-22 11:11:19 +00:00
|
|
|
|
2013-05-07 07:46:40 +00:00
|
|
|
move(calculateGravitation(false));
|
|
|
|
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
|
|
|
|
if (Compositor::compositing()) {
|
|
|
|
discardWindowPixmap();
|
|
|
|
}
|
|
|
|
emit geometryShapeChanged(this, oldgeom);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::destroyDecoration()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-27 10:01:10 +00:00
|
|
|
QRect oldgeom = frameGeometry();
|
2015-12-03 12:24:44 +00:00
|
|
|
if (isDecorated()) {
|
2015-02-16 22:38:56 +00:00
|
|
|
QPoint grav = calculateGravitation(true);
|
2015-12-03 12:24:44 +00:00
|
|
|
AbstractClient::destroyDecoration();
|
2011-01-30 14:34:42 +00:00
|
|
|
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
|
|
|
|
move(grav);
|
|
|
|
if (compositing())
|
2007-04-29 17:35:43 +00:00
|
|
|
discardWindowPixmap();
|
2011-03-12 11:34:59 +00:00
|
|
|
if (!deleting) {
|
2011-06-19 20:07:19 +00:00
|
|
|
emit geometryShapeChanged(this, oldgeom);
|
2011-03-12 11:34:59 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2013-02-04 10:20:15 +00:00
|
|
|
m_decoInputExtent.reset();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-12-03 12:24:44 +00:00
|
|
|
if (!isDecorated()) {
|
2014-07-22 11:11:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-12-03 12:24:44 +00:00
|
|
|
QRect r = decoration()->rect();
|
2009-05-04 22:35:33 +00:00
|
|
|
|
2009-11-25 23:32:35 +00:00
|
|
|
NETStrut strut = info->frameOverlap();
|
2009-11-30 00:37:52 +00:00
|
|
|
|
|
|
|
// Ignore the overlap strut when compositing is disabled
|
2014-07-22 11:11:19 +00:00
|
|
|
if (!compositing())
|
2009-11-30 00:37:52 +00:00
|
|
|
strut.left = strut.top = strut.right = strut.bottom = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (strut.left == -1 && strut.top == -1 && strut.right == -1 && strut.bottom == -1) {
|
2009-11-25 23:32:35 +00:00
|
|
|
top = QRect(r.x(), r.y(), r.width(), r.height() / 3);
|
|
|
|
left = QRect(r.x(), r.y() + top.height(), width() / 2, r.height() / 3);
|
|
|
|
right = QRect(r.x() + left.width(), r.y() + top.height(), r.width() - left.width(), left.height());
|
|
|
|
bottom = QRect(r.x(), r.y() + top.height() + left.height(), r.width(), r.height() - left.height() - top.height());
|
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-25 23:32:35 +00:00
|
|
|
|
2014-07-22 11:11:19 +00:00
|
|
|
top = QRect(r.x(), r.y(), r.width(), borderTop() + strut.top);
|
|
|
|
bottom = QRect(r.x(), r.y() + r.height() - borderBottom() - strut.bottom,
|
|
|
|
r.width(), borderBottom() + strut.bottom);
|
2009-05-04 22:35:33 +00:00
|
|
|
left = QRect(r.x(), r.y() + top.height(),
|
2014-07-22 11:11:19 +00:00
|
|
|
borderLeft() + strut.left, r.height() - top.height() - bottom.height());
|
|
|
|
right = QRect(r.x() + r.width() - borderRight() - strut.right, r.y() + top.height(),
|
|
|
|
borderRight() + strut.right, r.height() - top.height() - bottom.height());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-08 19:47:58 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
QRect X11Client::transparentRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-30 00:37:52 +00:00
|
|
|
if (isShade())
|
|
|
|
return QRect();
|
|
|
|
|
2009-11-25 23:32:35 +00:00
|
|
|
NETStrut strut = info->frameOverlap();
|
2009-12-16 20:51:54 +00:00
|
|
|
// Ignore the strut when compositing is disabled or the decoration doesn't support it
|
2014-07-22 11:11:19 +00:00
|
|
|
if (!compositing())
|
2009-11-30 00:37:52 +00:00
|
|
|
strut.left = strut.top = strut.right = strut.bottom = 0;
|
|
|
|
else if (strut.left == -1 && strut.top == -1 && strut.right == -1 && strut.bottom == -1)
|
2009-11-25 23:32:35 +00:00
|
|
|
return QRect();
|
|
|
|
|
|
|
|
const QRect r = QRect(clientPos(), clientSize())
|
2011-01-30 14:34:42 +00:00
|
|
|
.adjusted(strut.left, strut.top, -strut.right, -strut.bottom);
|
2009-11-25 23:32:35 +00:00
|
|
|
if (r.isValid())
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return QRect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-25 23:32:35 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::detectNoBorder()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (shape()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
noborder = true;
|
2008-03-23 00:12:11 +00:00
|
|
|
app_noborder = true;
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
switch(windowType()) {
|
|
|
|
case NET::Desktop :
|
|
|
|
case NET::Dock :
|
|
|
|
case NET::TopMenu :
|
|
|
|
case NET::Splash :
|
2014-02-12 09:52:45 +00:00
|
|
|
case NET::Notification :
|
2015-01-02 11:11:54 +00:00
|
|
|
case NET::OnScreenDisplay :
|
2019-05-02 08:29:38 +00:00
|
|
|
case NET::CriticalNotification :
|
2011-01-30 14:34:42 +00:00
|
|
|
noborder = true;
|
|
|
|
app_noborder = true;
|
|
|
|
break;
|
|
|
|
case NET::Unknown :
|
|
|
|
case NET::Normal :
|
|
|
|
case NET::Toolbar :
|
|
|
|
case NET::Menu :
|
|
|
|
case NET::Dialog :
|
|
|
|
case NET::Utility :
|
|
|
|
noborder = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// NET::Override is some strange beast without clear definition, usually
|
|
|
|
// just meaning "noborder", so let's treat it only as such flag, and ignore it as
|
|
|
|
// a window type otherwise (SUPPORTED_WINDOW_TYPES_MASK doesn't include it)
|
2015-02-06 15:30:46 +00:00
|
|
|
if (info->windowType(NET::OverrideMask) == NET::Override) {
|
2007-04-29 17:35:43 +00:00
|
|
|
noborder = true;
|
2008-03-23 00:12:11 +00:00
|
|
|
app_noborder = true;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateFrameExtents()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
NETStrut strut;
|
2014-07-22 11:11:19 +00:00
|
|
|
strut.left = borderLeft();
|
|
|
|
strut.right = borderRight();
|
|
|
|
strut.top = borderTop();
|
|
|
|
strut.bottom = borderBottom();
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setFrameExtents(strut);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
Xcb::Property X11Client::fetchGtkFrameExtents() const
|
2015-01-15 14:38:21 +00:00
|
|
|
{
|
|
|
|
return Xcb::Property(false, m_client, atoms->gtk_frame_extents, XCB_ATOM_CARDINAL, 0, 4);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::readGtkFrameExtents(Xcb::Property &prop)
|
2014-07-01 13:44:02 +00:00
|
|
|
{
|
|
|
|
m_clientSideDecorated = !prop.isNull() && prop->type != 0;
|
|
|
|
emit clientSideDecoratedChanged();
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::detectGtkFrameExtents()
|
2015-01-15 14:38:21 +00:00
|
|
|
{
|
|
|
|
Xcb::Property prop = fetchGtkFrameExtents();
|
|
|
|
readGtkFrameExtents(prop);
|
|
|
|
}
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2013-02-17 00:56:01 +00:00
|
|
|
* re-layouts (e.g. when maximization state changes,
|
|
|
|
* the decoration may alter some borders, but the actual size
|
2008-12-18 13:50:57 +00:00
|
|
|
* of the decoration stays the same).
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::resizeDecoration()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-12-03 12:24:44 +00:00
|
|
|
triggerDecorationRepaint();
|
2011-11-09 19:39:13 +00:00
|
|
|
updateInputWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::userNoBorder() const
|
2019-02-05 11:10:40 +00:00
|
|
|
{
|
|
|
|
return noborder;
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::isFullScreenable() const
|
2019-01-09 14:20:19 +00:00
|
|
|
{
|
|
|
|
if (!rules()->checkFullScreen(true)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (rules()->checkStrictGeometry(true)) {
|
|
|
|
// check geometry constraints (rule to obey is set)
|
|
|
|
const QRect fsarea = workspace()->clientArea(FullScreenArea, this);
|
|
|
|
if (sizeForClientSize(fsarea.size(), SizemodeAny, true) != fsarea.size()) {
|
|
|
|
return false; // the app wouldn't fit exactly fullscreen geometry due to its strict geometry requirements
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// don't check size constrains - some apps request fullscreen despite requesting fixed size
|
|
|
|
return !isSpecialWindow(); // also better disallow only weird types to go fullscreen
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::noBorder() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-02-05 11:10:40 +00:00
|
|
|
return userNoBorder() || isFullScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::userCanSetNoBorder() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-14 08:58:12 +00:00
|
|
|
return !isFullScreen() && !isShade();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setNoBorder(bool set)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!userCanSetNoBorder())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
set = rules()->checkNoBorder(set);
|
|
|
|
if (noborder == set)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2008-03-23 00:12:11 +00:00
|
|
|
noborder = set;
|
2011-01-30 14:34:42 +00:00
|
|
|
updateDecoration(true, false);
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::NoBorder);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::checkNoBorder()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
setNoBorder(app_noborder);
|
|
|
|
}
|
2010-10-26 14:43:29 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::wantsShadowToBeRendered() const
|
2014-07-24 06:55:57 +00:00
|
|
|
{
|
2014-12-02 12:49:08 +00:00
|
|
|
return !isFullScreen() && maximizeMode() != MaximizeFull;
|
2014-07-24 06:55:57 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateShape()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (shape()) {
|
|
|
|
// Workaround for #19644 - Shaped windows shouldn't have decoration
|
|
|
|
if (!app_noborder) {
|
|
|
|
// Only when shape is detected for the first time, still let the user to override
|
2008-03-23 00:12:11 +00:00
|
|
|
app_noborder = true;
|
2012-07-08 20:29:39 +00:00
|
|
|
noborder = rules()->checkNoBorder(true);
|
2011-01-30 14:34:42 +00:00
|
|
|
updateDecoration(true);
|
2007-04-29 21:19:29 +00:00
|
|
|
}
|
2013-02-04 12:48:09 +00:00
|
|
|
if (noBorder()) {
|
|
|
|
xcb_shape_combine(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
|
|
|
|
frameId(), clientPos().x(), clientPos().y(), window());
|
|
|
|
}
|
2012-02-17 17:41:44 +00:00
|
|
|
} else if (app_noborder) {
|
2013-02-04 12:48:09 +00:00
|
|
|
xcb_shape_mask(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, frameId(), 0, 0, XCB_PIXMAP_NONE);
|
2012-02-17 17:41:44 +00:00
|
|
|
detectNoBorder();
|
2014-01-30 15:28:55 +00:00
|
|
|
app_noborder = noborder;
|
2015-02-02 13:56:21 +00:00
|
|
|
noborder = rules()->checkNoBorder(noborder || m_motif.noBorder());
|
2012-02-17 17:41:44 +00:00
|
|
|
updateDecoration(true);
|
|
|
|
}
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2008-03-23 00:12:11 +00:00
|
|
|
// Decoration mask (i.e. 'else' here) setting is done in setMask()
|
|
|
|
// when the decoration calls it or when the decoration is created/destroyed
|
2007-07-04 09:51:10 +00:00
|
|
|
updateInputShape();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (compositing()) {
|
2008-09-30 16:45:24 +00:00
|
|
|
addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
addWorkspaceRepaint(visibleRect()); // In case shape change removes part of this window
|
2007-07-04 09:51:10 +00:00
|
|
|
}
|
2019-09-27 10:01:10 +00:00
|
|
|
emit geometryShapeChanged(this, frameGeometry());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 21:39:58 +00:00
|
|
|
|
2013-02-04 12:48:09 +00:00
|
|
|
static Xcb::Window shape_helper_window(XCB_WINDOW_NONE);
|
2008-03-23 00:12:11 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::cleanupX11()
|
2016-05-09 14:01:49 +00:00
|
|
|
{
|
|
|
|
shape_helper_window.reset();
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateInputShape()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (hiddenPreview()) // Sets it to none, don't change
|
2007-07-04 09:51:10 +00:00
|
|
|
return;
|
2012-12-21 14:11:31 +00:00
|
|
|
if (Xcb::Extensions::self()->isShapeInputAvailable()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// There appears to be no way to find out if a window has input
|
|
|
|
// shape set or not, so always propagate the input shape
|
|
|
|
// (it's the same like the bounding shape by default).
|
|
|
|
// Also, build the shape using a helper window, not directly
|
|
|
|
// in the frame window, because the sequence set-shape-to-frame,
|
|
|
|
// remove-shape-of-client, add-input-shape-of-client has the problem
|
|
|
|
// that after the second step there's a hole in the input shape
|
|
|
|
// until the real shape of the client is added and that can make
|
|
|
|
// the window lose focus (which is a problem with mouse focus policies)
|
|
|
|
// TODO: It seems there is, after all - XShapeGetRectangles() - but maybe this is better
|
2013-02-04 12:48:09 +00:00
|
|
|
if (!shape_helper_window.isValid())
|
|
|
|
shape_helper_window.create(QRect(0, 0, 1, 1));
|
|
|
|
shape_helper_window.resize(width(), height());
|
|
|
|
xcb_connection_t *c = connection();
|
|
|
|
xcb_shape_combine(c, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, XCB_SHAPE_SK_BOUNDING,
|
|
|
|
shape_helper_window, 0, 0, frameId());
|
|
|
|
xcb_shape_combine(c, XCB_SHAPE_SO_SUBTRACT, XCB_SHAPE_SK_INPUT, XCB_SHAPE_SK_BOUNDING,
|
|
|
|
shape_helper_window, clientPos().x(), clientPos().y(), window());
|
|
|
|
xcb_shape_combine(c, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_INPUT, XCB_SHAPE_SK_INPUT,
|
|
|
|
shape_helper_window, clientPos().x(), clientPos().y(), window());
|
|
|
|
xcb_shape_combine(c, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, XCB_SHAPE_SK_INPUT,
|
|
|
|
frameId(), 0, 0, shape_helper_window);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::hideClient(bool hide)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (hidden == hide)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
hidden = hide;
|
|
|
|
updateVisibility();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::setupCompositing()
|
2019-06-22 10:00:56 +00:00
|
|
|
{
|
|
|
|
if (!Toplevel::setupCompositing()){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
updateVisibility(); // for internalKeep()
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::finishCompositing(ReleaseReason releaseReason)
|
2019-06-22 10:00:56 +00:00
|
|
|
{
|
|
|
|
Toplevel::finishCompositing(releaseReason);
|
|
|
|
updateVisibility();
|
|
|
|
// for safety in case KWin is just resizing the window
|
|
|
|
resetHaveResizeEffect();
|
|
|
|
}
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the window is minimizable or not
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::isMinimizable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-06-28 19:49:24 +00:00
|
|
|
if (isSpecialWindow() && !isTransient())
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-12-10 19:29:01 +00:00
|
|
|
if (!rules()->checkMinimize(true))
|
|
|
|
return false;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isTransient()) {
|
|
|
|
// #66868 - Let other xmms windows be minimized when the mainwindow is minimized
|
2007-04-29 17:35:43 +00:00
|
|
|
bool shown_mainwindow = false;
|
2015-09-11 13:55:23 +00:00
|
|
|
auto mainclients = mainClients();
|
|
|
|
for (auto it = mainclients.constBegin();
|
2011-01-30 14:34:42 +00:00
|
|
|
it != mainclients.constEnd();
|
|
|
|
++it)
|
|
|
|
if ((*it)->isShown(true))
|
2007-04-29 17:35:43 +00:00
|
|
|
shown_mainwindow = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!shown_mainwindow)
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-01-09 14:07:03 +00:00
|
|
|
#if 0
|
2008-12-18 13:50:57 +00:00
|
|
|
// This is here because kicker's taskbar doesn't provide separate entries
|
2007-04-29 17:35:43 +00:00
|
|
|
// for windows with an explicitly given parent
|
2008-12-18 13:50:57 +00:00
|
|
|
// TODO: perhaps this should be redone
|
2009-01-09 14:07:03 +00:00
|
|
|
// Disabled for now, since at least modal dialogs should be minimizable
|
|
|
|
// (resulting in the mainwindow being minimized too).
|
2011-01-30 14:34:42 +00:00
|
|
|
if (transientFor() != NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2009-01-09 14:07:03 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!wantsTabFocus()) // SELI, TODO: - NET::Utility? why wantsTabFocus() - skiptaskbar? ?
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::doMinimize()
|
2011-12-22 18:01:01 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
updateVisibility();
|
|
|
|
updateAllowedActions();
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateMinimizedOfTransients(this);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
QRect X11Client::iconGeometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
NETRect r = info->iconGeometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect geom(r.pos.x, r.pos.y, r.size.width, r.size.height);
|
|
|
|
if (geom.isValid())
|
2007-04-29 17:35:43 +00:00
|
|
|
return geom;
|
2011-01-30 14:34:42 +00:00
|
|
|
else {
|
|
|
|
// Check all mainwindows of this window (recursively)
|
2015-09-11 13:55:23 +00:00
|
|
|
foreach (AbstractClient * amainwin, mainClients()) {
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *mainwin = dynamic_cast<X11Client *>(amainwin);
|
2015-09-11 13:55:23 +00:00
|
|
|
if (!mainwin) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
geom = mainwin->iconGeometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (geom.isValid())
|
2007-04-29 17:35:43 +00:00
|
|
|
return geom;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// No mainwindow (or their parents) with icon geometry was found
|
2016-08-22 14:55:48 +00:00
|
|
|
return AbstractClient::iconGeometry();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::isShadeable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-12-10 19:29:01 +00:00
|
|
|
return !isSpecialWindow() && !noBorder() && (rules()->checkShade(ShadeNormal) != rules()->checkShade(ShadeNone));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setShade(ShadeMode mode)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-03-20 15:38:08 +00:00
|
|
|
if (mode == ShadeHover && isMove())
|
|
|
|
return; // causes geometry breaks and is probably nasty
|
2011-12-10 19:29:01 +00:00
|
|
|
if (isSpecialWindow() || noBorder())
|
|
|
|
mode = ShadeNone;
|
2011-01-30 14:34:42 +00:00
|
|
|
mode = rules()->checkShade(mode);
|
|
|
|
if (shade_mode == mode)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
bool was_shade = isShade();
|
|
|
|
ShadeMode was_shade_mode = shade_mode;
|
|
|
|
shade_mode = mode;
|
2012-08-25 20:44:44 +00:00
|
|
|
|
2012-10-21 15:42:30 +00:00
|
|
|
// Decorations may turn off some borders when shaded
|
|
|
|
// this has to happen _before_ the tab alignment since it will restrict the minimum geometry
|
2014-07-22 11:11:19 +00:00
|
|
|
#if 0
|
2012-10-21 15:42:30 +00:00
|
|
|
if (decoration)
|
|
|
|
decoration->borders(border_left, border_right, border_top, border_bottom);
|
2014-07-22 11:11:19 +00:00
|
|
|
#endif
|
2012-10-21 15:42:30 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (was_shade == isShade()) {
|
2013-05-07 07:46:40 +00:00
|
|
|
// Decoration may want to update after e.g. hover-shade changes
|
|
|
|
emit shadeChanged();
|
2008-12-18 13:50:57 +00:00
|
|
|
return; // No real change in shaded state
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(isDecorated()); // noborder windows can't be shaded
|
2011-01-30 14:34:42 +00:00
|
|
|
GeometryUpdatesBlocker blocker(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// TODO: All this unmapping, resizing etc. feels too much duplicated from elsewhere
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isShade()) {
|
|
|
|
// shade_mode == ShadeNormal
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
2008-12-18 13:50:57 +00:00
|
|
|
// Shade
|
2007-04-29 17:35:43 +00:00
|
|
|
shade_geometry_change = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
QSize s(sizeForClientSize(QSize(clientSize())));
|
2014-07-22 11:11:19 +00:00
|
|
|
s.setHeight(borderTop() + borderBottom());
|
2013-08-19 08:52:22 +00:00
|
|
|
m_wrapper.selectInput(ClientWinMask); // Avoid getting UnmapNotify
|
2013-05-02 16:26:05 +00:00
|
|
|
m_wrapper.unmap();
|
2013-09-10 05:38:21 +00:00
|
|
|
m_client.unmap();
|
2013-08-19 08:52:22 +00:00
|
|
|
m_wrapper.selectInput(ClientWinMask | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
|
2019-09-06 14:30:26 +00:00
|
|
|
exportMappingState(XCB_ICCCM_WM_STATE_ICONIC);
|
2011-01-30 14:34:42 +00:00
|
|
|
plainResize(s);
|
2007-04-29 17:35:43 +00:00
|
|
|
shade_geometry_change = false;
|
2012-04-16 17:13:02 +00:00
|
|
|
if (was_shade_mode == ShadeHover) {
|
|
|
|
if (shade_below && workspace()->stackingOrder().indexOf(shade_below) > -1)
|
2015-02-06 22:00:34 +00:00
|
|
|
workspace()->restack(this, shade_below, true);
|
2012-04-16 17:13:02 +00:00
|
|
|
if (isActive())
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->activateNextClient(this);
|
2012-04-16 17:13:02 +00:00
|
|
|
} else if (isActive()) {
|
|
|
|
workspace()->focusToNull();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2007-04-29 17:35:43 +00:00
|
|
|
shade_geometry_change = true;
|
2016-01-07 22:12:40 +00:00
|
|
|
if (decoratedClient())
|
|
|
|
decoratedClient()->signalShadeChange();
|
2011-01-30 14:34:42 +00:00
|
|
|
QSize s(sizeForClientSize(clientSize()));
|
2007-04-29 17:35:43 +00:00
|
|
|
shade_geometry_change = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
plainResize(s);
|
2019-09-27 10:01:10 +00:00
|
|
|
setGeometryRestore(frameGeometry());
|
2014-09-12 11:56:34 +00:00
|
|
|
if ((shade_mode == ShadeHover || shade_mode == ShadeActivated) && rules()->checkAcceptFocus(info->input()))
|
2011-01-30 14:34:42 +00:00
|
|
|
setActive(true);
|
2012-03-14 08:59:41 +00:00
|
|
|
if (shade_mode == ShadeHover) {
|
2012-04-08 08:07:35 +00:00
|
|
|
ToplevelList order = workspace()->stackingOrder();
|
2012-12-08 13:52:32 +00:00
|
|
|
// invalidate, since "this" could be the topmost toplevel and shade_below dangeling
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
shade_below = nullptr;
|
2012-04-08 08:07:35 +00:00
|
|
|
// this is likely related to the index parameter?!
|
|
|
|
for (int idx = order.indexOf(this) + 1; idx < order.count(); ++idx) {
|
2019-09-24 08:48:08 +00:00
|
|
|
shade_below = qobject_cast<X11Client *>(order.at(idx));
|
2012-04-08 08:07:35 +00:00
|
|
|
if (shade_below) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-14 08:59:41 +00:00
|
|
|
if (shade_below && shade_below->isNormalWindow())
|
|
|
|
workspace()->raiseClient(this);
|
|
|
|
else
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
shade_below = nullptr;
|
2012-03-14 08:59:41 +00:00
|
|
|
}
|
2013-09-10 05:47:28 +00:00
|
|
|
m_wrapper.map();
|
2013-09-10 05:45:17 +00:00
|
|
|
m_client.map();
|
2019-09-06 14:30:26 +00:00
|
|
|
exportMappingState(XCB_ICCCM_WM_STATE_NORMAL);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isActive())
|
|
|
|
workspace()->requestFocus(this);
|
|
|
|
}
|
2019-09-14 21:17:53 +00:00
|
|
|
info->setState(isShade() ? NET::Shaded : NET::States(), NET::Shaded);
|
|
|
|
info->setState(isShown(false) ? NET::States() : NET::Hidden, NET::Hidden);
|
2007-04-29 17:35:43 +00:00
|
|
|
discardWindowPixmap();
|
|
|
|
updateVisibility();
|
|
|
|
updateAllowedActions();
|
2012-02-05 17:50:23 +00:00
|
|
|
updateWindowRules(Rules::Shade);
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-12-22 17:10:18 +00:00
|
|
|
emit shadeChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::shadeHover()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
setShade(ShadeHover);
|
2008-12-15 08:27:17 +00:00
|
|
|
cancelShadeHoverTimer();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::shadeUnhover()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-14 08:58:12 +00:00
|
|
|
setShade(ShadeNormal);
|
2008-12-15 08:27:17 +00:00
|
|
|
cancelShadeHoverTimer();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-12-15 08:27:17 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::cancelShadeHoverTimer()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete shadeHoverTimer;
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
shadeHoverTimer = nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::toggleShade()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
// If the mode is ShadeHover or ShadeActive, cancel shade too
|
|
|
|
setShade(shade_mode == ShadeNone ? ShadeNormal : ShadeNone);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateVisibility()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (deleting)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2019-09-14 08:58:12 +00:00
|
|
|
if (hidden) {
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setState(NET::Hidden, NET::Hidden);
|
2015-06-06 20:08:12 +00:00
|
|
|
setSkipTaskbar(true); // Also hide from taskbar
|
2012-02-20 09:25:13 +00:00
|
|
|
if (compositing() && options->hiddenPreviews() == HiddenPreviewsAlways)
|
2013-04-26 07:47:45 +00:00
|
|
|
internalKeep();
|
2008-08-12 11:02:58 +00:00
|
|
|
else
|
2013-04-26 07:47:45 +00:00
|
|
|
internalHide();
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2019-09-14 08:58:12 +00:00
|
|
|
setSkipTaskbar(originalSkipTaskbar()); // Reset from 'hidden'
|
2015-03-13 13:45:21 +00:00
|
|
|
if (isMinimized()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setState(NET::Hidden, NET::Hidden);
|
2012-02-20 09:25:13 +00:00
|
|
|
if (compositing() && options->hiddenPreviews() == HiddenPreviewsAlways)
|
2013-04-26 07:47:45 +00:00
|
|
|
internalKeep();
|
2008-08-12 11:02:58 +00:00
|
|
|
else
|
2013-04-26 07:47:45 +00:00
|
|
|
internalHide();
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2019-09-14 21:17:53 +00:00
|
|
|
info->setState(NET::States(), NET::Hidden);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!isOnCurrentDesktop()) {
|
2012-02-20 09:25:13 +00:00
|
|
|
if (compositing() && options->hiddenPreviews() != HiddenPreviewsNever)
|
2013-04-26 07:47:45 +00:00
|
|
|
internalKeep();
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2013-04-26 07:47:45 +00:00
|
|
|
internalHide();
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (!isOnCurrentActivity()) {
|
2012-02-20 09:25:13 +00:00
|
|
|
if (compositing() && options->hiddenPreviews() != HiddenPreviewsNever)
|
2013-04-26 07:47:45 +00:00
|
|
|
internalKeep();
|
2010-05-11 20:30:20 +00:00
|
|
|
else
|
2013-04-26 07:47:45 +00:00
|
|
|
internalHide();
|
2010-05-11 20:30:20 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-04-26 07:47:45 +00:00
|
|
|
internalShow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-08-26 14:16:38 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Sets the client window's mapping state. Possible values are
|
|
|
|
* WithdrawnState, IconicState, NormalState.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::exportMappingState(int s)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(m_client != XCB_WINDOW_NONE);
|
2019-09-06 14:30:26 +00:00
|
|
|
Q_ASSERT(!deleting || s == XCB_ICCCM_WM_STATE_WITHDRAWN);
|
|
|
|
if (s == XCB_ICCCM_WM_STATE_WITHDRAWN) {
|
2013-09-10 07:28:22 +00:00
|
|
|
m_client.deleteProperty(atoms->wm_state);
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2019-09-06 14:30:26 +00:00
|
|
|
Q_ASSERT(s == XCB_ICCCM_WM_STATE_NORMAL || s == XCB_ICCCM_WM_STATE_ICONIC);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-09-10 09:22:38 +00:00
|
|
|
int32_t data[2];
|
|
|
|
data[0] = s;
|
|
|
|
data[1] = XCB_NONE;
|
|
|
|
m_client.changeProperty(atoms->wm_state, atoms->wm_state, 32, 2, data);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::internalShow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (mapping_state == Mapped)
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
|
|
|
MappingState old = mapping_state;
|
|
|
|
mapping_state = Mapped;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old == Unmapped || old == Withdrawn)
|
2013-04-26 07:47:45 +00:00
|
|
|
map();
|
2011-11-09 19:39:13 +00:00
|
|
|
if (old == Kept) {
|
2013-02-04 10:20:15 +00:00
|
|
|
m_decoInputExtent.map();
|
2008-08-12 11:02:58 +00:00
|
|
|
updateHiddenPreview();
|
2011-11-09 19:39:13 +00:00
|
|
|
}
|
2016-07-14 08:54:35 +00:00
|
|
|
emit windowShown(this);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-12 11:02:58 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::internalHide()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (mapping_state == Unmapped)
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
|
|
|
MappingState old = mapping_state;
|
|
|
|
mapping_state = Unmapped;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old == Mapped || old == Kept)
|
2013-04-26 07:47:45 +00:00
|
|
|
unmap();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old == Kept)
|
2008-08-12 11:02:58 +00:00
|
|
|
updateHiddenPreview();
|
2011-01-30 14:34:42 +00:00
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
workspace()->clientHidden(this);
|
2016-07-14 08:54:35 +00:00
|
|
|
emit windowHidden(this);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-12 11:02:58 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::internalKeep()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(compositing());
|
2011-01-30 14:34:42 +00:00
|
|
|
if (mapping_state == Kept)
|
2008-08-12 11:02:58 +00:00
|
|
|
return;
|
|
|
|
MappingState old = mapping_state;
|
|
|
|
mapping_state = Kept;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old == Unmapped || old == Withdrawn)
|
2013-04-26 07:47:45 +00:00
|
|
|
map();
|
2013-02-04 10:20:15 +00:00
|
|
|
m_decoInputExtent.unmap();
|
2013-06-15 20:34:05 +00:00
|
|
|
if (isActive())
|
|
|
|
workspace()->focusToNull(); // get rid of input focus, bug #317484
|
2008-08-12 11:02:58 +00:00
|
|
|
updateHiddenPreview();
|
2011-01-30 14:34:42 +00:00
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
workspace()->clientHidden(this);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Maps (shows) the client. Note that it is mapping state of the frame,
|
|
|
|
* not necessarily the client window itself (i.e. a shaded window is here
|
|
|
|
* considered mapped, even though it is in IconicState).
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::map()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-08-12 11:02:58 +00:00
|
|
|
// XComposite invalidates backing pixmaps on unmap (minimize, different
|
|
|
|
// virtual desktop, etc.). We kept the last known good pixmap around
|
|
|
|
// for use in effects, but now we want to have access to the new pixmap
|
2011-01-30 14:34:42 +00:00
|
|
|
if (compositing())
|
2008-08-12 11:02:58 +00:00
|
|
|
discardWindowPixmap();
|
2013-09-10 06:37:49 +00:00
|
|
|
m_frame.map();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!isShade()) {
|
2013-05-02 16:26:05 +00:00
|
|
|
m_wrapper.map();
|
2013-09-10 05:38:21 +00:00
|
|
|
m_client.map();
|
2013-02-04 10:20:15 +00:00
|
|
|
m_decoInputExtent.map();
|
2019-09-06 14:30:26 +00:00
|
|
|
exportMappingState(XCB_ICCCM_WM_STATE_NORMAL);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2019-09-06 14:30:26 +00:00
|
|
|
exportMappingState(XCB_ICCCM_WM_STATE_ICONIC);
|
2015-01-07 09:53:32 +00:00
|
|
|
addLayerRepaint(visibleRect());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Unmaps the client. Again, this is about the frame.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::unmap()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-08-12 11:02:58 +00:00
|
|
|
// Here it may look like a race condition, as some other client might try to unmap
|
|
|
|
// the window between these two XSelectInput() calls. However, they're supposed to
|
|
|
|
// use XWithdrawWindow(), which also sends a synthetic event to the root window,
|
|
|
|
// which won't be missed, so this shouldn't be a problem. The chance the real UnmapNotify
|
|
|
|
// will be missed is also very minimal, so I don't think it's needed to grab the server
|
|
|
|
// here.
|
2013-08-19 08:52:22 +00:00
|
|
|
m_wrapper.selectInput(ClientWinMask); // Avoid getting UnmapNotify
|
2013-09-10 06:37:49 +00:00
|
|
|
m_frame.unmap();
|
2013-05-02 16:26:05 +00:00
|
|
|
m_wrapper.unmap();
|
2013-09-10 05:38:21 +00:00
|
|
|
m_client.unmap();
|
2013-02-04 10:20:15 +00:00
|
|
|
m_decoInputExtent.unmap();
|
2013-08-19 08:52:22 +00:00
|
|
|
m_wrapper.selectInput(ClientWinMask | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
|
2019-09-06 14:30:26 +00:00
|
|
|
exportMappingState(XCB_ICCCM_WM_STATE_ICONIC);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* XComposite doesn't keep window pixmaps of unmapped windows, which means
|
|
|
|
* there wouldn't be any previews of windows that are minimized or on another
|
|
|
|
* virtual desktop. Therefore rawHide() actually keeps such windows mapped.
|
|
|
|
* However special care needs to be taken so that such windows don't interfere.
|
|
|
|
* Therefore they're put very low in the stacking order and they have input shape
|
|
|
|
* set to none, which hopefully is enough. If there's no input shape available,
|
|
|
|
* then it's hoped that there will be some other desktop above it *shrug*.
|
|
|
|
* Using normal shape would be better, but that'd affect other things, e.g. painting
|
|
|
|
* of the actual preview.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateHiddenPreview()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (hiddenPreview()) {
|
2007-07-04 09:51:10 +00:00
|
|
|
workspace()->forceRestacking();
|
2013-02-04 12:48:09 +00:00
|
|
|
if (Xcb::Extensions::self()->isShapeInputAvailable()) {
|
|
|
|
xcb_shape_rectangles(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
XCB_CLIP_ORDERING_UNSORTED, frameId(), 0, 0, 0, nullptr);
|
2013-02-04 12:48:09 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2007-07-04 09:51:10 +00:00
|
|
|
workspace()->forceRestacking();
|
|
|
|
updateInputShape();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-07-04 09:51:10 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::sendClientMessage(xcb_window_t w, xcb_atom_t a, xcb_atom_t protocol, uint32_t data1, uint32_t data2, uint32_t data3, xcb_timestamp_t timestamp)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-05-03 08:55:37 +00:00
|
|
|
xcb_client_message_event_t ev;
|
2011-01-30 14:34:42 +00:00
|
|
|
memset(&ev, 0, sizeof(ev));
|
2013-05-03 08:55:37 +00:00
|
|
|
ev.response_type = XCB_CLIENT_MESSAGE;
|
|
|
|
ev.window = w;
|
|
|
|
ev.type = a;
|
|
|
|
ev.format = 32;
|
|
|
|
ev.data.data32[0] = protocol;
|
2016-01-15 11:18:24 +00:00
|
|
|
ev.data.data32[1] = timestamp;
|
2013-05-03 08:55:37 +00:00
|
|
|
ev.data.data32[2] = data1;
|
|
|
|
ev.data.data32[3] = data2;
|
|
|
|
ev.data.data32[4] = data3;
|
|
|
|
uint32_t eventMask = 0;
|
|
|
|
if (w == rootWindow()) {
|
|
|
|
eventMask = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT; // Magic!
|
|
|
|
}
|
|
|
|
xcb_send_event(connection(), false, w, eventMask, reinterpret_cast<const char*>(&ev));
|
|
|
|
xcb_flush(connection());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the window may be closed (have a close button)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::isCloseable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-02-02 13:56:21 +00:00
|
|
|
return rules()->checkCloseable(m_motif.close() && !isSpecialWindow());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Closes the window by either sending a delete_window message or using XKill.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::closeWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!isCloseable())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// Update user time, because the window may create a confirming dialog.
|
2008-12-18 13:50:57 +00:00
|
|
|
updateUserTime();
|
|
|
|
|
2014-09-18 06:43:20 +00:00
|
|
|
if (info->supportsProtocol(NET::DeleteWindowProtocol)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
sendClientMessage(window(), atoms->wm_protocols, atoms->wm_delete_window);
|
2007-04-29 17:35:43 +00:00
|
|
|
pingWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
} else // Client will not react on wm_delete_window. We have not choice
|
|
|
|
// but destroy his connection to the XServer.
|
2007-04-29 17:35:43 +00:00
|
|
|
killWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Kills the window via XKill
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::killWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-24 08:48:08 +00:00
|
|
|
qCDebug(KWIN_CORE) << "X11Client::killWindow():" << caption();
|
2011-01-30 14:34:42 +00:00
|
|
|
killProcess(false);
|
2013-09-10 06:49:41 +00:00
|
|
|
m_client.kill(); // Always kill this client at the server
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyClient();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Send a ping to the window using _NET_WM_PING if possible if it
|
|
|
|
* doesn't respond within a reasonable time, it will be killed.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::pingWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-09-18 06:43:20 +00:00
|
|
|
if (!info->supportsProtocol(NET::PingProtocol))
|
2008-12-18 13:50:57 +00:00
|
|
|
return; // Can't ping :(
|
2012-02-20 09:25:13 +00:00
|
|
|
if (options->killPingTimeout() == 0)
|
2008-12-18 13:50:57 +00:00
|
|
|
return; // Turned off
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
if (ping_timer != nullptr)
|
2008-12-18 13:50:57 +00:00
|
|
|
return; // Pinging already
|
2011-01-30 14:34:42 +00:00
|
|
|
ping_timer = new QTimer(this);
|
2014-04-03 08:54:56 +00:00
|
|
|
connect(ping_timer, &QTimer::timeout, this,
|
|
|
|
[this]() {
|
2017-04-05 09:16:23 +00:00
|
|
|
if (unresponsive()) {
|
|
|
|
qCDebug(KWIN_CORE) << "Final ping timeout, asking to kill:" << caption();
|
|
|
|
ping_timer->deleteLater();
|
|
|
|
ping_timer = nullptr;
|
|
|
|
killProcess(true, m_pingTimestamp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
qCDebug(KWIN_CORE) << "First ping timeout:" << caption();
|
|
|
|
|
|
|
|
setUnresponsive(true);
|
|
|
|
ping_timer->start();
|
2014-04-03 08:54:56 +00:00
|
|
|
}
|
|
|
|
);
|
2011-01-30 14:34:42 +00:00
|
|
|
ping_timer->setSingleShot(true);
|
2017-04-05 09:16:23 +00:00
|
|
|
// we'll run the timer twice, at first we'll desaturate the window
|
|
|
|
// and the second time we'll show the "do you want to kill" prompt
|
|
|
|
ping_timer->start(options->killPingTimeout() / 2);
|
2013-05-03 09:35:46 +00:00
|
|
|
m_pingTimestamp = xTime();
|
|
|
|
workspace()->sendPingToWindow(window(), m_pingTimestamp);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::gotPing(xcb_timestamp_t timestamp)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-12-18 13:50:57 +00:00
|
|
|
// Just plain compare is not good enough because of 64bit and truncating and whatnot
|
2013-05-03 09:35:46 +00:00
|
|
|
if (NET::timestampCompare(timestamp, m_pingTimestamp) != 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
delete ping_timer;
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
ping_timer = nullptr;
|
2017-04-05 09:16:23 +00:00
|
|
|
|
|
|
|
setUnresponsive(false);
|
|
|
|
|
2012-04-16 21:52:13 +00:00
|
|
|
if (m_killHelperPID && !::kill(m_killHelperPID, 0)) { // means the process is alive
|
|
|
|
::kill(m_killHelperPID, SIGTERM);
|
|
|
|
m_killHelperPID = 0;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::killProcess(bool ask, xcb_timestamp_t timestamp)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-04-16 21:52:13 +00:00
|
|
|
if (m_killHelperPID && !::kill(m_killHelperPID, 0)) // means the process is alive
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2013-05-03 09:02:06 +00:00
|
|
|
Q_ASSERT(!ask || timestamp != XCB_TIME_CURRENT_TIME);
|
2007-04-29 17:35:43 +00:00
|
|
|
pid_t pid = info->pid();
|
2013-01-07 07:07:27 +00:00
|
|
|
if (pid <= 0 || clientMachine()->hostName().isEmpty()) // Needed properties missing
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "Kill process:" << pid << "(" << clientMachine()->hostName() << ")";
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!ask) {
|
2013-01-07 07:07:27 +00:00
|
|
|
if (!clientMachine()->isLocal()) {
|
2008-12-18 13:50:57 +00:00
|
|
|
QStringList lst;
|
2013-07-23 05:02:52 +00:00
|
|
|
lst << QString::fromUtf8(clientMachine()->hostName()) << QStringLiteral("kill") << QString::number(pid);
|
|
|
|
QProcess::startDetached(QStringLiteral("xon"), lst);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
|
|
|
::kill(pid, SIGTERM);
|
|
|
|
} else {
|
2013-07-23 05:02:52 +00:00
|
|
|
QString hostname = clientMachine()->isLocal() ? QStringLiteral("localhost") : QString::fromUtf8(clientMachine()->hostName());
|
2018-11-08 21:02:32 +00:00
|
|
|
// execute helper from build dir or the system installed one
|
|
|
|
const QFileInfo buildDirBinary{QDir{QCoreApplication::applicationDirPath()}, QStringLiteral("kwin_killer_helper")};
|
|
|
|
QProcess::startDetached(buildDirBinary.exists() ? buildDirBinary.absoluteFilePath() : QStringLiteral(KWIN_KILLER_BIN),
|
2013-07-23 05:02:52 +00:00
|
|
|
QStringList() << QStringLiteral("--pid") << QString::number(unsigned(pid)) << QStringLiteral("--hostname") << hostname
|
2017-08-20 07:35:15 +00:00
|
|
|
<< QStringLiteral("--windowname") << captionNormal()
|
2013-07-23 05:02:52 +00:00
|
|
|
<< QStringLiteral("--applicationname") << QString::fromUtf8(resourceClass())
|
|
|
|
<< QStringLiteral("--wid") << QString::number(window())
|
|
|
|
<< QStringLiteral("--timestamp") << QString::number(timestamp),
|
2012-04-16 21:52:13 +00:00
|
|
|
QString(), &m_killHelperPID);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::doSetSkipTaskbar()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-14 21:17:53 +00:00
|
|
|
info->setState(skipTaskbar() ? NET::SkipTaskbar : NET::States(), NET::SkipTaskbar);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::doSetSkipPager()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-14 21:17:53 +00:00
|
|
|
info->setState(skipPager() ? NET::SkipPager : NET::States(), NET::SkipPager);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::doSetSkipSwitcher()
|
2018-05-24 04:33:39 +00:00
|
|
|
{
|
2019-09-14 21:17:53 +00:00
|
|
|
info->setState(skipSwitcher() ? NET::SkipSwitcher : NET::States(), NET::SkipSwitcher);
|
2018-05-24 04:33:39 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::doSetDesktop(int desktop, int was_desk)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-09-14 09:40:48 +00:00
|
|
|
Q_UNUSED(desktop)
|
|
|
|
Q_UNUSED(was_desk)
|
2007-04-29 17:35:43 +00:00
|
|
|
updateVisibility();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-05-11 20:30:20 +00:00
|
|
|
/**
|
|
|
|
* Sets whether the client is on @p activity.
|
|
|
|
* If you remove it from its last activity, then it's on all activities.
|
|
|
|
*
|
|
|
|
* Note: If it was on all activities and you try to remove it from one, nothing will happen;
|
|
|
|
* I don't think that's an important enough use case to handle here.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setOnActivity(const QString &activity, bool enable)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-04-04 14:14:12 +00:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
2015-07-07 09:48:42 +00:00
|
|
|
if (! Activities::self()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-09-24 12:03:22 +00:00
|
|
|
QStringList newActivitiesList = activities();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (newActivitiesList.contains(activity) == enable) //nothing to do
|
2010-05-11 20:30:20 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (enable) {
|
2013-04-04 14:14:12 +00:00
|
|
|
QStringList allActivities = Activities::self()->all();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!allActivities.contains(activity)) //bogus ID
|
2010-05-13 04:06:27 +00:00
|
|
|
return;
|
2010-05-11 20:30:20 +00:00
|
|
|
newActivitiesList.append(activity);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2010-05-11 20:30:20 +00:00
|
|
|
newActivitiesList.removeOne(activity);
|
2011-01-30 14:34:42 +00:00
|
|
|
setOnActivities(newActivitiesList);
|
2013-04-04 14:14:12 +00:00
|
|
|
#else
|
|
|
|
Q_UNUSED(activity)
|
|
|
|
Q_UNUSED(enable)
|
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-19 22:32:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set exactly which activities this client is on
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setOnActivities(QStringList newActivitiesList)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-04-04 14:14:12 +00:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
2015-07-07 09:48:42 +00:00
|
|
|
if (!Activities::self()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-23 05:02:52 +00:00
|
|
|
QString joinedActivitiesList = newActivitiesList.join(QStringLiteral(","));
|
2012-05-17 14:32:06 +00:00
|
|
|
joinedActivitiesList = rules()->checkActivity(joinedActivitiesList, false);
|
2015-11-05 14:14:06 +00:00
|
|
|
newActivitiesList = joinedActivitiesList.split(u',', QString::SkipEmptyParts);
|
2012-05-17 14:32:06 +00:00
|
|
|
|
2013-04-04 14:14:12 +00:00
|
|
|
QStringList allActivities = Activities::self()->all();
|
2016-08-12 11:25:33 +00:00
|
|
|
|
|
|
|
auto it = newActivitiesList.begin();
|
|
|
|
while (it != newActivitiesList.end()) {
|
|
|
|
if (! allActivities.contains(*it)) {
|
|
|
|
it = newActivitiesList.erase(it);
|
|
|
|
} else {
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-15 16:00:27 +00:00
|
|
|
if (// If we got the request to be on all activities explicitly
|
|
|
|
newActivitiesList.isEmpty() || joinedActivitiesList == Activities::nullUuid() ||
|
|
|
|
// If we got a list of activities that covers all activities
|
|
|
|
(newActivitiesList.count() > 1 && newActivitiesList.count() == allActivities.count())) {
|
|
|
|
|
2012-05-17 14:32:06 +00:00
|
|
|
activityList.clear();
|
2013-04-10 07:46:07 +00:00
|
|
|
const QByteArray nullUuid = Activities::nullUuid().toUtf8();
|
2013-09-10 09:22:38 +00:00
|
|
|
m_client.changeProperty(atoms->activities, XCB_ATOM_STRING, 8, nullUuid.length(), nullUuid.constData());
|
2010-09-24 12:03:22 +00:00
|
|
|
|
2012-05-17 14:32:06 +00:00
|
|
|
} else {
|
2019-07-10 13:04:52 +00:00
|
|
|
QByteArray joined = joinedActivitiesList.toLatin1();
|
2012-05-17 14:32:06 +00:00
|
|
|
activityList = newActivitiesList;
|
2013-09-10 09:22:38 +00:00
|
|
|
m_client.changeProperty(atoms->activities, XCB_ATOM_STRING, 8, joined.length(), joined.constData());
|
2012-05-17 14:32:06 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
updateActivities(false);
|
2013-04-04 14:14:12 +00:00
|
|
|
#else
|
|
|
|
Q_UNUSED(newActivitiesList)
|
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-19 22:32:57 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::blockActivityUpdates(bool b)
|
2013-03-24 20:57:26 +00:00
|
|
|
{
|
|
|
|
if (b) {
|
|
|
|
++m_activityUpdatesBlocked;
|
|
|
|
} else {
|
|
|
|
Q_ASSERT(m_activityUpdatesBlocked);
|
|
|
|
--m_activityUpdatesBlocked;
|
|
|
|
if (!m_activityUpdatesBlocked)
|
|
|
|
updateActivities(m_blockedActivityUpdatesRequireTransients);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-19 22:32:57 +00:00
|
|
|
/**
|
|
|
|
* update after activities changed
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateActivities(bool includeTransients)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-03-24 20:57:26 +00:00
|
|
|
if (m_activityUpdatesBlocked) {
|
|
|
|
m_blockedActivityUpdatesRequireTransients |= includeTransients;
|
|
|
|
return;
|
|
|
|
}
|
2013-03-25 14:18:58 +00:00
|
|
|
emit activitiesChanged(this);
|
2013-03-24 20:57:26 +00:00
|
|
|
m_blockedActivityUpdatesRequireTransients = false; // reset
|
2012-11-20 16:26:50 +00:00
|
|
|
FocusChain::self()->update(this, FocusChain::MakeFirst);
|
2010-05-11 20:30:20 +00:00
|
|
|
updateVisibility();
|
2012-05-17 14:32:06 +00:00
|
|
|
updateWindowRules(Rules::Activity);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-11 20:30:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of activities the client window is on.
|
|
|
|
* if it's on all activities, the list will be empty.
|
|
|
|
* Don't use this, use isOnActivity() and friends (from class Toplevel)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
QStringList X11Client::activities() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2017-04-27 10:18:41 +00:00
|
|
|
if (sessionActivityOverride) {
|
2010-12-16 20:14:22 +00:00
|
|
|
return QStringList();
|
|
|
|
}
|
2010-05-11 20:30:20 +00:00
|
|
|
return activityList;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-11 20:30:20 +00:00
|
|
|
|
|
|
|
/**
|
2010-05-13 04:56:38 +00:00
|
|
|
* if @p on is true, sets on all activities.
|
2010-05-11 20:30:20 +00:00
|
|
|
* if it's false, sets it to only be on the current activity
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setOnAllActivities(bool on)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-04-04 14:14:12 +00:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
2011-01-30 14:34:42 +00:00
|
|
|
if (on == isOnAllActivities())
|
2010-05-11 20:30:20 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (on) {
|
2012-05-17 14:32:06 +00:00
|
|
|
setOnActivities(QStringList());
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2013-04-04 14:14:12 +00:00
|
|
|
setOnActivity(Activities::self()->current(), true);
|
2010-05-11 20:30:20 +00:00
|
|
|
}
|
2014-11-21 15:48:39 +00:00
|
|
|
#else
|
|
|
|
Q_UNUSED(on)
|
2013-04-04 14:14:12 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-11 20:30:20 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Performs the actual focusing of the window using XSetInputFocus and WM_TAKE_FOCUS
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::takeFocus()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-09-12 11:56:34 +00:00
|
|
|
if (rules()->checkAcceptFocus(info->input()))
|
2013-09-10 08:59:16 +00:00
|
|
|
m_client.focus();
|
2012-04-16 15:27:53 +00:00
|
|
|
else
|
|
|
|
demandAttention(false); // window cannot take input, at least withdraw urgency
|
2015-05-05 10:23:45 +00:00
|
|
|
if (info->supportsProtocol(NET::TakeFocusProtocol)) {
|
2016-01-15 11:18:24 +00:00
|
|
|
sendClientMessage(window(), atoms->wm_protocols, atoms->wm_take_focus, 0, 0, 0, XCB_CURRENT_TIME);
|
2015-05-05 10:23:45 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->setShouldGetFocus(this);
|
2015-05-13 21:25:20 +00:00
|
|
|
|
|
|
|
bool breakShowingDesktop = !keepAbove();
|
|
|
|
if (breakShowingDesktop) {
|
2019-09-24 08:48:08 +00:00
|
|
|
foreach (const X11Client *c, group()->members()) {
|
2015-05-13 21:25:20 +00:00
|
|
|
if (c->isDesktop()) {
|
|
|
|
breakShowingDesktop = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (breakShowingDesktop)
|
|
|
|
workspace()->setShowingDesktop(false);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* contextHelp() if this is invoked.
|
|
|
|
*
|
|
|
|
* \sa contextHelp()
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::providesContextHelp() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-09-18 06:43:20 +00:00
|
|
|
return info->supportsProtocol(NET::ContextHelpProtocol);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Invokes context help on the window. Only works if the window
|
|
|
|
* actually provides context help.
|
|
|
|
*
|
|
|
|
* \sa providesContextHelp()
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::showContextHelp()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-09-18 06:43:20 +00:00
|
|
|
if (info->supportsProtocol(NET::ContextHelpProtocol)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
sendClientMessage(window(), atoms->wm_protocols, atoms->net_wm_context_help);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Fetches the window's caption (WM_NAME property). It will be
|
|
|
|
* stored in the client's caption().
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::fetchName()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
setCaption(readName());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2017-08-01 19:28:36 +00:00
|
|
|
static inline QString readNameProperty(xcb_window_t w, xcb_atom_t atom)
|
|
|
|
{
|
|
|
|
const auto cookie = xcb_icccm_get_text_property_unchecked(connection(), w, atom);
|
|
|
|
xcb_icccm_get_text_property_reply_t reply;
|
|
|
|
if (xcb_icccm_get_wm_name_reply(connection(), cookie, &reply, nullptr)) {
|
|
|
|
QString retVal;
|
|
|
|
if (reply.encoding == atoms->utf8_string) {
|
|
|
|
retVal = QString::fromUtf8(QByteArray(reply.name, reply.name_len));
|
|
|
|
} else if (reply.encoding == XCB_ATOM_STRING) {
|
|
|
|
retVal = QString::fromLocal8Bit(QByteArray(reply.name, reply.name_len));
|
|
|
|
}
|
|
|
|
xcb_icccm_get_text_property_reply_wipe(&reply);
|
|
|
|
return retVal.simplified();
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
QString X11Client::readName() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (info->name() && info->name()[0] != '\0')
|
2016-10-31 14:56:01 +00:00
|
|
|
return QString::fromUtf8(info->name()).simplified();
|
2017-08-01 19:28:36 +00:00
|
|
|
else {
|
|
|
|
return readNameProperty(window(), XCB_ATOM_WM_NAME);
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-12-18 13:50:57 +00:00
|
|
|
|
2019-03-25 18:11:15 +00:00
|
|
|
// The list is taken from https://www.unicode.org/reports/tr9/ (#154840)
|
2014-09-27 18:30:49 +00:00
|
|
|
static const QChar LRM(0x200E);
|
2008-08-13 16:33:54 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setCaption(const QString& _s, bool force)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-10-16 20:42:19 +00:00
|
|
|
QString s(_s);
|
Fix captions with non-BMP characters
KWin replaces any non-printable character with a space. This check does not
handle surrogate pairs correctly. Additionally, translators sometimes insert
non-printable soft-hyphens into titles, which also cause KWin to display a
space instead.
This code adds the missing surrogate handling, and (to fix both issues), also
removes non-printable characters instead of replacing them with a space.
Also moved the changed test after these changes, so that changes in non-
printable characters do not cause unneeded redraws.
Unit tests adapted by Vlad Zagorodniy.
Test Plan:
kwrite /tmp/Test😣.txt shows correct title. I also tested actual non-printable
characters, such as 0x1A, and these are correctly omitted.
BUG: 376813
FIXED-IN: 5.15.5
Reviewers: #kwin, zzag
Reviewed By: #kwin, zzag
Subscribers: zzag, grasslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19052
2019-04-26 08:52:57 +00:00
|
|
|
for (int i = 0; i < s.length(); ) {
|
|
|
|
if (!s[i].isPrint()) {
|
|
|
|
if (QChar(s[i]).isHighSurrogate() && i + 1 < s.length() && QChar(s[i + 1]).isLowSurrogate()) {
|
|
|
|
const uint uc = QChar::surrogateToUcs4(s[i], s[i + 1]);
|
|
|
|
if (!QChar::isPrint(uc)) {
|
|
|
|
s.remove(i, 2);
|
|
|
|
} else {
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
s.remove(i, 1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
2017-09-18 16:37:45 +00:00
|
|
|
const bool changed = (s != cap_normal);
|
Fix captions with non-BMP characters
KWin replaces any non-printable character with a space. This check does not
handle surrogate pairs correctly. Additionally, translators sometimes insert
non-printable soft-hyphens into titles, which also cause KWin to display a
space instead.
This code adds the missing surrogate handling, and (to fix both issues), also
removes non-printable characters instead of replacing them with a space.
Also moved the changed test after these changes, so that changes in non-
printable characters do not cause unneeded redraws.
Unit tests adapted by Vlad Zagorodniy.
Test Plan:
kwrite /tmp/Test😣.txt shows correct title. I also tested actual non-printable
characters, such as 0x1A, and these are correctly omitted.
BUG: 376813
FIXED-IN: 5.15.5
Reviewers: #kwin, zzag
Reviewed By: #kwin, zzag
Subscribers: zzag, grasslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19052
2019-04-26 08:52:57 +00:00
|
|
|
if (!force && !changed) {
|
|
|
|
return;
|
|
|
|
}
|
2012-10-16 20:42:19 +00:00
|
|
|
cap_normal = s;
|
2017-09-18 16:37:45 +00:00
|
|
|
if (!force && !changed) {
|
2017-08-13 14:54:04 +00:00
|
|
|
emit captionChanged();
|
2012-10-16 20:42:19 +00:00
|
|
|
return;
|
2017-08-13 14:54:04 +00:00
|
|
|
}
|
2012-10-16 20:42:19 +00:00
|
|
|
|
|
|
|
bool reset_name = force;
|
|
|
|
bool was_suffix = (!cap_suffix.isEmpty());
|
|
|
|
cap_suffix.clear();
|
|
|
|
QString machine_suffix;
|
|
|
|
if (!options->condensedTitle()) { // machine doesn't qualify for "clean"
|
2013-01-07 07:07:27 +00:00
|
|
|
if (clientMachine()->hostName() != ClientMachine::localhost() && !clientMachine()->isLocal())
|
2015-11-05 14:14:06 +00:00
|
|
|
machine_suffix = QLatin1String(" <@") + QString::fromUtf8(clientMachine()->hostName()) + QLatin1Char('>') + LRM;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2017-08-03 05:11:40 +00:00
|
|
|
QString shortcut_suffix = shortcutCaptionSuffix();
|
2012-10-16 20:42:19 +00:00
|
|
|
cap_suffix = machine_suffix + shortcut_suffix;
|
2017-08-20 06:56:13 +00:00
|
|
|
if ((!isSpecialWindow() || isToolbar()) && findClientWithSameCaption()) {
|
2012-10-16 20:42:19 +00:00
|
|
|
int i = 2;
|
|
|
|
do {
|
2015-11-05 14:14:06 +00:00
|
|
|
cap_suffix = machine_suffix + QLatin1String(" <") + QString::number(i) + QLatin1Char('>') + LRM;
|
2012-10-16 20:42:19 +00:00
|
|
|
i++;
|
2017-08-20 06:56:13 +00:00
|
|
|
} while (findClientWithSameCaption());
|
2013-07-23 05:02:52 +00:00
|
|
|
info->setVisibleName(caption().toUtf8().constData());
|
2012-10-16 20:42:19 +00:00
|
|
|
reset_name = false;
|
|
|
|
}
|
|
|
|
if ((was_suffix && cap_suffix.isEmpty()) || reset_name) {
|
|
|
|
// If it was new window, it may have old value still set, if the window is reused
|
|
|
|
info->setVisibleName("");
|
|
|
|
info->setVisibleIconName("");
|
|
|
|
} else if (!cap_suffix.isEmpty() && !cap_iconic.isEmpty())
|
|
|
|
// Keep the same suffix in iconic name if it's set
|
2013-07-23 05:02:52 +00:00
|
|
|
info->setVisibleIconName(QString(cap_iconic + cap_suffix).toUtf8().constData());
|
2012-10-16 20:42:19 +00:00
|
|
|
|
|
|
|
emit captionChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateCaption()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
setCaption(cap_normal, true);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::fetchIconicName()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QString s;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (info->iconName() && info->iconName()[0] != '\0')
|
|
|
|
s = QString::fromUtf8(info->iconName());
|
2008-12-18 13:50:57 +00:00
|
|
|
else
|
2017-08-01 19:28:36 +00:00
|
|
|
s = readNameProperty(window(), XCB_ATOM_WM_ICON_NAME);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (s != cap_iconic) {
|
2008-12-18 13:50:57 +00:00
|
|
|
bool was_set = !cap_iconic.isEmpty();
|
2007-04-29 17:35:43 +00:00
|
|
|
cap_iconic = s;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!cap_suffix.isEmpty()) {
|
|
|
|
if (!cap_iconic.isEmpty()) // Keep the same suffix in iconic name if it's set
|
2013-07-23 05:02:52 +00:00
|
|
|
info->setVisibleIconName(QString(s + cap_suffix).toUtf8().constData());
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (was_set)
|
|
|
|
info->setVisibleIconName("");
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setClientShown(bool shown)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (deleting)
|
2009-11-16 11:38:26 +00:00
|
|
|
return; // Don't change shown status if this client is being deleted
|
2012-01-12 06:42:55 +00:00
|
|
|
if (shown != hidden)
|
|
|
|
return; // nothing to change
|
|
|
|
hidden = !shown;
|
|
|
|
if (shown) {
|
2013-04-26 07:47:45 +00:00
|
|
|
map();
|
|
|
|
takeFocus();
|
2009-11-15 03:24:04 +00:00
|
|
|
autoRaise();
|
2012-11-20 16:26:50 +00:00
|
|
|
FocusChain::self()->update(this, FocusChain::MakeFirst);
|
2012-01-12 06:42:55 +00:00
|
|
|
} else {
|
2013-04-26 07:47:45 +00:00
|
|
|
unmap();
|
2010-09-24 21:34:20 +00:00
|
|
|
// Don't move tabs to the end of the list when another tab get's activated
|
2019-09-14 08:58:12 +00:00
|
|
|
FocusChain::self()->update(this, FocusChain::MakeLast);
|
2011-01-30 14:34:42 +00:00
|
|
|
addWorkspaceRepaint(visibleRect());
|
2009-11-15 03:24:04 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::getMotifHints()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-02-02 13:56:21 +00:00
|
|
|
const bool wasClosable = m_motif.close();
|
|
|
|
const bool wasNoBorder = m_motif.noBorder();
|
2015-08-31 20:25:48 +00:00
|
|
|
if (m_managed) // only on property change, initial read is prefetched
|
|
|
|
m_motif.fetch();
|
2015-02-02 13:56:21 +00:00
|
|
|
m_motif.read();
|
|
|
|
if (m_motif.hasDecoration() && m_motif.noBorder() != wasNoBorder) {
|
2009-10-03 14:32:24 +00:00
|
|
|
// If we just got a hint telling us to hide decorations, we do so.
|
2015-02-02 13:56:21 +00:00
|
|
|
if (m_motif.noBorder())
|
2012-01-12 18:01:43 +00:00
|
|
|
noborder = rules()->checkNoBorder(true);
|
2009-10-03 14:32:24 +00:00
|
|
|
// If the Motif hint is now telling us to show decorations, we only do so if the app didn't
|
|
|
|
// instruct us to hide decorations in some other way, though.
|
2012-01-12 18:01:43 +00:00
|
|
|
else if (!app_noborder)
|
|
|
|
noborder = rules()->checkNoBorder(false);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-12-18 13:50:57 +00:00
|
|
|
|
|
|
|
// mminimize; - Ignore, bogus - E.g. shading or sending to another desktop is "minimizing" too
|
|
|
|
// mmaximize; - Ignore, bogus - Maximizing is basically just resizing
|
2015-02-02 13:56:21 +00:00
|
|
|
const bool closabilityChanged = wasClosable != m_motif.close();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isManaged())
|
|
|
|
updateDecoration(true); // Check if noborder state has changed
|
2014-07-25 12:01:47 +00:00
|
|
|
if (closabilityChanged) {
|
|
|
|
emit closeableChanged(isCloseable());
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::getIcons()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-12-18 13:50:57 +00:00
|
|
|
// First read icons from the window itself
|
2016-10-27 13:59:08 +00:00
|
|
|
const QString themedIconName = iconFromDesktopFile();
|
|
|
|
if (!themedIconName.isEmpty()) {
|
|
|
|
setIcon(QIcon::fromTheme(themedIconName));
|
|
|
|
return;
|
|
|
|
}
|
2015-03-12 14:44:39 +00:00
|
|
|
QIcon icon;
|
|
|
|
auto readIcon = [this, &icon](int size, bool scale = true) {
|
2015-01-21 09:17:26 +00:00
|
|
|
const QPixmap pix = KWindowSystem::icon(window(), size, size, scale, KWindowSystem::NETWM | KWindowSystem::WMHints, info);
|
2013-12-06 13:41:23 +00:00
|
|
|
if (!pix.isNull()) {
|
2015-03-12 14:44:39 +00:00
|
|
|
icon.addPixmap(pix);
|
2013-12-06 13:41:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
readIcon(16);
|
|
|
|
readIcon(32);
|
|
|
|
readIcon(48, false);
|
|
|
|
readIcon(64, false);
|
|
|
|
readIcon(128, false);
|
2015-03-12 14:44:39 +00:00
|
|
|
if (icon.isNull()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// Then try window group
|
2015-03-12 14:44:39 +00:00
|
|
|
icon = group()->icon();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2015-03-12 14:44:39 +00:00
|
|
|
if (icon.isNull() && isTransient()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// Then mainclients
|
2015-09-11 13:55:23 +00:00
|
|
|
auto mainclients = mainClients();
|
|
|
|
for (auto it = mainclients.constBegin();
|
2015-03-12 14:44:39 +00:00
|
|
|
it != mainclients.constEnd() && icon.isNull();
|
2011-01-30 14:34:42 +00:00
|
|
|
++it) {
|
2013-12-06 13:41:23 +00:00
|
|
|
if (!(*it)->icon().isNull()) {
|
2015-03-12 14:44:39 +00:00
|
|
|
icon = (*it)->icon();
|
2013-12-06 13:41:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-12 14:44:39 +00:00
|
|
|
if (icon.isNull()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// And if nothing else, load icon from classhint or xapp icon
|
2015-03-12 14:44:39 +00:00
|
|
|
icon.addPixmap(KWindowSystem::icon(window(), 32, 32, true, KWindowSystem::ClassHint | KWindowSystem::XApp, info));
|
|
|
|
icon.addPixmap(KWindowSystem::icon(window(), 16, 16, true, KWindowSystem::ClassHint | KWindowSystem::XApp, info));
|
|
|
|
icon.addPixmap(KWindowSystem::icon(window(), 64, 64, false, KWindowSystem::ClassHint | KWindowSystem::XApp, info));
|
|
|
|
icon.addPixmap(KWindowSystem::icon(window(), 128, 128, false, KWindowSystem::ClassHint | KWindowSystem::XApp, info));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2015-03-12 14:44:39 +00:00
|
|
|
setIcon(icon);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::getSyncCounter()
|
2007-06-25 08:51:44 +00:00
|
|
|
{
|
2017-08-24 18:47:02 +00:00
|
|
|
// TODO: make sync working on XWayland
|
|
|
|
static const bool isX11 = kwinApp()->operationMode() == Application::OperationModeX11;
|
|
|
|
if (!Xcb::Extensions::self()->isSyncAvailable() || !isX11)
|
2007-06-25 08:51:44 +00:00
|
|
|
return;
|
|
|
|
|
2014-04-25 10:25:12 +00:00
|
|
|
Xcb::Property syncProp(false, window(), atoms->net_wm_sync_request_counter, XCB_ATOM_CARDINAL, 0, 1);
|
|
|
|
const xcb_sync_counter_t counter = syncProp.value<xcb_sync_counter_t>(XCB_NONE);
|
|
|
|
if (counter != XCB_NONE) {
|
|
|
|
syncRequest.counter = counter;
|
2013-07-31 08:11:39 +00:00
|
|
|
syncRequest.value.hi = 0;
|
|
|
|
syncRequest.value.lo = 0;
|
|
|
|
auto *c = connection();
|
2013-11-11 10:30:59 +00:00
|
|
|
xcb_sync_set_counter(c, syncRequest.counter, syncRequest.value);
|
2013-07-31 08:11:39 +00:00
|
|
|
if (syncRequest.alarm == XCB_NONE) {
|
2013-11-11 10:30:59 +00:00
|
|
|
const uint32_t mask = XCB_SYNC_CA_COUNTER | XCB_SYNC_CA_VALUE_TYPE | XCB_SYNC_CA_TEST_TYPE | XCB_SYNC_CA_EVENTS;
|
2013-07-31 08:11:39 +00:00
|
|
|
const uint32_t values[] = {
|
|
|
|
syncRequest.counter,
|
|
|
|
XCB_SYNC_VALUETYPE_RELATIVE,
|
|
|
|
XCB_SYNC_TESTTYPE_POSITIVE_TRANSITION,
|
|
|
|
1
|
|
|
|
};
|
|
|
|
syncRequest.alarm = xcb_generate_id(c);
|
2013-11-11 10:30:59 +00:00
|
|
|
auto cookie = xcb_sync_create_alarm_checked(c, syncRequest.alarm, mask, values);
|
|
|
|
ScopedCPointer<xcb_generic_error_t> error(xcb_request_check(c, cookie));
|
|
|
|
if (!error.isNull()) {
|
|
|
|
syncRequest.alarm = XCB_NONE;
|
|
|
|
} else {
|
2015-02-02 09:07:10 +00:00
|
|
|
xcb_sync_change_alarm_value_list_t value;
|
|
|
|
memset(&value, 0, sizeof(value));
|
|
|
|
value.value.hi = 0;
|
|
|
|
value.value.lo = 1;
|
|
|
|
value.delta.hi = 0;
|
|
|
|
value.delta.lo = 1;
|
|
|
|
xcb_sync_change_alarm_aux(c, syncRequest.alarm, XCB_SYNC_CA_DELTA | XCB_SYNC_CA_VALUE, &value);
|
2013-11-11 10:30:59 +00:00
|
|
|
}
|
2007-06-25 08:51:44 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-06-25 08:51:44 +00:00
|
|
|
}
|
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Send the client a _NET_SYNC_REQUEST
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::sendSyncRequest()
|
2007-06-25 08:51:44 +00:00
|
|
|
{
|
2013-07-31 08:11:39 +00:00
|
|
|
if (syncRequest.counter == XCB_NONE || syncRequest.isPending)
|
2011-08-13 14:39:58 +00:00
|
|
|
return; // do NOT, NEVER send a sync request when there's one on the stack. the clients will just stop respoding. FOREVER! ...
|
|
|
|
|
|
|
|
if (!syncRequest.failsafeTimeout) {
|
|
|
|
syncRequest.failsafeTimeout = new QTimer(this);
|
2014-04-03 08:54:56 +00:00
|
|
|
connect(syncRequest.failsafeTimeout, &QTimer::timeout, this,
|
|
|
|
[this]() {
|
|
|
|
// client does not respond to XSYNC requests in reasonable time, remove support
|
|
|
|
if (!ready_for_painting) {
|
|
|
|
// failed on initial pre-show request
|
|
|
|
setReadyForPainting();
|
2015-07-09 07:10:33 +00:00
|
|
|
setupWindowManagementInterface();
|
2014-04-03 08:54:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// failed during resize
|
|
|
|
syncRequest.isPending = false;
|
|
|
|
syncRequest.counter = syncRequest.alarm = XCB_NONE;
|
|
|
|
delete syncRequest.timeout; delete syncRequest.failsafeTimeout;
|
|
|
|
syncRequest.timeout = syncRequest.failsafeTimeout = nullptr;
|
2014-04-24 09:00:48 +00:00
|
|
|
syncRequest.lastTimestamp = XCB_CURRENT_TIME;
|
2014-04-03 08:54:56 +00:00
|
|
|
}
|
|
|
|
);
|
2011-08-13 14:39:58 +00:00
|
|
|
syncRequest.failsafeTimeout->setSingleShot(true);
|
|
|
|
}
|
|
|
|
// if there's no response within 10 seconds, sth. went wrong and we remove XSYNC support from this client.
|
2019-09-24 08:48:08 +00:00
|
|
|
// see events.cpp X11Client::syncEvent()
|
2011-08-13 14:39:58 +00:00
|
|
|
syncRequest.failsafeTimeout->start(ready_for_painting ? 10000 : 1000);
|
2007-06-25 08:51:44 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// We increment before the notify so that after the notify
|
2007-06-25 08:51:44 +00:00
|
|
|
// syncCounterSerial will equal the value we are expecting
|
|
|
|
// in the acknowledgement
|
2013-07-31 08:11:39 +00:00
|
|
|
const uint32_t oldLo = syncRequest.value.lo;
|
|
|
|
syncRequest.value.lo++;;
|
|
|
|
if (oldLo > syncRequest.value.lo) {
|
|
|
|
syncRequest.value.hi++;
|
|
|
|
}
|
2014-04-24 09:00:48 +00:00
|
|
|
if (syncRequest.lastTimestamp >= xTime()) {
|
|
|
|
updateXTime();
|
|
|
|
}
|
2007-06-25 08:51:44 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
// Send the message to client
|
2014-04-28 12:59:12 +00:00
|
|
|
sendClientMessage(window(), atoms->wm_protocols, atoms->net_wm_sync_request, syncRequest.value.lo, syncRequest.value.hi);
|
2011-08-13 14:39:58 +00:00
|
|
|
syncRequest.isPending = true;
|
2014-04-24 09:00:48 +00:00
|
|
|
syncRequest.lastTimestamp = xTime();
|
2007-06-25 08:51:44 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::wantsInput() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-12-07 15:18:30 +00:00
|
|
|
return rules()->checkAcceptFocus(acceptsFocus() || info->supportsProtocol(NET::TakeFocusProtocol));
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::acceptsFocus() const
|
2015-12-07 15:18:30 +00:00
|
|
|
{
|
|
|
|
return info->input();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setBlockingCompositing(bool block)
|
2012-03-31 17:09:00 +00:00
|
|
|
{
|
|
|
|
const bool usedToBlock = blocks_compositing;
|
2016-08-26 06:56:42 +00:00
|
|
|
blocks_compositing = rules()->checkBlockCompositing(block && options->windowsBlockCompositing());
|
2012-08-23 11:42:59 +00:00
|
|
|
if (usedToBlock != blocks_compositing) {
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
emit blockingCompositingChanged(blocks_compositing ? this : nullptr);
|
2012-03-31 17:09:00 +00:00
|
|
|
}
|
2011-03-20 14:42:05 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateAllowedActions(bool force)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!isManaged() && !force)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2014-02-03 08:37:08 +00:00
|
|
|
NET::Actions old_allowed_actions = NET::Actions(allowed_actions);
|
2019-09-19 15:16:14 +00:00
|
|
|
allowed_actions = NET::Actions();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMovable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionMove;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isResizable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionResize;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMinimizable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionMinimize;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isShadeable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionShade;
|
2008-12-18 13:50:57 +00:00
|
|
|
// Sticky state not supported
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMaximizable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionMax;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (userCanSetFullScreen())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionFullScreen;
|
2008-12-18 13:50:57 +00:00
|
|
|
allowed_actions |= NET::ActionChangeDesktop; // Always (Pagers shouldn't show Docks etc.)
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isCloseable())
|
2007-04-29 17:35:43 +00:00
|
|
|
allowed_actions |= NET::ActionClose;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old_allowed_actions == allowed_actions)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2008-12-18 13:50:57 +00:00
|
|
|
// TODO: This could be delayed and compressed - It's only for pagers etc. anyway
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setAllowedActions(allowed_actions);
|
2011-04-23 15:17:25 +00:00
|
|
|
|
|
|
|
// ONLY if relevant features have changed (and the window didn't just get/loose moveresize for maximization state changes)
|
2014-02-03 08:37:08 +00:00
|
|
|
const NET::Actions relevant = ~(NET::ActionMove|NET::ActionResize);
|
2014-07-25 12:01:47 +00:00
|
|
|
if ((allowed_actions & relevant) != (old_allowed_actions & relevant)) {
|
|
|
|
if ((allowed_actions & NET::ActionMinimize) != (old_allowed_actions & NET::ActionMinimize)) {
|
|
|
|
emit minimizeableChanged(allowed_actions & NET::ActionMinimize);
|
|
|
|
}
|
|
|
|
if ((allowed_actions & NET::ActionShade) != (old_allowed_actions & NET::ActionShade)) {
|
|
|
|
emit shadeableChanged(allowed_actions & NET::ActionShade);
|
|
|
|
}
|
|
|
|
if ((allowed_actions & NET::ActionMax) != (old_allowed_actions & NET::ActionMax)) {
|
|
|
|
emit maximizeableChanged(allowed_actions & NET::ActionMax);
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::debug(QDebug& stream) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2018-09-16 20:45:17 +00:00
|
|
|
stream.nospace();
|
2013-02-14 14:19:35 +00:00
|
|
|
print<QDebug>(stream);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
Xcb::StringProperty X11Client::fetchActivities() const
|
2015-01-15 15:31:20 +00:00
|
|
|
{
|
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
|
|
|
return Xcb::StringProperty(window(), atoms->activities);
|
|
|
|
#else
|
|
|
|
return Xcb::StringProperty();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::readActivities(Xcb::StringProperty &property)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-04-04 14:14:12 +00:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
2010-09-24 12:03:22 +00:00
|
|
|
QStringList newActivitiesList;
|
2015-02-15 16:00:27 +00:00
|
|
|
QString prop = QString::fromUtf8(property);
|
2010-12-16 20:14:22 +00:00
|
|
|
activitiesDefined = !prop.isEmpty();
|
2015-02-15 16:00:27 +00:00
|
|
|
|
|
|
|
if (prop == Activities::nullUuid()) {
|
2010-12-16 20:14:22 +00:00
|
|
|
//copied from setOnAllActivities to avoid a redundant XChangeProperty.
|
|
|
|
if (!activityList.isEmpty()) {
|
|
|
|
activityList.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
updateActivities(true);
|
2010-12-16 20:14:22 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (prop.isEmpty()) {
|
|
|
|
//note: this makes it *act* like it's on all activities but doesn't set the property to 'ALL'
|
|
|
|
if (!activityList.isEmpty()) {
|
|
|
|
activityList.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
updateActivities(true);
|
2010-12-16 20:14:22 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2010-09-24 12:03:22 +00:00
|
|
|
|
2015-11-05 14:14:06 +00:00
|
|
|
newActivitiesList = prop.split(u',');
|
2013-03-02 21:27:20 +00:00
|
|
|
|
2010-09-24 12:03:22 +00:00
|
|
|
if (newActivitiesList == activityList)
|
|
|
|
return; //expected change, it's ok.
|
|
|
|
|
2015-02-15 16:00:27 +00:00
|
|
|
//otherwise, somebody else changed it. we need to validate before reacting.
|
|
|
|
//if the activities are not synced, and there are existing clients with
|
|
|
|
//activities specified, somebody has restarted kwin. we can not validate
|
|
|
|
//activities in this case. we need to trust the old values.
|
2015-07-07 09:48:42 +00:00
|
|
|
if (Activities::self() && Activities::self()->serviceStatus() != KActivities::Consumer::Unknown) {
|
2015-02-15 16:00:27 +00:00
|
|
|
QStringList allActivities = Activities::self()->all();
|
|
|
|
if (allActivities.isEmpty()) {
|
|
|
|
qCDebug(KWIN_CORE) << "no activities!?!?";
|
|
|
|
//don't touch anything, there's probably something bad going on and we don't wanna make it worse
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < newActivitiesList.size(); ++i) {
|
|
|
|
if (! allActivities.contains(newActivitiesList.at(i))) {
|
|
|
|
qCDebug(KWIN_CORE) << "invalid:" << newActivitiesList.at(i);
|
|
|
|
newActivitiesList.removeAt(i--);
|
|
|
|
}
|
2010-09-24 12:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
setOnActivities(newActivitiesList);
|
2015-01-15 15:31:20 +00:00
|
|
|
#else
|
|
|
|
Q_UNUSED(property)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::checkActivities()
|
2015-01-15 15:31:20 +00:00
|
|
|
{
|
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
|
|
|
Xcb::StringProperty property = fetchActivities();
|
|
|
|
readActivities(property);
|
2013-04-04 14:14:12 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-09-24 12:03:22 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setSessionActivityOverride(bool needed)
|
2010-12-16 20:14:22 +00:00
|
|
|
{
|
2017-04-27 10:18:41 +00:00
|
|
|
sessionActivityOverride = needed;
|
|
|
|
updateActivities(false);
|
2010-12-16 20:14:22 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
QRect X11Client::decorationRect() const
|
2011-04-10 19:24:27 +00:00
|
|
|
{
|
2014-07-22 11:11:19 +00:00
|
|
|
return QRect(0, 0, width(), height());
|
2011-04-10 19:24:27 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
Xcb::Property X11Client::fetchFirstInTabBox() const
|
2015-01-15 15:14:28 +00:00
|
|
|
{
|
|
|
|
return Xcb::Property(false, m_client, atoms->kde_first_in_window_list,
|
|
|
|
atoms->kde_first_in_window_list, 0, 1);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::readFirstInTabBox(Xcb::Property &property)
|
2015-01-15 15:14:28 +00:00
|
|
|
{
|
|
|
|
setFirstInTabBox(property.toBool(32, atoms->kde_first_in_window_list));
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateFirstInTabBox()
|
2011-12-01 12:15:11 +00:00
|
|
|
{
|
|
|
|
// TODO: move into KWindowInfo
|
2015-01-15 15:14:28 +00:00
|
|
|
Xcb::Property property = fetchFirstInTabBox();
|
|
|
|
readFirstInTabBox(property);
|
2011-12-01 12:15:11 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
Xcb::StringProperty X11Client::fetchColorScheme() const
|
2013-10-14 05:17:07 +00:00
|
|
|
{
|
2015-01-15 15:09:05 +00:00
|
|
|
return Xcb::StringProperty(m_client, atoms->kde_color_sheme);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::readColorScheme(Xcb::StringProperty &property)
|
2015-01-15 15:09:05 +00:00
|
|
|
{
|
2015-04-29 10:02:54 +00:00
|
|
|
AbstractClient::updateColorScheme(rules()->checkDecoColor(QString::fromUtf8(property)));
|
2013-10-14 05:17:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateColorScheme()
|
2015-01-15 15:09:05 +00:00
|
|
|
{
|
|
|
|
Xcb::StringProperty property = fetchColorScheme();
|
|
|
|
readColorScheme(property);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::isClient() const
|
2012-01-15 09:51:09 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
NET::WindowType X11Client::windowType(bool direct, int supportedTypes) const
|
2012-09-06 07:09:31 +00:00
|
|
|
{
|
|
|
|
// TODO: does it make sense to cache the returned window type for SUPPORTED_MANAGED_WINDOW_TYPES_MASK?
|
|
|
|
if (supportedTypes == 0) {
|
|
|
|
supportedTypes = SUPPORTED_MANAGED_WINDOW_TYPES_MASK;
|
|
|
|
}
|
2014-02-03 08:37:08 +00:00
|
|
|
NET::WindowType wt = info->windowType(NET::WindowTypes(supportedTypes));
|
2012-09-06 07:09:31 +00:00
|
|
|
if (direct) {
|
|
|
|
return wt;
|
|
|
|
}
|
2017-10-01 14:38:57 +00:00
|
|
|
NET::WindowType wt2 = rules()->checkType(wt);
|
2012-09-06 07:09:31 +00:00
|
|
|
if (wt != wt2) {
|
|
|
|
wt = wt2;
|
|
|
|
info->setWindowType(wt); // force hint change
|
|
|
|
}
|
|
|
|
// hacks here
|
|
|
|
if (wt == NET::Unknown) // this is more or less suggested in NETWM spec
|
|
|
|
wt = isTransient() ? NET::Dialog : NET::Normal;
|
|
|
|
return wt;
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::cancelFocusOutTimer()
|
2013-08-05 07:48:14 +00:00
|
|
|
{
|
|
|
|
if (m_focusOutTimer) {
|
|
|
|
m_focusOutTimer->stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
xcb_window_t X11Client::frameId() const
|
2013-09-10 06:13:33 +00:00
|
|
|
{
|
|
|
|
return m_frame;
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
Xcb::Property X11Client::fetchShowOnScreenEdge() const
|
2015-01-15 14:51:21 +00:00
|
|
|
{
|
|
|
|
return Xcb::Property(false, window(), atoms->kde_screen_edge_show, XCB_ATOM_CARDINAL, 0, 1);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::readShowOnScreenEdge(Xcb::Property &property)
|
2014-02-20 11:39:23 +00:00
|
|
|
{
|
2015-10-11 20:48:29 +00:00
|
|
|
//value comes in two parts, edge in the lower byte
|
|
|
|
//then the type in the upper byte
|
|
|
|
// 0 = autohide
|
|
|
|
// 1 = raise in front on activate
|
|
|
|
|
2014-04-15 08:09:25 +00:00
|
|
|
const uint32_t value = property.value<uint32_t>(ElectricNone);
|
|
|
|
ElectricBorder border = ElectricNone;
|
2015-10-11 20:48:29 +00:00
|
|
|
switch (value & 0xFF) {
|
2014-04-15 08:09:25 +00:00
|
|
|
case 0:
|
|
|
|
border = ElectricTop;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
border = ElectricRight;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
border = ElectricBottom;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
border = ElectricLeft;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (border != ElectricNone) {
|
2015-10-11 20:48:29 +00:00
|
|
|
disconnect(m_edgeRemoveConnection);
|
2017-03-08 22:54:58 +00:00
|
|
|
disconnect(m_edgeGeometryTrackingConnection);
|
2015-10-11 20:48:29 +00:00
|
|
|
bool successfullyHidden = false;
|
|
|
|
|
|
|
|
if (((value >> 8) & 0xFF) == 1) {
|
|
|
|
setKeepBelow(true);
|
|
|
|
successfullyHidden = keepBelow(); //request could have failed due to user kwin rules
|
|
|
|
|
|
|
|
m_edgeRemoveConnection = connect(this, &AbstractClient::keepBelowChanged, this, [this](){
|
|
|
|
if (!keepBelow()) {
|
|
|
|
ScreenEdges::self()->reserve(this, ElectricNone);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
hideClient(true);
|
|
|
|
successfullyHidden = isHiddenInternal();
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
m_edgeGeometryTrackingConnection = connect(this, &X11Client::geometryChanged, this, [this, border](){
|
2017-03-08 22:54:58 +00:00
|
|
|
hideClient(true);
|
|
|
|
ScreenEdges::self()->reserve(this, border);
|
2015-10-11 20:48:29 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (successfullyHidden) {
|
|
|
|
ScreenEdges::self()->reserve(this, border);
|
|
|
|
} else {
|
|
|
|
ScreenEdges::self()->reserve(this, ElectricNone);
|
|
|
|
}
|
2014-04-15 08:09:25 +00:00
|
|
|
} else if (!property.isNull() && property->type != XCB_ATOM_NONE) {
|
|
|
|
// property value is incorrect, delete the property
|
|
|
|
// so that the client knows that it is not hidden
|
|
|
|
xcb_delete_property(connection(), window(), atoms->kde_screen_edge_show);
|
|
|
|
} else {
|
|
|
|
// restore
|
2014-02-20 11:39:23 +00:00
|
|
|
// TODO: add proper unreserve
|
2015-10-11 20:48:29 +00:00
|
|
|
|
|
|
|
//this will call showOnScreenEdge to reset the state
|
2017-03-08 22:54:58 +00:00
|
|
|
disconnect(m_edgeGeometryTrackingConnection);
|
2014-02-20 11:39:23 +00:00
|
|
|
ScreenEdges::self()->reserve(this, ElectricNone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateShowOnScreenEdge()
|
2015-01-15 14:51:21 +00:00
|
|
|
{
|
|
|
|
Xcb::Property property = fetchShowOnScreenEdge();
|
|
|
|
readShowOnScreenEdge(property);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::showOnScreenEdge()
|
2014-02-20 11:39:23 +00:00
|
|
|
{
|
2015-10-11 20:48:29 +00:00
|
|
|
disconnect(m_edgeRemoveConnection);
|
|
|
|
|
2014-02-20 11:39:23 +00:00
|
|
|
hideClient(false);
|
2015-10-11 20:48:29 +00:00
|
|
|
setKeepBelow(false);
|
2014-02-20 11:39:23 +00:00
|
|
|
xcb_delete_property(connection(), window(), atoms->kde_screen_edge_show);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::addDamage(const QRegion &damage)
|
2015-02-24 09:54:28 +00:00
|
|
|
{
|
|
|
|
if (!ready_for_painting) { // avoid "setReadyForPainting()" function calling overhead
|
2015-07-09 07:10:33 +00:00
|
|
|
if (syncRequest.counter == XCB_NONE) { // cannot detect complete redraw, consider done now
|
2015-02-24 09:54:28 +00:00
|
|
|
setReadyForPainting();
|
2015-07-09 07:10:33 +00:00
|
|
|
setupWindowManagementInterface();
|
|
|
|
}
|
2015-02-24 09:54:28 +00:00
|
|
|
}
|
2016-03-04 15:33:09 +00:00
|
|
|
repaints_region += damage;
|
2015-02-24 09:54:28 +00:00
|
|
|
Toplevel::addDamage(damage);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const
|
2015-03-05 09:21:03 +00:00
|
|
|
{
|
2019-09-24 08:48:08 +00:00
|
|
|
const X11Client *c2 = dynamic_cast<const X11Client *>(other);
|
2015-03-05 09:21:03 +00:00
|
|
|
if (!c2) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-24 08:48:08 +00:00
|
|
|
return X11Client::belongToSameApplication(this, c2, checks);
|
2015-03-05 09:21:03 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
QSize X11Client::resizeIncrements() const
|
2015-10-26 14:49:03 +00:00
|
|
|
{
|
|
|
|
return m_geometryHints.resizeIncrements();
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
Xcb::StringProperty X11Client::fetchApplicationMenuServiceName() const
|
2017-01-11 09:21:03 +00:00
|
|
|
{
|
|
|
|
return Xcb::StringProperty(m_client, atoms->kde_net_wm_appmenu_service_name);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::readApplicationMenuServiceName(Xcb::StringProperty &property)
|
2017-01-11 09:21:03 +00:00
|
|
|
{
|
|
|
|
updateApplicationMenuServiceName(QString::fromUtf8(property));
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::checkApplicationMenuServiceName()
|
2017-01-11 09:21:03 +00:00
|
|
|
{
|
|
|
|
Xcb::StringProperty property = fetchApplicationMenuServiceName();
|
|
|
|
readApplicationMenuServiceName(property);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
Xcb::StringProperty X11Client::fetchApplicationMenuObjectPath() const
|
2017-01-11 09:21:03 +00:00
|
|
|
{
|
|
|
|
return Xcb::StringProperty(m_client, atoms->kde_net_wm_appmenu_object_path);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::readApplicationMenuObjectPath(Xcb::StringProperty &property)
|
2017-01-11 09:21:03 +00:00
|
|
|
{
|
|
|
|
updateApplicationMenuObjectPath(QString::fromUtf8(property));
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::checkApplicationMenuObjectPath()
|
2017-01-11 09:21:03 +00:00
|
|
|
{
|
|
|
|
Xcb::StringProperty property = fetchApplicationMenuObjectPath();
|
|
|
|
readApplicationMenuObjectPath(property);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::handleSync()
|
2017-09-22 18:35:50 +00:00
|
|
|
{
|
|
|
|
setReadyForPainting();
|
|
|
|
setupWindowManagementInterface();
|
|
|
|
syncRequest.isPending = false;
|
|
|
|
if (syncRequest.failsafeTimeout)
|
|
|
|
syncRequest.failsafeTimeout->stop();
|
|
|
|
if (isResize()) {
|
|
|
|
if (syncRequest.timeout)
|
|
|
|
syncRequest.timeout->stop();
|
|
|
|
performMoveResize();
|
|
|
|
} else // setReadyForPainting does as well, but there's a small chance for resize syncs after the resize ended
|
|
|
|
addRepaintFull();
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|