File indexing completed on 2024-04-28 16:48:52

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
0006     SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
0007     SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 #include "killwindow.h"
0012 #include "main.h"
0013 #include "osd.h"
0014 #include "unmanaged.h"
0015 #include "window.h"
0016 
0017 #include <KLocalizedString>
0018 
0019 namespace KWin
0020 {
0021 
0022 KillWindow::KillWindow()
0023 {
0024 }
0025 
0026 KillWindow::~KillWindow()
0027 {
0028 }
0029 
0030 void KillWindow::start()
0031 {
0032     OSD::show(i18n("Select window to force close with left click or enter.\nEscape or right click to cancel."),
0033               QStringLiteral("window-close"));
0034     kwinApp()->startInteractiveWindowSelection(
0035         [](KWin::Window *t) {
0036             OSD::hide();
0037             if (!t) {
0038                 return;
0039             }
0040             if (Window *c = static_cast<Window *>(t->isClient() ? t : nullptr)) {
0041                 c->killWindow();
0042             } else if (Unmanaged *u = qobject_cast<Unmanaged *>(t)) {
0043                 xcb_kill_client(kwinApp()->x11Connection(), u->window());
0044             }
0045         },
0046         QByteArrayLiteral("pirate"));
0047 }
0048 
0049 } // namespace