2020-08-02 22:22:19 +00:00
/*
KWin - the KDE window manager
This file is part of the KDE project .
2007-04-29 17:35:43 +00:00
2020-08-02 22:22:19 +00:00
SPDX - FileCopyrightText : 1999 , 2000 Matthias Ettrich < ettrich @ kde . org >
SPDX - FileCopyrightText : 2003 Lubos Lunak < l . lunak @ kde . org >
2007-04-29 17:35:43 +00:00
2020-08-02 22:22:19 +00:00
SPDX - License - Identifier : GPL - 2.0 - or - later
*/
2007-04-29 17:35:43 +00:00
/*
This file contains things relevant to direct user actions , such as
responses to global keyboard shortcuts , or selecting actions
from the window operations menu .
*/
2012-03-23 07:03:09 +00:00
///////////////////////////////////////////////////////////////////////////////
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
// NOTE: if you change the menu, keep
// plasma-desktop/applets/taskmanager/package/contents/ui/ContextMenu.qml
// in sync
2012-03-23 07:03:09 +00:00
//////////////////////////////////////////////////////////////////////////////
2012-08-19 10:00:53 +00:00
# include "useractions.h"
2021-08-28 14:51:00 +00:00
# include "abstract_output.h"
2013-02-26 07:45:44 +00:00
# include "cursor.h"
2019-09-24 08:48:08 +00:00
# include "x11client.h"
2017-09-24 08:15:13 +00:00
# include "composite.h"
2013-07-10 09:45:51 +00:00
# include "input.h"
2007-04-29 17:35:43 +00:00
# include "workspace.h"
# include "effects.h"
2017-07-20 17:14:07 +00:00
# include "platform.h"
2013-04-03 10:19:27 +00:00
# include "screens.h"
2012-11-16 07:23:47 +00:00
# include "virtualdesktops.h"
2012-08-31 11:28:31 +00:00
# include "scripting/scripting.h"
2012-02-26 10:38:16 +00:00
# ifdef KWIN_BUILD_ACTIVITIES
2013-04-04 14:14:12 +00:00
# include "activities.h"
2014-02-04 08:36:15 +00:00
# include <kactivities/info.h>
2012-02-26 10:38:16 +00:00
# endif
2017-01-11 09:21:03 +00:00
# include "appmenu.h"
2010-05-11 20:30:20 +00:00
2014-03-17 15:24:10 +00:00
# include <KProcess>
2012-08-19 10:00:53 +00:00
2013-08-28 10:27:09 +00:00
# include <QAction>
2013-03-24 20:57:26 +00:00
# include <QCheckBox>
2013-08-19 09:42:16 +00:00
# include <QtConcurrentRun>
2007-04-29 17:35:43 +00:00
# include <QPushButton>
2014-03-17 15:24:10 +00:00
# include <KGlobalAccel>
# include <KLocalizedString>
2007-04-29 17:35:43 +00:00
# include <kconfig.h>
# include <QMenu>
2021-06-20 10:56:24 +00:00
# include <QRegularExpression>
2021-12-04 16:07:01 +00:00
# include <QAction>
2007-04-29 17:35:43 +00:00
# include <kauthorized.h>
# include "killwindow.h"
2011-06-30 11:02:30 +00:00
# ifdef KWIN_BUILD_TABBOX
2007-04-29 17:35:43 +00:00
# include "tabbox.h"
2011-06-30 11:02:30 +00:00
# endif
2007-04-29 17:35:43 +00:00
namespace KWin
{
2012-08-19 10:00:53 +00:00
UserActionsMenu : : UserActionsMenu ( QObject * parent )
: QObject ( parent )
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
, m_menu ( nullptr )
, m_desktopMenu ( nullptr )
2020-11-19 03:05:39 +00:00
, m_multipleDesktopsMenu ( nullptr )
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
, m_screenMenu ( nullptr )
, m_activityMenu ( nullptr )
, m_scriptsMenu ( nullptr )
, m_resizeOperation ( nullptr )
, m_moveOperation ( nullptr )
, m_maximizeOperation ( nullptr )
, m_shadeOperation ( nullptr )
, m_keepAboveOperation ( nullptr )
, m_keepBelowOperation ( nullptr )
, m_fullScreenOperation ( nullptr )
, m_noBorderOperation ( nullptr )
, m_minimizeOperation ( nullptr )
, m_closeOperation ( nullptr )
2020-11-19 03:05:39 +00:00
, m_shortcutOperation ( nullptr )
2012-08-19 10:00:53 +00:00
{
}
2007-04-29 17:35:43 +00:00
2012-08-19 10:00:53 +00:00
UserActionsMenu : : ~ UserActionsMenu ( )
2011-01-30 14:34:42 +00:00
{
2012-08-19 10:00:53 +00:00
discard ( ) ;
}
2007-04-29 17:35:43 +00:00
2012-08-19 10:00:53 +00:00
bool UserActionsMenu : : isShown ( ) const
{
return m_menu & & m_menu - > isVisible ( ) ;
}
2007-04-29 17:35:43 +00:00
2012-08-19 10:00:53 +00:00
bool UserActionsMenu : : hasClient ( ) const
{
2019-08-11 18:25:58 +00:00
return m_client & & isShown ( ) ;
2012-08-19 10:00:53 +00:00
}
2012-03-23 07:03:09 +00:00
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : close ( )
{
if ( ! m_menu ) {
return ;
}
m_menu - > close ( ) ;
2012-12-20 20:26:33 +00:00
m_client . clear ( ) ;
2012-08-19 10:00:53 +00:00
}
2012-03-23 07:03:09 +00:00
2015-03-06 10:33:51 +00:00
bool UserActionsMenu : : isMenuClient ( const AbstractClient * c ) const
2012-08-19 10:00:53 +00:00
{
2019-08-11 18:25:58 +00:00
return c & & c = = m_client ;
2012-08-19 10:00:53 +00:00
}
2011-01-30 14:34:42 +00:00
2019-08-10 07:57:32 +00:00
void UserActionsMenu : : show ( const QRect & pos , AbstractClient * client )
2012-08-19 10:00:53 +00:00
{
2019-08-11 18:25:58 +00:00
Q_ASSERT ( client ) ;
2019-08-10 07:57:32 +00:00
QPointer < AbstractClient > cl ( client ) ;
2019-08-11 18:25:58 +00:00
// Presumably client will never be nullptr,
// but play it safe and make sure not to crash.
if ( cl . isNull ( ) ) {
2012-08-19 10:00:53 +00:00
return ;
2019-08-11 18:25:58 +00:00
}
if ( isShown ( ) ) { // recursion
2012-08-19 10:00:53 +00:00
return ;
2019-08-11 18:25:58 +00:00
}
if ( cl - > isDesktop ( ) | | cl - > isDock ( ) ) {
2012-08-19 10:00:53 +00:00
return ;
2019-08-11 18:25:58 +00:00
}
if ( ! KAuthorized : : authorizeAction ( QStringLiteral ( " kwin_rmb " ) ) ) {
2012-08-19 10:00:53 +00:00
return ;
2019-08-11 18:25:58 +00:00
}
2012-08-19 10:00:53 +00:00
m_client = cl ;
init ( ) ;
2019-08-11 20:15:38 +00:00
m_client - > blockActivityUpdates ( true ) ;
2019-08-13 06:37:25 +00:00
if ( kwinApp ( ) - > shouldUseWaylandForCompositing ( ) ) {
2019-08-13 19:41:19 +00:00
m_menu - > popup ( pos . bottomLeft ( ) ) ;
2019-08-13 06:37:25 +00:00
} else {
2019-08-13 19:41:19 +00:00
m_menu - > exec ( pos . bottomLeft ( ) ) ;
2019-08-13 06:37:25 +00:00
}
2019-08-11 20:15:38 +00:00
if ( m_client ) {
m_client - > blockActivityUpdates ( false ) ;
2012-08-19 10:00:53 +00:00
}
}
2011-01-30 14:34:42 +00:00
2015-09-22 12:44:25 +00:00
void UserActionsMenu : : grabInput ( )
{
m_menu - > windowHandle ( ) - > setMouseGrabEnabled ( true ) ;
m_menu - > windowHandle ( ) - > setKeyboardGrabEnabled ( true ) ;
}
2019-08-10 07:57:32 +00:00
void UserActionsMenu : : helperDialog ( const QString & message , AbstractClient * client )
2012-08-19 10:00:53 +00:00
{
QStringList args ;
QString type ;
2013-08-19 09:42:16 +00:00
auto shortcut = [ ] ( const QString & name ) {
2013-12-10 09:01:13 +00:00
QAction * action = Workspace : : self ( ) - > findChild < QAction * > ( name ) ;
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
Q_ASSERT ( action ! = nullptr ) ;
2013-08-19 09:42:16 +00:00
const auto shortcuts = KGlobalAccel : : self ( ) - > shortcut ( action ) ;
2021-08-22 13:15:16 +00:00
return QStringLiteral ( " %1 (%2) " ).arg(action->text(), shortcuts.isEmpty() ? QString() : shortcuts.first().toString(QKeySequence::NativeText)) ;
2013-08-19 09:42:16 +00:00
} ;
if ( message = = QStringLiteral ( " noborderaltf3 " ) ) {
2013-07-23 05:02:52 +00:00
args < < QStringLiteral ( " --msgbox " ) < < i18n (
2012-08-19 10:00:53 +00:00
" You have selected to show a window without its border. \n "
" Without the border, you will not be able to enable the border "
" again using the mouse: use the window operations menu instead, "
" activated using the %1 keyboard shortcut. " ,
2013-08-19 09:42:16 +00:00
shortcut ( QStringLiteral ( " Window Operations Menu " ) ) ) ;
2013-07-23 05:02:52 +00:00
type = QStringLiteral ( " altf3warning " ) ;
2015-11-05 14:14:06 +00:00
} else if ( message = = QLatin1String ( " fullscreenaltf3 " ) ) {
2013-07-23 05:02:52 +00:00
args < < QStringLiteral ( " --msgbox " ) < < i18n (
2012-08-19 10:00:53 +00:00
" You have selected to show a window in fullscreen mode. \n "
" If the application itself does not have an option to turn the fullscreen "
" mode off you will not be able to disable it "
" again using the mouse: use the window operations menu instead, "
" activated using the %1 keyboard shortcut. " ,
2013-08-19 09:42:16 +00:00
shortcut ( QStringLiteral ( " Window Operations Menu " ) ) ) ;
2013-07-23 05:02:52 +00:00
type = QStringLiteral ( " altf3warning " ) ;
2022-01-04 08:28:42 +00:00
} else {
Q_UNREACHABLE ( ) ;
}
2012-08-19 10:00:53 +00:00
if ( ! type . isEmpty ( ) ) {
2013-07-23 05:02:52 +00:00
KConfig cfg ( QStringLiteral ( " kwin_dialogsrc " ) ) ;
2012-08-19 10:00:53 +00:00
KConfigGroup cg ( & cfg , " Notification Messages " ) ; // Depends on KMessageBox
if ( ! cg . readEntry ( type , true ) )
return ;
2015-11-05 14:14:06 +00:00
args < < QStringLiteral ( " --dontagain " ) < < QLatin1String ( " kwin_dialogsrc: " ) + type ;
2012-08-19 10:00:53 +00:00
}
2019-08-10 07:57:32 +00:00
if ( client )
2020-11-04 15:49:10 +00:00
args < < QStringLiteral ( " --embed " ) < < QString : : number ( client - > window ( ) ) ;
2013-08-19 09:42:16 +00:00
QtConcurrent : : run ( [ args ] ( ) {
KProcess : : startDetached ( QStringLiteral ( " kdialog " ) , args ) ;
} ) ;
2012-08-19 10:00:53 +00:00
}
2012-03-23 07:03:09 +00:00
2011-01-30 14:34:42 +00:00
2012-08-19 10:00:53 +00:00
QStringList configModules ( bool controlCenter )
{
QStringList args ;
2013-07-23 05:02:52 +00:00
args < < QStringLiteral ( " kwindecoration " ) ;
2012-08-19 10:00:53 +00:00
if ( controlCenter )
2013-07-23 05:02:52 +00:00
args < < QStringLiteral ( " kwinoptions " ) ;
else if ( KAuthorized : : authorizeControlModule ( QStringLiteral ( " kde-kwinoptions.desktop " ) ) )
args < < QStringLiteral ( " kwinactions " ) < < QStringLiteral ( " kwinfocus " ) < < QStringLiteral ( " kwinmoving " ) < < QStringLiteral ( " kwinadvanced " )
2014-03-10 13:55:04 +00:00
< < QStringLiteral ( " kwinrules " ) < < QStringLiteral ( " kwincompositing " ) < < QStringLiteral ( " kwineffects " )
2012-08-19 10:00:53 +00:00
# ifdef KWIN_BUILD_TABBOX
2013-07-23 05:02:52 +00:00
< < QStringLiteral ( " kwintabbox " )
2012-08-19 10:00:53 +00:00
# endif
2013-07-23 05:02:52 +00:00
< < QStringLiteral ( " kwinscreenedges " )
< < QStringLiteral ( " kwinscripts " )
2012-08-19 10:00:53 +00:00
;
return args ;
}
2012-03-23 07:03:09 +00:00
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : init ( )
{
if ( m_menu ) {
return ;
}
m_menu = new QMenu ;
2014-03-27 15:48:25 +00:00
connect ( m_menu , & QMenu : : aboutToShow , this , & UserActionsMenu : : menuAboutToShow ) ;
connect ( m_menu , & QMenu : : triggered , this , & UserActionsMenu : : slotWindowOperation , Qt : : QueuedConnection ) ;
2012-08-19 10:00:53 +00:00
QMenu * advancedMenu = new QMenu ( m_menu ) ;
2021-08-22 12:51:36 +00:00
connect ( advancedMenu , & QMenu : : aboutToShow , this , [ this , advancedMenu ] ( ) {
2019-08-11 18:25:58 +00:00
if ( m_client ) {
advancedMenu - > setPalette ( m_client - > palette ( ) ) ;
}
2013-10-14 05:25:27 +00:00
} ) ;
2012-08-19 10:00:53 +00:00
2013-09-06 12:56:16 +00:00
auto setShortcut = [ ] ( QAction * action , const QString & actionName ) {
2013-12-10 09:01:13 +00:00
const auto shortcuts = KGlobalAccel : : self ( ) - > shortcut ( Workspace : : self ( ) - > findChild < QAction * > ( actionName ) ) ;
2013-09-06 12:56:16 +00:00
if ( ! shortcuts . isEmpty ( ) ) {
action - > setShortcut ( shortcuts . first ( ) ) ;
}
} ;
2012-08-19 10:00:53 +00:00
m_moveOperation = advancedMenu - > addAction ( i18n ( " &Move " ) ) ;
2013-09-06 13:12:35 +00:00
m_moveOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " transform-move " ) ) ) ;
2013-09-06 12:56:16 +00:00
setShortcut ( m_moveOperation , QStringLiteral ( " Window Move " ) ) ;
2012-08-19 10:00:53 +00:00
m_moveOperation - > setData ( Options : : UnrestrictedMoveOp ) ;
2015-09-28 07:28:37 +00:00
m_resizeOperation = advancedMenu - > addAction ( i18n ( " &Resize " ) ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_resizeOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " transform-scale " ) ) ) ;
2013-09-06 12:56:16 +00:00
setShortcut ( m_resizeOperation , QStringLiteral ( " Window Resize " ) ) ;
2012-08-19 10:00:53 +00:00
m_resizeOperation - > setData ( Options : : ResizeOp ) ;
m_keepAboveOperation = advancedMenu - > addAction ( i18n ( " Keep &Above Others " ) ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_keepAboveOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " window-keep-above " ) ) ) ;
2013-09-06 12:56:16 +00:00
setShortcut ( m_keepAboveOperation , QStringLiteral ( " Window Above Other Windows " ) ) ;
2012-08-19 10:00:53 +00:00
m_keepAboveOperation - > setCheckable ( true ) ;
m_keepAboveOperation - > setData ( Options : : KeepAboveOp ) ;
m_keepBelowOperation = advancedMenu - > addAction ( i18n ( " Keep &Below Others " ) ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_keepBelowOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " window-keep-below " ) ) ) ;
2013-09-06 12:56:16 +00:00
setShortcut ( m_keepBelowOperation , QStringLiteral ( " Window Below Other Windows " ) ) ;
2012-08-19 10:00:53 +00:00
m_keepBelowOperation - > setCheckable ( true ) ;
m_keepBelowOperation - > setData ( Options : : KeepBelowOp ) ;
m_fullScreenOperation = advancedMenu - > addAction ( i18n ( " &Fullscreen " ) ) ;
2013-09-06 13:12:35 +00:00
m_fullScreenOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " view-fullscreen " ) ) ) ;
2013-09-06 12:56:16 +00:00
setShortcut ( m_fullScreenOperation , QStringLiteral ( " Window Fullscreen " ) ) ;
2012-08-19 10:00:53 +00:00
m_fullScreenOperation - > setCheckable ( true ) ;
m_fullScreenOperation - > setData ( Options : : FullScreenOp ) ;
2015-09-28 07:28:37 +00:00
m_shadeOperation = advancedMenu - > addAction ( i18n ( " &Shade " ) ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_shadeOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " window-shade " ) ) ) ;
2013-09-06 12:56:16 +00:00
setShortcut ( m_shadeOperation , QStringLiteral ( " Window Shade " ) ) ;
2012-08-19 10:00:53 +00:00
m_shadeOperation - > setCheckable ( true ) ;
m_shadeOperation - > setData ( Options : : ShadeOp ) ;
m_noBorderOperation = advancedMenu - > addAction ( i18n ( " &No Border " ) ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_noBorderOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " edit-none-border " ) ) ) ;
2013-09-06 12:56:16 +00:00
setShortcut ( m_noBorderOperation , QStringLiteral ( " Window No Border " ) ) ;
2012-08-19 10:00:53 +00:00
m_noBorderOperation - > setCheckable ( true ) ;
m_noBorderOperation - > setData ( Options : : NoBorderOp ) ;
advancedMenu - > addSeparator ( ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_shortcutOperation = advancedMenu - > addAction ( i18n ( " Set Window Short&cut... " ) ) ;
2015-02-06 15:55:44 +00:00
m_shortcutOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " configure-shortcuts " ) ) ) ;
setShortcut ( m_shortcutOperation , QStringLiteral ( " Setup Window Shortcut " ) ) ;
m_shortcutOperation - > setData ( Options : : SetupWindowShortcutOp ) ;
2012-08-19 10:00:53 +00:00
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
QAction * action = advancedMenu - > addAction ( i18n ( " Configure Special &Window Settings... " ) ) ;
2013-09-06 13:12:35 +00:00
action - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " preferences-system-windows-actions " ) ) ) ;
2012-08-19 10:00:53 +00:00
action - > setData ( Options : : WindowRulesOp ) ;
2018-02-16 19:55:06 +00:00
m_rulesOperation = action ;
2012-08-19 10:00:53 +00:00
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
action = advancedMenu - > addAction ( i18n ( " Configure S&pecial Application Settings... " ) ) ;
2013-09-06 13:12:35 +00:00
action - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " preferences-system-windows-actions " ) ) ) ;
2012-08-19 10:00:53 +00:00
action - > setData ( Options : : ApplicationRulesOp ) ;
2018-02-16 19:55:06 +00:00
m_applicationRulesOperation = action ;
2016-01-29 10:24:18 +00:00
if ( ! kwinApp ( ) - > config ( ) - > isImmutable ( ) & &
2012-08-19 10:00:53 +00:00
! KAuthorized : : authorizeControlModules ( configModules ( true ) ) . isEmpty ( ) ) {
advancedMenu - > addSeparator ( ) ;
action = advancedMenu - > addAction ( i18nc ( " Entry in context menu of window decoration to open the configuration module of KWin " ,
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
" Configure W&indow Manager... " ) ) ;
2013-09-06 13:12:35 +00:00
action - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " configure " ) ) ) ;
2014-03-27 15:48:25 +00:00
connect ( action , & QAction : : triggered , this ,
2015-07-07 15:35:57 +00:00
[ this ] ( ) {
2014-03-27 15:48:25 +00:00
// opens the KWin configuration
QStringList args ;
2016-10-26 06:10:04 +00:00
args < < QStringLiteral ( " --icon " ) < < QStringLiteral ( " preferences-system-windows " ) ;
const QString path = QStandardPaths : : locate ( QStandardPaths : : GenericDataLocation ,
QStringLiteral ( " kservices5/kwinfocus.desktop " ) ) ;
if ( ! path . isEmpty ( ) ) {
args < < QStringLiteral ( " --desktopfile " ) < < path ;
}
args < < configModules ( false ) ;
2022-01-10 20:30:37 +00:00
QProcess * p = new QProcess ( this ) ;
2015-07-07 15:35:57 +00:00
p - > setArguments ( args ) ;
p - > setProcessEnvironment ( kwinApp ( ) - > processStartupEnvironment ( ) ) ;
p - > setProgram ( QStringLiteral ( " kcmshell5 " ) ) ;
2015-08-23 18:56:10 +00:00
connect ( p , static_cast < void ( QProcess : : * ) ( int , QProcess : : ExitStatus ) > ( & QProcess : : finished ) , p , & QProcess : : deleteLater ) ;
2020-03-15 19:59:29 +00:00
connect ( p , & QProcess : : errorOccurred , this , [ ] ( QProcess : : ProcessError e ) {
2020-01-25 20:34:15 +00:00
if ( e = = QProcess : : FailedToStart ) {
qCDebug ( KWIN_CORE ) < < " Failed to start kcmshell5 " ;
2015-07-07 15:35:57 +00:00
}
2020-01-25 20:34:15 +00:00
} ) ;
2015-07-07 15:35:57 +00:00
p - > start ( ) ;
2014-03-27 15:48:25 +00:00
}
) ;
2012-08-19 10:00:53 +00:00
}
2011-01-30 14:34:42 +00:00
2012-08-19 10:00:53 +00:00
m_maximizeOperation = m_menu - > addAction ( i18n ( " Ma&ximize " ) ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_maximizeOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " window-maximize " ) ) ) ;
2013-09-06 12:56:16 +00:00
setShortcut ( m_maximizeOperation , QStringLiteral ( " Window Maximize " ) ) ;
2012-08-19 10:00:53 +00:00
m_maximizeOperation - > setCheckable ( true ) ;
m_maximizeOperation - > setData ( Options : : MaximizeOp ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_minimizeOperation = m_menu - > addAction ( i18n ( " Mi&nimize " ) ) ;
m_minimizeOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " window-minimize " ) ) ) ;
setShortcut ( m_minimizeOperation , QStringLiteral ( " Window Minimize " ) ) ;
m_minimizeOperation - > setData ( Options : : MinimizeOp ) ;
2012-08-19 10:00:53 +00:00
action = m_menu - > addMenu ( advancedMenu ) ;
2013-05-15 18:55:49 +00:00
action - > setText ( i18n ( " &More Actions " ) ) ;
2021-08-20 04:25:16 +00:00
action - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " overflow-menu " ) ) ) ;
2008-08-07 11:51:20 +00:00
2012-08-19 10:00:53 +00:00
m_closeOperation = m_menu - > addAction ( i18n ( " &Close " ) ) ;
2013-09-06 13:12:35 +00:00
m_closeOperation - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " window-close " ) ) ) ;
2013-09-06 12:56:16 +00:00
setShortcut ( m_closeOperation , QStringLiteral ( " Window Close " ) ) ;
2012-08-19 10:00:53 +00:00
m_closeOperation - > setData ( Options : : CloseOp ) ;
2011-08-19 19:53:30 +00:00
}
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : discard ( )
2011-08-19 19:53:30 +00:00
{
2012-08-19 10:00:53 +00:00
delete m_menu ;
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
m_menu = nullptr ;
m_desktopMenu = nullptr ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
m_multipleDesktopsMenu = nullptr ;
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
m_screenMenu = nullptr ;
m_activityMenu = nullptr ;
m_scriptsMenu = nullptr ;
2011-08-19 19:53:30 +00:00
}
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : menuAboutToShow ( )
2011-01-30 14:34:42 +00:00
{
2012-08-19 10:00:53 +00:00
if ( m_client . isNull ( ) | | ! m_menu )
2007-04-29 17:35:43 +00:00
return ;
2012-11-16 07:23:47 +00:00
if ( VirtualDesktopManager : : self ( ) - > count ( ) = = 1 ) {
2012-08-19 10:00:53 +00:00
delete m_desktopMenu ;
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
m_desktopMenu = nullptr ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
delete m_multipleDesktopsMenu ;
m_multipleDesktopsMenu = nullptr ;
2011-01-30 14:34:42 +00:00
} else {
2007-04-29 17:35:43 +00:00
initDesktopPopup ( ) ;
2011-01-30 14:34:42 +00:00
}
2019-08-11 18:25:58 +00:00
if ( screens ( ) - > count ( ) = = 1 | | ( ! m_client - > isMovable ( ) & & ! m_client - > isMovableAcrossScreens ( ) ) ) {
2012-08-19 10:00:53 +00:00
delete m_screenMenu ;
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
m_screenMenu = nullptr ;
2012-08-17 20:32:06 +00:00
} else {
initScreenPopup ( ) ;
}
2007-04-29 17:35:43 +00:00
2019-08-11 18:25:58 +00:00
m_menu - > setPalette ( m_client - > palette ( ) ) ;
m_resizeOperation - > setEnabled ( m_client - > isResizable ( ) ) ;
m_moveOperation - > setEnabled ( m_client - > isMovableAcrossScreens ( ) ) ;
m_maximizeOperation - > setEnabled ( m_client - > isMaximizable ( ) ) ;
m_maximizeOperation - > setChecked ( m_client - > maximizeMode ( ) = = MaximizeFull ) ;
m_shadeOperation - > setEnabled ( m_client - > isShadeable ( ) ) ;
m_shadeOperation - > setChecked ( m_client - > shadeMode ( ) ! = ShadeNone ) ;
m_keepAboveOperation - > setChecked ( m_client - > keepAbove ( ) ) ;
m_keepBelowOperation - > setChecked ( m_client - > keepBelow ( ) ) ;
m_fullScreenOperation - > setEnabled ( m_client - > userCanSetFullScreen ( ) ) ;
m_fullScreenOperation - > setChecked ( m_client - > isFullScreen ( ) ) ;
m_noBorderOperation - > setEnabled ( m_client - > userCanSetNoBorder ( ) ) ;
m_noBorderOperation - > setChecked ( m_client - > noBorder ( ) ) ;
m_minimizeOperation - > setEnabled ( m_client - > isMinimizable ( ) ) ;
m_closeOperation - > setEnabled ( m_client - > isCloseable ( ) ) ;
m_shortcutOperation - > setEnabled ( m_client - > rules ( ) - > checkShortcut ( QString ( ) ) . isNull ( ) ) ;
2012-08-19 10:00:53 +00:00
2012-08-31 11:28:31 +00:00
// drop the existing scripts menu
delete m_scriptsMenu ;
2019-09-14 08:58:12 +00:00
m_scriptsMenu = nullptr ;
2012-08-31 11:28:31 +00:00
// ask scripts whether they want to add entries for the given Client
2013-04-04 07:11:17 +00:00
QList < QAction * > scriptActions = Scripting : : self ( ) - > actionsForUserActionMenu ( m_client . data ( ) , m_scriptsMenu ) ;
2012-08-31 11:28:31 +00:00
if ( ! scriptActions . isEmpty ( ) ) {
2015-09-22 12:44:25 +00:00
m_scriptsMenu = new QMenu ( m_menu ) ;
2019-08-11 18:25:58 +00:00
m_scriptsMenu - > setPalette ( m_client - > palette ( ) ) ;
2012-08-31 11:28:31 +00:00
m_scriptsMenu - > addActions ( scriptActions ) ;
QAction * action = m_scriptsMenu - > menuAction ( ) ;
// set it as the first item after desktop
m_menu - > insertAction ( m_closeOperation , action ) ;
action - > setText ( i18n ( " &Extensions " ) ) ;
}
2014-06-01 16:55:36 +00:00
2019-08-11 18:25:58 +00:00
m_rulesOperation - > setEnabled ( m_client - > supportsWindowRules ( ) ) ;
m_applicationRulesOperation - > setEnabled ( m_client - > supportsWindowRules ( ) ) ;
2018-02-16 19:55:06 +00:00
2014-06-01 16:55:36 +00:00
showHideActivityMenu ( ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : showHideActivityMenu ( )
2012-04-12 19:52:44 +00:00
{
# ifdef KWIN_BUILD_ACTIVITIES
2015-07-07 09:48:42 +00:00
if ( ! Activities : : self ( ) ) {
return ;
}
2013-04-04 14:14:12 +00:00
const QStringList & openActivities_ = Activities : : self ( ) - > running ( ) ;
2014-12-05 10:42:15 +00:00
qCDebug ( KWIN_CORE ) < < " activities: " < < openActivities_ . size ( ) ;
2012-04-12 19:52:44 +00:00
if ( openActivities_ . size ( ) < 2 ) {
2012-08-19 10:00:53 +00:00
delete m_activityMenu ;
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
m_activityMenu = nullptr ;
2012-04-12 19:52:44 +00:00
} else {
initActivityPopup ( ) ;
}
# endif
}
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : initDesktopPopup ( )
2011-01-30 14:34:42 +00:00
{
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
if ( kwinApp ( ) - > operationMode ( ) = = Application : : OperationModeWaylandOnly | |
2019-02-02 18:17:44 +00:00
kwinApp ( ) - > operationMode ( ) = = Application : : OperationModeXwayland ) {
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
if ( m_multipleDesktopsMenu ) {
return ;
}
2007-04-29 17:35:43 +00:00
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
m_multipleDesktopsMenu = new QMenu ( m_menu ) ;
connect ( m_multipleDesktopsMenu , & QMenu : : aboutToShow , this , & UserActionsMenu : : multipleDesktopsPopupAboutToShow ) ;
2007-04-29 17:35:43 +00:00
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
QAction * action = m_multipleDesktopsMenu - > menuAction ( ) ;
// set it as the first item
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_menu - > insertAction ( m_maximizeOperation , action ) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
action - > setText ( i18n ( " &Desktops " ) ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
action - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " virtual-desktops " ) ) ) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
} else {
if ( m_desktopMenu )
return ;
m_desktopMenu = new QMenu ( m_menu ) ;
connect ( m_desktopMenu , & QMenu : : aboutToShow , this , & UserActionsMenu : : desktopPopupAboutToShow ) ;
QAction * action = m_desktopMenu - > menuAction ( ) ;
// set it as the first item
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_menu - > insertAction ( m_maximizeOperation , action ) ;
action - > setText ( i18n ( " Move to &Desktop " ) ) ;
action - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " virtual-desktops " ) ) ) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
}
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : initScreenPopup ( )
2012-08-17 20:32:06 +00:00
{
2012-08-19 10:00:53 +00:00
if ( m_screenMenu ) {
2012-08-17 20:32:06 +00:00
return ;
}
2012-08-19 10:00:53 +00:00
m_screenMenu = new QMenu ( m_menu ) ;
2014-03-27 15:48:25 +00:00
connect ( m_screenMenu , & QMenu : : aboutToShow , this , & UserActionsMenu : : screenPopupAboutToShow ) ;
2012-08-17 20:32:06 +00:00
2012-08-19 10:00:53 +00:00
QAction * action = m_screenMenu - > menuAction ( ) ;
2012-08-17 20:32:06 +00:00
// set it as the first item after desktop
2012-08-19 10:00:53 +00:00
m_menu - > insertAction ( m_activityMenu ? m_activityMenu - > menuAction ( ) : m_minimizeOperation , action ) ;
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
action - > setText ( i18n ( " Move to &Screen " ) ) ;
action - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " computer " ) ) ) ;
2012-08-17 20:32:06 +00:00
}
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : initActivityPopup ( )
2011-01-30 14:34:42 +00:00
{
2012-08-19 10:00:53 +00:00
if ( m_activityMenu )
2010-05-11 20:30:20 +00:00
return ;
2012-08-19 10:00:53 +00:00
m_activityMenu = new QMenu ( m_menu ) ;
2014-03-27 15:48:25 +00:00
connect ( m_activityMenu , & QMenu : : triggered , this , & UserActionsMenu : : slotToggleOnActivity ) ;
connect ( m_activityMenu , & QMenu : : aboutToShow , this , & UserActionsMenu : : activityPopupAboutToShow ) ;
2010-05-11 20:30:20 +00:00
2012-08-19 10:00:53 +00:00
QAction * action = m_activityMenu - > menuAction ( ) ;
2010-05-11 20:30:20 +00:00
// set it as the first item
Make KWin action menu consistent with task manager, use action verbs for configure items and add more icons
Summary: {F7329676}
Test Plan: Open the context menu for a window (Alt+F3).
Reviewers: #kwin, #vdg, ndavis, davidedmundson
Reviewed By: #kwin, #vdg, ndavis, davidedmundson
Subscribers: davidedmundson, ndavis, #vdg, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23779
2019-09-07 22:07:20 +00:00
m_menu - > insertAction ( m_maximizeOperation , action ) ;
action - > setText ( i18n ( " Show in &Activities " ) ) ;
action - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " activities " ) ) ) ;
2011-01-30 14:34:42 +00:00
}
2010-05-11 20:30:20 +00:00
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : desktopPopupAboutToShow ( )
2011-01-30 14:34:42 +00:00
{
2012-08-19 10:00:53 +00:00
if ( ! m_desktopMenu )
2007-04-29 17:35:43 +00:00
return ;
2012-11-16 07:23:47 +00:00
const VirtualDesktopManager * vds = VirtualDesktopManager : : self ( ) ;
2007-04-29 17:35:43 +00:00
2012-08-19 10:00:53 +00:00
m_desktopMenu - > clear ( ) ;
2019-08-11 18:25:58 +00:00
if ( m_client ) {
m_desktopMenu - > setPalette ( m_client - > palette ( ) ) ;
}
2012-08-19 10:00:53 +00:00
QActionGroup * group = new QActionGroup ( m_desktopMenu ) ;
QAction * action = m_desktopMenu - > addAction ( i18n ( " &All Desktops " ) ) ;
2021-08-17 06:42:09 +00:00
connect ( action , & QAction : : triggered , this , [ this ] ( ) {
if ( m_client ) {
m_client - > setOnAllDesktops ( ! m_client - > isOnAllDesktops ( ) ) ;
}
} ) ;
2011-01-30 14:34:42 +00:00
action - > setCheckable ( true ) ;
2021-08-17 06:42:09 +00:00
if ( m_client & & m_client - > isOnAllDesktops ( ) ) {
action - > setChecked ( true ) ;
}
2012-03-23 07:11:55 +00:00
group - > addAction ( action ) ;
2007-04-29 17:35:43 +00:00
2019-08-11 18:25:58 +00:00
if ( m_client & & m_client - > isOnAllDesktops ( ) ) {
2011-01-30 14:34:42 +00:00
action - > setChecked ( true ) ;
2019-08-11 18:25:58 +00:00
}
2012-08-19 10:00:53 +00:00
m_desktopMenu - > addSeparator ( ) ;
2007-04-29 17:35:43 +00:00
2012-11-16 07:23:47 +00:00
const uint BASE = 10 ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
2021-08-17 06:42:09 +00:00
const auto desktops = vds - > desktops ( ) ;
for ( VirtualDesktop * desktop : desktops ) {
const uint legacyId = desktop - > x11DesktopNumber ( ) ;
2013-07-23 05:02:52 +00:00
QString basic_name ( QStringLiteral ( " %1 %2 " ) ) ;
2021-08-17 06:42:09 +00:00
if ( legacyId < BASE ) {
2015-11-05 14:14:06 +00:00
basic_name . prepend ( QLatin1Char ( ' & ' ) ) ;
2007-04-29 17:35:43 +00:00
}
2021-08-17 06:42:09 +00:00
action = m_desktopMenu - > addAction ( basic_name . arg ( legacyId ) . arg ( desktop - > name ( ) . replace ( QLatin1Char ( ' & ' ) , QStringLiteral ( " && " ) ) ) ) ;
connect ( action , & QAction : : triggered , this , [ this , desktop ] ( ) {
if ( m_client ) {
workspace ( ) - > sendClientToDesktop ( m_client , desktop - > x11DesktopNumber ( ) , false ) ;
}
} ) ;
2011-01-30 14:34:42 +00:00
action - > setCheckable ( true ) ;
2012-03-23 07:11:55 +00:00
group - > addAction ( action ) ;
2007-04-29 17:35:43 +00:00
2021-08-17 06:42:09 +00:00
if ( m_client & & ! m_client - > isOnAllDesktops ( ) & & m_client - > isOnDesktop ( desktop ) ) {
2011-01-30 14:34:42 +00:00
action - > setChecked ( true ) ;
2019-08-11 18:25:58 +00:00
}
2007-04-29 17:35:43 +00:00
}
2012-04-29 15:32:34 +00:00
2012-08-19 10:00:53 +00:00
m_desktopMenu - > addSeparator ( ) ;
2021-07-21 10:43:58 +00:00
action = m_desktopMenu - > addAction ( i18nc ( " Create a new desktop and move the window there " , " &New Desktop " ) ) ;
2021-08-17 06:42:09 +00:00
connect ( action , & QAction : : triggered , this , [ this ] ( ) {
if ( ! m_client ) {
return ;
}
VirtualDesktopManager * vds = VirtualDesktopManager : : self ( ) ;
VirtualDesktop * desktop = vds - > createVirtualDesktop ( vds - > count ( ) ) ;
if ( desktop ) {
workspace ( ) - > sendClientToDesktop ( m_client , desktop - > x11DesktopNumber ( ) , false ) ;
}
} ) ;
action - > setEnabled ( vds - > count ( ) < vds - > maximum ( ) ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
void UserActionsMenu : : multipleDesktopsPopupAboutToShow ( )
{
if ( ! m_multipleDesktopsMenu )
return ;
2021-08-16 13:52:15 +00:00
VirtualDesktopManager * vds = VirtualDesktopManager : : self ( ) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
m_multipleDesktopsMenu - > clear ( ) ;
2019-08-11 18:25:58 +00:00
if ( m_client ) {
m_multipleDesktopsMenu - > setPalette ( m_client - > palette ( ) ) ;
}
2021-07-21 10:43:58 +00:00
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
QAction * action = m_multipleDesktopsMenu - > addAction ( i18n ( " &All Desktops " ) ) ;
2021-08-16 13:52:15 +00:00
connect ( action , & QAction : : triggered , this , [ this ] ( ) {
if ( m_client ) {
m_client - > setOnAllDesktops ( ! m_client - > isOnAllDesktops ( ) ) ;
}
} ) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
action - > setCheckable ( true ) ;
2019-08-11 18:25:58 +00:00
if ( m_client & & m_client - > isOnAllDesktops ( ) ) {
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
action - > setChecked ( true ) ;
}
2021-07-21 10:43:58 +00:00
m_multipleDesktopsMenu - > addSeparator ( ) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
const uint BASE = 10 ;
2021-08-16 13:52:15 +00:00
const auto desktops = vds - > desktops ( ) ;
for ( VirtualDesktop * desktop : desktops ) {
const uint legacyId = desktop - > x11DesktopNumber ( ) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
QString basic_name ( QStringLiteral ( " %1 %2 " ) ) ;
2021-08-16 13:52:15 +00:00
if ( legacyId < BASE ) {
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
basic_name . prepend ( QLatin1Char ( ' & ' ) ) ;
}
2021-08-16 13:52:15 +00:00
QAction * action = m_multipleDesktopsMenu - > addAction ( basic_name . arg ( legacyId ) . arg ( desktop - > name ( ) . replace ( QLatin1Char ( ' & ' ) , QStringLiteral ( " && " ) ) ) ) ;
connect ( action , & QAction : : triggered , this , [ this , desktop ] ( ) {
if ( m_client ) {
if ( m_client - > desktops ( ) . contains ( desktop ) ) {
m_client - > leaveDesktop ( desktop ) ;
} else {
m_client - > enterDesktop ( desktop ) ;
}
}
} ) ;
2021-07-21 10:43:58 +00:00
action - > setCheckable ( true ) ;
2021-08-16 13:52:15 +00:00
if ( m_client & & ! m_client - > isOnAllDesktops ( ) & & m_client - > isOnDesktop ( desktop ) ) {
2021-07-21 10:43:58 +00:00
action - > setChecked ( true ) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
}
}
m_multipleDesktopsMenu - > addSeparator ( ) ;
2021-08-16 13:52:15 +00:00
for ( VirtualDesktop * desktop : desktops ) {
const uint legacyId = desktop - > x11DesktopNumber ( ) ;
QString name = i18n ( " Move to %1 %2 " , legacyId , desktop - > name ( ) ) ;
2021-07-21 10:43:58 +00:00
QAction * action = m_multipleDesktopsMenu - > addAction ( name ) ;
2021-08-16 13:52:15 +00:00
connect ( action , & QAction : : triggered , this , [ this , desktop ] ( ) {
if ( m_client ) {
m_client - > setDesktops ( { desktop } ) ;
}
} ) ;
2021-07-21 10:43:58 +00:00
}
m_multipleDesktopsMenu - > addSeparator ( ) ;
bool allowNewDesktops = vds - > count ( ) < vds - > maximum ( ) ;
action = m_multipleDesktopsMenu - > addAction ( i18nc ( " Create a new desktop and add the window to that desktop " , " Add to &New Desktop " ) ) ;
2021-08-16 13:52:15 +00:00
connect ( action , & QAction : : triggered , this , [ this , vds ] ( ) {
if ( ! m_client ) {
return ;
}
VirtualDesktop * desktop = vds - > createVirtualDesktop ( vds - > count ( ) ) ;
if ( desktop ) {
m_client - > enterDesktop ( desktop ) ;
}
} ) ;
2021-07-21 10:43:58 +00:00
action - > setEnabled ( allowNewDesktops ) ;
action = m_multipleDesktopsMenu - > addAction ( i18nc ( " Create a new desktop and move the window to that desktop " , " Move to New Desktop " ) ) ;
2021-08-16 13:52:15 +00:00
connect ( action , & QAction : : triggered , this , [ this , vds ] ( ) {
if ( ! m_client ) {
return ;
}
VirtualDesktop * desktop = vds - > createVirtualDesktop ( vds - > count ( ) ) ;
if ( desktop ) {
m_client - > setDesktops ( { desktop } ) ;
}
} ) ;
2021-07-21 10:43:58 +00:00
action - > setEnabled ( allowNewDesktops ) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
}
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : screenPopupAboutToShow ( )
2012-08-17 20:32:06 +00:00
{
2012-08-19 10:00:53 +00:00
if ( ! m_screenMenu ) {
2012-08-17 20:32:06 +00:00
return ;
}
2012-08-19 10:00:53 +00:00
m_screenMenu - > clear ( ) ;
2019-08-11 18:25:58 +00:00
if ( ! m_client ) {
return ;
}
m_screenMenu - > setPalette ( m_client - > palette ( ) ) ;
2012-08-19 10:00:53 +00:00
QActionGroup * group = new QActionGroup ( m_screenMenu ) ;
2012-08-17 20:32:06 +00:00
2021-08-28 14:51:00 +00:00
const auto outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
for ( int i = 0 ; i < outputs . count ( ) ; + + i ) {
AbstractOutput * output = outputs [ i ] ;
2012-08-17 20:32:06 +00:00
// assumption: there are not more than 9 screens attached.
2015-05-19 06:37:13 +00:00
QAction * action = m_screenMenu - > addAction ( i18nc ( " @item:inmenu List of all Screens to send a window to. First argument is a number, second the output identifier. E.g. Screen 1 (HDMI1) " ,
2021-08-28 14:51:00 +00:00
" Screen &%1 (%2) " , ( i + 1 ) , output - > name ( ) ) ) ;
connect ( action , & QAction : : triggered , this , [ this , output ] ( ) {
workspace ( ) - > sendClientToOutput ( m_client , output ) ;
} ) ;
2012-08-17 20:32:06 +00:00
action - > setCheckable ( true ) ;
2021-08-28 14:51:00 +00:00
if ( m_client & & output = = m_client - > output ( ) ) {
2012-08-17 20:32:06 +00:00
action - > setChecked ( true ) ;
}
group - > addAction ( action ) ;
}
}
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : activityPopupAboutToShow ( )
2011-01-30 14:34:42 +00:00
{
2012-08-19 10:00:53 +00:00
if ( ! m_activityMenu )
2010-05-11 20:30:20 +00:00
return ;
2012-02-26 10:38:16 +00:00
# ifdef KWIN_BUILD_ACTIVITIES
2015-07-07 09:48:42 +00:00
if ( ! Activities : : self ( ) ) {
return ;
}
2012-08-19 10:00:53 +00:00
m_activityMenu - > clear ( ) ;
2019-08-11 18:25:58 +00:00
if ( m_client ) {
m_activityMenu - > setPalette ( m_client - > palette ( ) ) ;
}
2012-08-19 10:00:53 +00:00
QAction * action = m_activityMenu - > addAction ( i18n ( " &All Activities " ) ) ;
2011-01-30 14:34:42 +00:00
action - > setData ( QString ( ) ) ;
action - > setCheckable ( true ) ;
2014-05-01 14:22:04 +00:00
static QPointer < QActionGroup > allActivitiesGroup ;
2014-02-06 17:39:07 +00:00
if ( ! allActivitiesGroup ) {
allActivitiesGroup = new QActionGroup ( m_activityMenu ) ;
}
allActivitiesGroup - > addAction ( action ) ;
2010-05-11 20:30:20 +00:00
2019-08-11 18:25:58 +00:00
if ( m_client & & m_client - > isOnAllActivities ( ) ) {
2011-01-30 14:34:42 +00:00
action - > setChecked ( true ) ;
2019-08-11 18:25:58 +00:00
}
2012-08-19 10:00:53 +00:00
m_activityMenu - > addSeparator ( ) ;
2010-05-11 20:30:20 +00:00
2021-11-03 11:55:31 +00:00
const auto activities = Activities : : self ( ) - > running ( ) ;
for ( const QString & id : activities ) {
2011-11-04 22:23:52 +00:00
KActivities : : Info activity ( id ) ;
2010-11-01 19:53:22 +00:00
QString name = activity . name ( ) ;
2010-05-11 20:30:20 +00:00
name . replace ( ' & ' , " && " ) ;
2021-12-04 16:07:01 +00:00
auto action = m_activityMenu - > addAction ( name ) ;
action - > setCheckable ( true ) ;
2013-03-24 20:57:26 +00:00
const QString icon = activity . icon ( ) ;
2021-12-04 16:07:01 +00:00
if ( ! icon . isEmpty ( ) ) {
action - > setIcon ( QIcon : : fromTheme ( icon ) ) ;
}
2013-03-24 20:57:26 +00:00
m_activityMenu - > addAction ( action ) ;
2011-01-30 14:34:42 +00:00
action - > setData ( id ) ;
2010-05-11 20:30:20 +00:00
2019-08-11 18:25:58 +00:00
if ( m_client & & ! m_client - > isOnAllActivities ( ) & & m_client - > isOnActivity ( id ) ) {
2021-12-04 16:07:01 +00:00
action - > setChecked ( true ) ;
2019-08-11 18:25:58 +00:00
}
2010-05-11 20:30:20 +00:00
}
2012-02-26 10:38:16 +00:00
# endif
2011-01-30 14:34:42 +00:00
}
2010-05-11 20:30:20 +00:00
2012-08-19 10:00:53 +00:00
void UserActionsMenu : : slotWindowOperation ( QAction * action )
{
if ( ! action - > data ( ) . isValid ( ) )
return ;
Options : : WindowOperation op = static_cast < Options : : WindowOperation > ( action - > data ( ) . toInt ( ) ) ;
2019-08-10 07:57:32 +00:00
QPointer < AbstractClient > c = m_client ? m_client : QPointer < AbstractClient > ( Workspace : : self ( ) - > activeClient ( ) ) ;
2012-08-19 10:00:53 +00:00
if ( c . isNull ( ) )
return ;
QString type ;
switch ( op ) {
case Options : : FullScreenOp :
2019-08-10 07:57:32 +00:00
if ( ! c - > isFullScreen ( ) & & c - > userCanSetFullScreen ( ) )
2013-07-23 05:02:52 +00:00
type = QStringLiteral ( " fullscreenaltf3 " ) ;
2012-08-19 10:00:53 +00:00
break ;
case Options : : NoBorderOp :
2019-08-10 07:57:32 +00:00
if ( ! c - > noBorder ( ) & & c - > userCanSetNoBorder ( ) )
2013-07-23 05:02:52 +00:00
type = QStringLiteral ( " noborderaltf3 " ) ;
2012-08-19 10:00:53 +00:00
break ;
default :
break ;
2019-08-09 22:24:14 +00:00
}
2012-08-19 10:00:53 +00:00
if ( ! type . isEmpty ( ) )
helperDialog ( type , c ) ;
2013-08-19 10:15:42 +00:00
// need to delay performing the window operation as we need to have the
// user actions menu closed before we destroy the decoration. Otherwise Qt crashes
2014-12-02 12:50:26 +00:00
qRegisterMetaType < Options : : WindowOperation > ( ) ;
2021-09-06 19:11:02 +00:00
QMetaObject : : invokeMethod ( workspace ( ) , std : : bind ( & Workspace : : performWindowOperation , workspace ( ) , c , op ) , Qt : : QueuedConnection ) ;
2012-08-19 10:00:53 +00:00
}
void UserActionsMenu : : slotToggleOnActivity ( QAction * action )
{
2013-04-04 14:14:12 +00:00
# ifdef KWIN_BUILD_ACTIVITIES
2015-07-07 09:48:42 +00:00
if ( ! Activities : : self ( ) ) {
return ;
}
2012-08-19 10:00:53 +00:00
QString activity = action - > data ( ) . toString ( ) ;
if ( m_client . isNull ( ) )
return ;
if ( activity . isEmpty ( ) ) {
// the 'on_all_activities' menu entry
2019-08-11 18:25:58 +00:00
m_client - > setOnAllActivities ( ! m_client - > isOnAllActivities ( ) ) ;
2012-08-19 10:00:53 +00:00
return ;
}
2021-03-05 13:07:23 +00:00
Activities : : self ( ) - > toggleClientOnActivity ( m_client , activity , false ) ;
2013-03-24 20:57:26 +00:00
if ( m_activityMenu & & m_activityMenu - > isVisible ( ) & & m_activityMenu - > actions ( ) . count ( ) ) {
2019-08-11 18:25:58 +00:00
const bool isOnAll = m_client - > isOnAllActivities ( ) ;
2014-02-06 17:39:07 +00:00
m_activityMenu - > actions ( ) . at ( 0 ) - > setChecked ( isOnAll ) ;
if ( isOnAll ) {
// toggleClientOnActivity interprets "on all" as "on none" and
// susequent toggling ("off") would move the client to only that activity.
// bug #330838 -> set all but "on all" off to "force proper usage"
for ( int i = 1 ; i < m_activityMenu - > actions ( ) . count ( ) ; + + i ) {
2021-12-04 16:07:01 +00:00
m_activityMenu - > actions ( ) . at ( i ) - > setChecked ( true ) ;
2014-02-06 17:39:07 +00:00
}
}
2013-03-24 20:57:26 +00:00
}
2021-12-04 16:07:01 +00:00
2014-11-21 15:48:39 +00:00
# else
Q_UNUSED ( action )
2013-04-04 14:14:12 +00:00
# endif
2012-08-19 10:00:53 +00:00
}
2013-04-25 15:21:54 +00:00
//****************************************
// ShortcutDialog
//****************************************
ShortcutDialog : : ShortcutDialog ( const QKeySequence & cut )
: _shortcut ( cut )
{
2013-12-12 13:17:26 +00:00
m_ui . setupUi ( this ) ;
m_ui . keySequenceEdit - > setKeySequence ( cut ) ;
m_ui . warning - > hide ( ) ;
2013-04-25 15:21:54 +00:00
// Listen to changed shortcuts
2013-12-12 13:17:26 +00:00
connect ( m_ui . keySequenceEdit , & QKeySequenceEdit : : editingFinished , this , & ShortcutDialog : : keySequenceChanged ) ;
2021-08-22 12:51:36 +00:00
connect ( m_ui . clearButton , & QToolButton : : clicked , this , [ this ] {
2013-12-12 13:17:26 +00:00
_shortcut = QKeySequence ( ) ;
} ) ;
m_ui . keySequenceEdit - > setFocus ( ) ;
2013-04-25 15:21:54 +00:00
2013-08-19 10:44:30 +00:00
setWindowFlags ( Qt : : Popup | Qt : : X11BypassWindowManagerHint ) ;
2013-04-25 15:21:54 +00:00
}
void ShortcutDialog : : accept ( )
{
QKeySequence seq = shortcut ( ) ;
if ( ! seq . isEmpty ( ) ) {
if ( seq [ 0 ] = = Qt : : Key_Escape ) {
reject ( ) ;
return ;
}
if ( seq [ 0 ] = = Qt : : Key_Space
| | ( seq [ 0 ] & Qt : : KeyboardModifierMask ) = = 0 ) {
// clear
2013-12-12 13:17:26 +00:00
m_ui . keySequenceEdit - > clear ( ) ;
2013-08-19 10:44:30 +00:00
QDialog : : accept ( ) ;
2013-04-25 15:21:54 +00:00
return ;
}
}
2013-08-19 10:44:30 +00:00
QDialog : : accept ( ) ;
2013-04-25 15:21:54 +00:00
}
void ShortcutDialog : : done ( int r )
{
2013-08-19 10:44:30 +00:00
QDialog : : done ( r ) ;
2021-06-08 07:02:14 +00:00
Q_EMIT dialogDone ( r = = Accepted ) ;
2013-04-25 15:21:54 +00:00
}
2013-12-12 13:17:26 +00:00
void ShortcutDialog : : keySequenceChanged ( )
2013-04-25 15:21:54 +00:00
{
activateWindow ( ) ; // where is the kbd focus lost? cause of popup state?
2013-12-12 13:17:26 +00:00
QKeySequence seq = m_ui . keySequenceEdit - > keySequence ( ) ;
2013-04-25 15:21:54 +00:00
if ( _shortcut = = seq )
return ; // don't try to update the same
if ( seq . isEmpty ( ) ) { // clear
_shortcut = seq ;
return ;
}
2013-12-12 13:17:26 +00:00
if ( seq . count ( ) > 1 ) {
seq = QKeySequence ( seq [ 0 ] ) ;
m_ui . keySequenceEdit - > setKeySequence ( seq ) ;
}
2013-04-25 15:21:54 +00:00
// Check if the key sequence is used currently
QString sc = seq . toString ( ) ;
// NOTICE - seq.toString() & the entries in "conflicting" randomly get invalidated after the next call (if no sc has been set & conflicting isn't empty?!)
2022-01-21 10:02:40 +00:00
QList < KGlobalShortcutInfo > conflicting = KGlobalAccel : : globalShortcutsByKey ( seq ) ;
2013-04-25 15:21:54 +00:00
if ( ! conflicting . isEmpty ( ) ) {
const KGlobalShortcutInfo & conflict = conflicting . at ( 0 ) ;
2013-12-12 13:17:26 +00:00
m_ui . warning - > setText ( i18nc ( " '%1' is a keyboard shortcut like 'ctrl+w' " ,
2013-04-25 15:21:54 +00:00
" <b>%1</b> is already in use " , sc ) ) ;
2013-12-12 13:17:26 +00:00
m_ui . warning - > setToolTip ( i18nc ( " keyboard shortcut '%1' is used by action '%2' in application '%3' " ,
2013-04-25 15:21:54 +00:00
" <b>%1</b> is used by %2 in %3 " , sc , conflict . friendlyName ( ) , conflict . componentFriendlyName ( ) ) ) ;
2013-12-12 13:17:26 +00:00
m_ui . warning - > show ( ) ;
m_ui . keySequenceEdit - > setKeySequence ( shortcut ( ) ) ;
2013-04-25 15:21:54 +00:00
} else if ( seq ! = _shortcut ) {
2013-12-12 13:17:26 +00:00
m_ui . warning - > hide ( ) ;
if ( QPushButton * ok = m_ui . buttonBox - > button ( QDialogButtonBox : : Ok ) )
2013-04-25 15:21:54 +00:00
ok - > setFocus ( ) ;
}
_shortcut = seq ;
}
QKeySequence ShortcutDialog : : shortcut ( ) const
{
return _shortcut ;
}
2012-08-19 10:00:53 +00:00
//****************************************
// Workspace
//****************************************
void Workspace : : slotIncreaseWindowOpacity ( )
{
if ( ! active_client ) {
return ;
}
active_client - > setOpacity ( qMin ( active_client - > opacity ( ) + 0.05 , 1.0 ) ) ;
}
void Workspace : : slotLowerWindowOpacity ( )
{
if ( ! active_client ) {
return ;
}
active_client - > setOpacity ( qMax ( active_client - > opacity ( ) - 0.05 , 0.05 ) ) ;
}
2007-04-29 17:35:43 +00:00
void Workspace : : closeActivePopup ( )
2011-01-30 14:34:42 +00:00
{
if ( active_popup ) {
2007-04-29 17:35:43 +00:00
active_popup - > close ( ) ;
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
active_popup = nullptr ;
active_popup_client = nullptr ;
2007-04-29 17:35:43 +00:00
}
2012-08-19 10:00:53 +00:00
m_userActionsMenu - > close ( ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2013-09-09 07:41:37 +00:00
template < typename Slot >
void Workspace : : initShortcut ( const QString & actionName , const QString & description , const QKeySequence & shortcut , Slot slot , const QVariant & data )
2017-09-24 08:10:52 +00:00
{
initShortcut ( actionName , description , shortcut , this , slot , data ) ;
}
template < typename T , typename Slot >
void Workspace : : initShortcut ( const QString & actionName , const QString & description , const QKeySequence & shortcut , T * receiver , Slot slot , const QVariant & data )
2013-09-09 07:41:37 +00:00
{
2013-12-10 09:01:13 +00:00
QAction * a = new QAction ( this ) ;
2016-09-13 11:02:20 +00:00
a - > setProperty ( " componentName " , QStringLiteral ( KWIN_NAME ) ) ;
2013-12-10 09:01:13 +00:00
a - > setObjectName ( actionName ) ;
2013-09-09 07:41:37 +00:00
a - > setText ( description ) ;
if ( data . isValid ( ) ) {
a - > setData ( data ) ;
}
KGlobalAccel : : self ( ) - > setDefaultShortcut ( a , QList < QKeySequence > ( ) < < shortcut ) ;
KGlobalAccel : : self ( ) - > setShortcut ( a , QList < QKeySequence > ( ) < < shortcut ) ;
2017-09-24 08:10:52 +00:00
input ( ) - > registerShortcut ( shortcut , a , receiver , slot ) ;
2013-09-09 07:41:37 +00:00
}
2019-02-02 18:17:44 +00:00
/**
* Creates the global accel object \ c keys .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : initShortcuts ( )
2011-01-30 14:34:42 +00:00
{
2021-06-08 08:05:02 +00:00
// Some shortcuts have Tarzan-speech like names, they need extra
// normal human descriptions with DEF2() the others can use DEF()
// new DEF3 allows to pass data to the action, replacing the %1 argument in the name
# define DEF2( name, descr, key, fnSlot ) \
initShortcut ( QStringLiteral ( name ) , i18n ( descr ) , key , & Workspace : : fnSlot ) ;
# define DEF( name, key, fnSlot ) \
initShortcut ( QStringLiteral ( name ) , i18n ( name ) , key , & Workspace : : fnSlot ) ;
# define DEF3( name, key, fnSlot, value ) \
initShortcut ( QStringLiteral ( name ) . arg ( value ) , i18n ( name , value ) , key , & Workspace : : fnSlot , value ) ;
# define DEF4( name, descr, key, functor ) \
initShortcut ( QStringLiteral ( name ) , i18n ( descr ) , key , functor ) ;
# define DEF5( name, key, functor, value ) \
initShortcut ( QStringLiteral ( name ) . arg ( value ) , i18n ( name , value ) , key , functor , value ) ;
# define DEF6( name, key, target, fnSlot ) \
initShortcut ( QStringLiteral ( name ) , i18n ( name ) , key , target , & fnSlot ) ;
DEF ( I18N_NOOP ( " Window Operations Menu " ) ,
Qt : : ALT + Qt : : Key_F3 , slotWindowOperations ) ;
DEF2 ( " Window Close " , I18N_NOOP ( " Close Window " ) ,
Qt : : ALT + Qt : : Key_F4 , slotWindowClose ) ;
DEF2 ( " Window Maximize " , I18N_NOOP ( " Maximize Window " ) ,
Qt : : META + Qt : : Key_PageUp , slotWindowMaximize ) ;
DEF2 ( " Window Maximize Vertical " , I18N_NOOP ( " Maximize Window Vertically " ) ,
0 , slotWindowMaximizeVertical ) ;
DEF2 ( " Window Maximize Horizontal " , I18N_NOOP ( " Maximize Window Horizontally " ) ,
0 , slotWindowMaximizeHorizontal ) ;
DEF2 ( " Window Minimize " , I18N_NOOP ( " Minimize Window " ) ,
Qt : : META + Qt : : Key_PageDown , slotWindowMinimize ) ;
DEF2 ( " Window Shade " , I18N_NOOP ( " Shade Window " ) ,
0 , slotWindowShade ) ;
DEF2 ( " Window Move " , I18N_NOOP ( " Move Window " ) ,
0 , slotWindowMove ) ;
DEF2 ( " Window Resize " , I18N_NOOP ( " Resize Window " ) ,
0 , slotWindowResize ) ;
DEF2 ( " Window Raise " , I18N_NOOP ( " Raise Window " ) ,
0 , slotWindowRaise ) ;
DEF2 ( " Window Lower " , I18N_NOOP ( " Lower Window " ) ,
0 , slotWindowLower ) ;
DEF ( I18N_NOOP ( " Toggle Window Raise/Lower " ) ,
0 , slotWindowRaiseOrLower ) ;
DEF2 ( " Window Fullscreen " , I18N_NOOP ( " Make Window Fullscreen " ) ,
0 , slotWindowFullScreen ) ;
DEF2 ( " Window No Border " , I18N_NOOP ( " Hide Window Border " ) ,
0 , slotWindowNoBorder ) ;
DEF2 ( " Window Above Other Windows " , I18N_NOOP ( " Keep Window Above Others " ) ,
0 , slotWindowAbove ) ;
DEF2 ( " Window Below Other Windows " , I18N_NOOP ( " Keep Window Below Others " ) ,
0 , slotWindowBelow ) ;
DEF ( I18N_NOOP ( " Activate Window Demanding Attention " ) ,
Qt : : CTRL + Qt : : ALT + Qt : : Key_A , slotActivateAttentionWindow ) ;
DEF ( I18N_NOOP ( " Setup Window Shortcut " ) ,
0 , slotSetupWindowShortcut ) ;
2021-09-20 13:14:24 +00:00
DEF2 ( " Window Move Center " , I18N_NOOP ( " Move Window to the Center " ) , 0 ,
slotWindowCenter ) ;
2021-10-04 16:20:10 +00:00
DEF2 ( " Window Pack Right " , I18N_NOOP ( " Move Window Right " ) ,
0 , slotWindowMoveRight ) ;
DEF2 ( " Window Pack Left " , I18N_NOOP ( " Move Window Left " ) ,
0 , slotWindowMoveLeft ) ;
DEF2 ( " Window Pack Up " , I18N_NOOP ( " Move Window Up " ) ,
0 , slotWindowMoveUp ) ;
DEF2 ( " Window Pack Down " , I18N_NOOP ( " Move Window Down " ) ,
0 , slotWindowMoveDown ) ;
DEF2 ( " Window Grow Horizontal " , I18N_NOOP ( " Expand Window Horizontally " ) ,
0 , slotWindowExpandHorizontal ) ;
DEF2 ( " Window Grow Vertical " , I18N_NOOP ( " Expand Window Vertically " ) ,
0 , slotWindowExpandVertical ) ;
DEF2 ( " Window Shrink Horizontal " , I18N_NOOP ( " Shrink Window Horizontally " ) ,
2021-06-08 08:05:02 +00:00
0 , slotWindowShrinkHorizontal ) ;
2021-10-04 16:20:10 +00:00
DEF2 ( " Window Shrink Vertical " , I18N_NOOP ( " Shrink Window Vertically " ) ,
2021-06-08 08:05:02 +00:00
0 , slotWindowShrinkVertical ) ;
DEF4 ( " Window Quick Tile Left " , I18N_NOOP ( " Quick Tile Window to the Left " ) ,
Qt : : META + Qt : : Key_Left , std : : bind ( & Workspace : : quickTileWindow , this , QuickTileFlag : : Left ) ) ;
DEF4 ( " Window Quick Tile Right " , I18N_NOOP ( " Quick Tile Window to the Right " ) ,
Qt : : META + Qt : : Key_Right , std : : bind ( & Workspace : : quickTileWindow , this , QuickTileFlag : : Right ) ) ;
DEF4 ( " Window Quick Tile Top " , I18N_NOOP ( " Quick Tile Window to the Top " ) ,
Qt : : META + Qt : : Key_Up , std : : bind ( & Workspace : : quickTileWindow , this , QuickTileFlag : : Top ) ) ;
DEF4 ( " Window Quick Tile Bottom " , I18N_NOOP ( " Quick Tile Window to the Bottom " ) ,
Qt : : META + Qt : : Key_Down , std : : bind ( & Workspace : : quickTileWindow , this , QuickTileFlag : : Bottom ) ) ;
DEF4 ( " Window Quick Tile Top Left " , I18N_NOOP ( " Quick Tile Window to the Top Left " ) ,
0 , std : : bind ( & Workspace : : quickTileWindow , this , QuickTileFlag : : Top | QuickTileFlag : : Left ) ) ;
DEF4 ( " Window Quick Tile Bottom Left " , I18N_NOOP ( " Quick Tile Window to the Bottom Left " ) ,
0 , std : : bind ( & Workspace : : quickTileWindow , this , QuickTileFlag : : Bottom | QuickTileFlag : : Left ) ) ;
DEF4 ( " Window Quick Tile Top Right " , I18N_NOOP ( " Quick Tile Window to the Top Right " ) ,
0 , std : : bind ( & Workspace : : quickTileWindow , this , QuickTileFlag : : Top | QuickTileFlag : : Right ) ) ;
DEF4 ( " Window Quick Tile Bottom Right " , I18N_NOOP ( " Quick Tile Window to the Bottom Right " ) ,
0 , std : : bind ( & Workspace : : quickTileWindow , this , QuickTileFlag : : Bottom | QuickTileFlag : : Right ) ) ;
DEF4 ( " Switch Window Up " , I18N_NOOP ( " Switch to Window Above " ) ,
Qt : : META + Qt : : ALT + Qt : : Key_Up , std : : bind ( static_cast < void ( Workspace : : * ) ( Direction ) > ( & Workspace : : switchWindow ) , this , DirectionNorth ) ) ;
DEF4 ( " Switch Window Down " , I18N_NOOP ( " Switch to Window Below " ) ,
Qt : : META + Qt : : ALT + Qt : : Key_Down , std : : bind ( static_cast < void ( Workspace : : * ) ( Direction ) > ( & Workspace : : switchWindow ) , this , DirectionSouth ) ) ;
DEF4 ( " Switch Window Right " , I18N_NOOP ( " Switch to Window to the Right " ) ,
Qt : : META + Qt : : ALT + Qt : : Key_Right , std : : bind ( static_cast < void ( Workspace : : * ) ( Direction ) > ( & Workspace : : switchWindow ) , this , DirectionEast ) ) ;
DEF4 ( " Switch Window Left " , I18N_NOOP ( " Switch to Window to the Left " ) ,
Qt : : META + Qt : : ALT + Qt : : Key_Left , std : : bind ( static_cast < void ( Workspace : : * ) ( Direction ) > ( & Workspace : : switchWindow ) , this , DirectionWest ) ) ;
DEF2 ( " Increase Opacity " , I18N_NOOP ( " Increase Opacity of Active Window by 5 % " ) ,
0 , slotIncreaseWindowOpacity ) ;
DEF2 ( " Decrease Opacity " , I18N_NOOP ( " Decrease Opacity of Active Window by 5 % " ) ,
0 , slotLowerWindowOpacity ) ;
DEF2 ( " Window On All Desktops " , I18N_NOOP ( " Keep Window on All Desktops " ) ,
0 , slotWindowOnAllDesktops ) ;
2021-08-17 07:19:46 +00:00
VirtualDesktopManager * vds = VirtualDesktopManager : : self ( ) ;
for ( uint i = 0 ; i < vds - > maximum ( ) ; + + i ) {
auto handler = [ this , i ] ( ) {
const QVector < VirtualDesktop * > desktops = VirtualDesktopManager : : self ( ) - > desktops ( ) ;
if ( i < uint ( desktops . count ( ) ) ) {
slotWindowToDesktop ( desktops [ i ] ) ;
}
} ;
DEF5 ( I18N_NOOP ( " Window to Desktop %1 " ) , 0 , handler , i + 1 ) ;
2021-06-08 08:05:02 +00:00
}
DEF ( I18N_NOOP ( " Window to Next Desktop " ) , 0 , slotWindowToNextDesktop ) ;
DEF ( I18N_NOOP ( " Window to Previous Desktop " ) , 0 , slotWindowToPreviousDesktop ) ;
DEF ( I18N_NOOP ( " Window One Desktop to the Right " ) , Qt : : META + Qt : : CTRL + Qt : : SHIFT + Qt : : Key_Right , slotWindowToDesktopRight ) ;
DEF ( I18N_NOOP ( " Window One Desktop to the Left " ) , Qt : : META + Qt : : CTRL + Qt : : SHIFT + Qt : : Key_Left , slotWindowToDesktopLeft ) ;
DEF ( I18N_NOOP ( " Window One Desktop Up " ) , Qt : : META + Qt : : CTRL + Qt : : SHIFT + Qt : : Key_Up , slotWindowToDesktopUp ) ;
DEF ( I18N_NOOP ( " Window One Desktop Down " ) , Qt : : META + Qt : : CTRL + Qt : : SHIFT + Qt : : Key_Down , slotWindowToDesktopDown ) ;
for ( int i = 0 ; i < 8 ; + + i ) {
DEF3 ( I18N_NOOP ( " Window to Screen %1 " ) , 0 , slotWindowToScreen , i ) ;
}
DEF ( I18N_NOOP ( " Window to Next Screen " ) , Qt : : META + Qt : : SHIFT + Qt : : Key_Right , slotWindowToNextScreen ) ;
DEF ( I18N_NOOP ( " Window to Previous Screen " ) , Qt : : META + Qt : : SHIFT + Qt : : Key_Left , slotWindowToPrevScreen ) ;
DEF ( I18N_NOOP ( " Show Desktop " ) , Qt : : META + Qt : : Key_D , slotToggleShowDesktop ) ;
for ( int i = 0 ; i < 8 ; + + i ) {
DEF3 ( I18N_NOOP ( " Switch to Screen %1 " ) , 0 , slotSwitchToScreen , i ) ;
}
DEF ( I18N_NOOP ( " Switch to Next Screen " ) , 0 , slotSwitchToNextScreen ) ;
DEF ( I18N_NOOP ( " Switch to Previous Screen " ) , 0 , slotSwitchToPrevScreen ) ;
DEF ( I18N_NOOP ( " Kill Window " ) , Qt : : CTRL + Qt : : ALT + Qt : : Key_Escape , slotKillWindow ) ;
DEF6 ( I18N_NOOP ( " Suspend Compositing " ) , Qt : : SHIFT + Qt : : ALT + Qt : : Key_F12 , Compositor : : self ( ) , Compositor : : toggleCompositing ) ;
DEF6 ( I18N_NOOP ( " Invert Screen Colors " ) , 0 , kwinApp ( ) - > platform ( ) , Platform : : invertScreen ) ;
# undef DEF
# undef DEF2
# undef DEF3
# undef DEF4
# undef DEF5
# undef DEF6
2011-06-30 11:02:30 +00:00
# ifdef KWIN_BUILD_TABBOX
2013-12-10 08:34:11 +00:00
TabBox : : TabBox : : self ( ) - > initShortcuts ( ) ;
2011-07-20 11:25:00 +00:00
# endif
2021-08-17 07:19:46 +00:00
vds - > initShortcuts ( ) ;
2012-08-19 10:00:53 +00:00
m_userActionsMenu - > discard ( ) ; // so that it's recreated next time
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2015-03-06 08:03:08 +00:00
void Workspace : : setupWindowShortcut ( AbstractClient * c )
2011-01-30 14:34:42 +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
Q_ASSERT ( client_keys_dialog = = nullptr ) ;
2009-10-05 06:59:10 +00:00
// TODO: PORT ME (KGlobalAccel related)
//keys->setEnabled( false );
//disable_shortcuts_keys->setEnabled( false );
//client_keys->setEnabled( false );
2013-09-06 08:31:38 +00:00
client_keys_dialog = new ShortcutDialog ( c - > shortcut ( ) ) ;
2007-04-29 17:35:43 +00:00
client_keys_client = c ;
2014-03-27 15:48:25 +00:00
connect ( client_keys_dialog , & ShortcutDialog : : dialogDone , this , & Workspace : : setupWindowShortcutDone ) ;
2011-01-30 14:34:42 +00:00
QRect r = clientArea ( ScreenArea , c ) ;
2007-04-29 17:35:43 +00:00
QSize size = client_keys_dialog - > sizeHint ( ) ;
QPoint pos = c - > pos ( ) + c - > clientPos ( ) ;
2011-01-30 14:34:42 +00:00
if ( pos . x ( ) + size . width ( ) > = r . right ( ) )
pos . setX ( r . right ( ) - size . width ( ) ) ;
if ( pos . y ( ) + size . height ( ) > = r . bottom ( ) )
pos . setY ( r . bottom ( ) - size . height ( ) ) ;
client_keys_dialog - > move ( pos ) ;
2007-04-29 17:35:43 +00:00
client_keys_dialog - > show ( ) ;
active_popup = client_keys_dialog ;
active_popup_client = c ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2011-01-30 14:34:42 +00:00
void Workspace : : setupWindowShortcutDone ( bool ok )
{
2007-11-01 19:24:35 +00:00
// keys->setEnabled( true );
// disable_shortcuts_keys->setEnabled( true );
// client_keys->setEnabled( true );
2011-01-30 14:34:42 +00:00
if ( ok )
2013-09-06 08:31:38 +00:00
client_keys_client - > setShortcut ( client_keys_dialog - > shortcut ( ) . toString ( ) ) ;
2007-04-29 17:35:43 +00:00
closeActivePopup ( ) ;
2008-06-01 11:36:07 +00:00
client_keys_dialog - > deleteLater ( ) ;
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
client_keys_dialog = nullptr ;
client_keys_client = nullptr ;
2013-02-10 11:53:09 +00:00
if ( active_client )
2013-04-26 07:47:45 +00:00
active_client - > takeFocus ( ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2017-07-21 18:22:56 +00:00
void Workspace : : clientShortcutUpdated ( AbstractClient * c )
2011-01-30 14:34:42 +00:00
{
2013-07-23 05:02:52 +00:00
QString key = QStringLiteral ( " _k_session:%1 " ) . arg ( c - > window ( ) ) ;
2013-12-10 09:15:23 +00:00
QAction * action = findChild < QAction * > ( key ) ;
2011-01-30 14:34:42 +00:00
if ( ! c - > shortcut ( ) . isEmpty ( ) ) {
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 ( action = = nullptr ) { // new shortcut
2013-12-10 09:15:23 +00:00
action = new QAction ( this ) ;
2017-07-20 17:14:07 +00:00
kwinApp ( ) - > platform ( ) - > setupActionForGlobalAccel ( action ) ;
2016-09-13 11:02:20 +00:00
action - > setProperty ( " componentName " , QStringLiteral ( KWIN_NAME ) ) ;
2013-12-10 09:15:23 +00:00
action - > setObjectName ( key ) ;
2011-01-30 14:34:42 +00:00
action - > setText ( i18n ( " Activate Window (%1) " , c - > caption ( ) ) ) ;
2017-07-20 17:07:25 +00:00
connect ( action , & QAction : : triggered , c , std : : bind ( & Workspace : : activateClient , this , c , true ) ) ;
2011-01-30 14:34:42 +00:00
}
2008-09-30 20:44:40 +00:00
2008-06-01 11:36:07 +00:00
// no autoloading, since it's configured explicitly here and is not meant to be reused
// (the key is the window id anyway, which is kind of random)
2013-09-06 08:31:38 +00:00
KGlobalAccel : : self ( ) - > setShortcut ( action , QList < QKeySequence > ( ) < < c - > shortcut ( ) ,
2013-08-19 11:51:29 +00:00
KGlobalAccel : : NoAutoloading ) ;
action - > setEnabled ( true ) ;
2011-01-30 14:34:42 +00:00
} else {
2013-08-19 11:51:29 +00:00
KGlobalAccel : : self ( ) - > removeAllShortcuts ( action ) ;
2011-01-30 14:34:42 +00:00
delete action ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2015-03-06 09:05:40 +00:00
void Workspace : : performWindowOperation ( AbstractClient * c , Options : : WindowOperation op )
2011-01-30 14:34:42 +00:00
{
if ( ! c )
2007-04-29 17:35:43 +00:00
return ;
2011-01-30 14:34:42 +00:00
if ( op = = Options : : MoveOp | | op = = Options : : UnrestrictedMoveOp )
2020-04-02 16:18:01 +00:00
Cursors : : self ( ) - > mouse ( ) - > setPos ( c - > frameGeometry ( ) . center ( ) ) ;
2011-01-30 14:34:42 +00:00
if ( op = = Options : : ResizeOp | | op = = Options : : UnrestrictedResizeOp )
2020-04-02 16:18:01 +00:00
Cursors : : self ( ) - > mouse ( ) - > setPos ( c - > frameGeometry ( ) . bottomRight ( ) ) ;
2011-01-30 14:34:42 +00:00
switch ( op ) {
case Options : : MoveOp :
2020-04-02 16:18:01 +00:00
c - > performMouseCommand ( Options : : MouseMove , Cursors : : self ( ) - > mouse ( ) - > pos ( ) ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : UnrestrictedMoveOp :
2020-04-02 16:18:01 +00:00
c - > performMouseCommand ( Options : : MouseUnrestrictedMove , Cursors : : self ( ) - > mouse ( ) - > pos ( ) ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : ResizeOp :
2020-04-02 16:18:01 +00:00
c - > performMouseCommand ( Options : : MouseResize , Cursors : : self ( ) - > mouse ( ) - > pos ( ) ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : UnrestrictedResizeOp :
2020-04-02 16:18:01 +00:00
c - > performMouseCommand ( Options : : MouseUnrestrictedResize , Cursors : : self ( ) - > mouse ( ) - > pos ( ) ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : CloseOp :
2021-09-06 19:11:02 +00:00
QMetaObject : : invokeMethod ( c , & AbstractClient : : closeWindow , Qt : : QueuedConnection ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : MaximizeOp :
2014-12-02 12:49:08 +00:00
c - > maximize ( c - > maximizeMode ( ) = = MaximizeFull
? MaximizeRestore : MaximizeFull ) ;
2020-07-17 09:19:38 +00:00
takeActivity ( c , ActivityFocus | ActivityRaise ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : HMaximizeOp :
2014-12-02 12:49:08 +00:00
c - > maximize ( c - > maximizeMode ( ) ^ MaximizeHorizontal ) ;
2020-07-17 09:19:38 +00:00
takeActivity ( c , ActivityFocus | ActivityRaise ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : VMaximizeOp :
2014-12-02 12:49:08 +00:00
c - > maximize ( c - > maximizeMode ( ) ^ MaximizeVertical ) ;
2020-07-17 09:19:38 +00:00
takeActivity ( c , ActivityFocus | ActivityRaise ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : RestoreOp :
2014-12-02 12:49:08 +00:00
c - > maximize ( MaximizeRestore ) ;
2020-07-17 09:19:38 +00:00
takeActivity ( c , ActivityFocus | ActivityRaise ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : MinimizeOp :
c - > minimize ( ) ;
break ;
case Options : : ShadeOp :
2020-04-02 16:18:01 +00:00
c - > performMouseCommand ( Options : : MouseShade , Cursors : : self ( ) - > mouse ( ) - > pos ( ) ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : OnAllDesktopsOp :
c - > setOnAllDesktops ( ! c - > isOnAllDesktops ( ) ) ;
break ;
case Options : : FullScreenOp :
c - > setFullScreen ( ! c - > isFullScreen ( ) , true ) ;
break ;
case Options : : NoBorderOp :
wayland: Allow setting "no border" flag even without xdg decoration
Historically, noBorder() was used for two things:
* as a substitute for AbstractClient::isDecorated()
* to determine whether the AbstractClient should have a decoration
With async decoration updates refactoring, a few things around
noBorder() have changed, which exposed an existing bug in the handling
of borderless maximized windows.
It's possible to have a case where an initially maximized window makes
an xdg_toplevel.set_maximized request before the initial commit, but
creates the decoration object after the initial commit.
Since XdgToplevelClient::userCanSetNoBorder() would return false when
maximize() is called in XdgToplevelClient::initialize(), m_userNoBorder
won't be updated and therefore the window can end up having a server
side decoration.
Previously, it wasn't the case because kwin would do nothing if the
decoration is installed and its preferred mode changes after the initial
commit but before the surface is mapped. With async decoration fixes,
kwin would react as expected, which unfortunately has exposed the bug.
The root cause of the problem is the fact that noBorder() is overloaded,
which makes it error-prone.
This patch changes how the noBorder property is treated. Now, it only
indicates whether the compositor wants the window to have no borders. If
noBorder() is true, it means that the compositor doesn't want the window
to have a server-side decoration; on the other hand, if noBorder() is
false, it doesn't imply that the window should have a decoration.
BUG: 448740
2022-01-20 15:10:08 +00:00
if ( c - > userCanSetNoBorder ( ) ) {
c - > setNoBorder ( ! c - > noBorder ( ) ) ;
}
2011-01-30 14:34:42 +00:00
break ;
case Options : : KeepAboveOp : {
StackingUpdatesBlocker blocker ( this ) ;
bool was = c - > keepAbove ( ) ;
c - > setKeepAbove ( ! c - > keepAbove ( ) ) ;
if ( was & & ! c - > keepAbove ( ) )
raiseClient ( c ) ;
break ;
}
case Options : : KeepBelowOp : {
StackingUpdatesBlocker blocker ( this ) ;
bool was = c - > keepBelow ( ) ;
c - > setKeepBelow ( ! c - > keepBelow ( ) ) ;
if ( was & & ! c - > keepBelow ( ) )
2007-04-29 17:35:43 +00:00
lowerClient ( c ) ;
2011-01-30 14:34:42 +00:00
break ;
}
case Options : : OperationsOp :
2020-04-02 16:18:01 +00:00
c - > performMouseCommand ( Options : : MouseShade , Cursors : : self ( ) - > mouse ( ) - > pos ( ) ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : WindowRulesOp :
2013-04-26 12:40:35 +00:00
RuleBook : : self ( ) - > edit ( c , false ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : ApplicationRulesOp :
2013-04-26 12:40:35 +00:00
RuleBook : : self ( ) - > edit ( c , true ) ;
2011-01-30 14:34:42 +00:00
break ;
case Options : : SetupWindowShortcutOp :
setupWindowShortcut ( c ) ;
break ;
case Options : : LowerOp :
lowerClient ( c ) ;
break ;
case Options : : NoOp :
break ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotActivateAttentionWindow ( )
2011-01-30 14:34:42 +00:00
{
if ( attention_chain . count ( ) > 0 )
activateClient ( attention_chain . first ( ) ) ;
}
2007-04-29 17:35:43 +00:00
2012-11-16 07:23:47 +00:00
static uint senderValue ( QObject * sender )
2011-01-30 14:34:42 +00:00
{
2011-02-16 18:23:54 +00:00
QAction * act = qobject_cast < QAction * > ( sender ) ;
2012-11-16 07:23:47 +00:00
bool ok = false ; uint i = - 1 ;
2011-02-16 18:23:54 +00:00
if ( act )
i = act - > data ( ) . toUInt ( & ok ) ;
if ( ok )
return i ;
return - 1 ;
}
2012-02-21 17:42:09 +00:00
# define USABLE_ACTIVE_CLIENT (active_client && !(active_client->isDesktop() || active_client->isDock()))
2007-04-29 17:35:43 +00:00
2021-08-17 07:19:46 +00:00
void Workspace : : slotWindowToDesktop ( VirtualDesktop * desktop )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT ) {
2021-08-17 07:19:46 +00:00
sendClientToDesktop ( active_client , desktop - > x11DesktopNumber ( ) , true ) ;
2012-02-16 22:44:00 +00:00
}
2011-01-30 14:34:42 +00:00
}
2013-03-23 19:44:10 +00:00
static bool screenSwitchImpossible ( )
{
2021-08-28 18:58:29 +00:00
if ( ! options - > activeMouseScreen ( ) )
2013-03-23 19:44:10 +00:00
return false ;
QStringList args ;
2013-07-23 05:02:52 +00:00
args < < QStringLiteral ( " --passivepopup " ) < < i18n ( " The window manager is configured to consider the screen with the mouse on it as active one. \n "
" Therefore it is not possible to switch to a screen explicitly. " ) < < QStringLiteral ( " 20 " ) ;
KProcess : : startDetached ( QStringLiteral ( " kdialog " ) , args ) ;
2013-03-23 19:44:10 +00:00
return true ;
}
2021-08-28 14:48:12 +00:00
AbstractOutput * Workspace : : nextOutput ( AbstractOutput * reference ) const
{
const auto outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
const int index = outputs . indexOf ( reference ) ;
Q_ASSERT ( index ! = - 1 ) ;
return outputs [ ( index + 1 ) % outputs . count ( ) ] ;
}
AbstractOutput * Workspace : : previousOutput ( AbstractOutput * reference ) const
{
const auto outputs = kwinApp ( ) - > platform ( ) - > enabledOutputs ( ) ;
const int index = outputs . indexOf ( reference ) ;
Q_ASSERT ( index ! = - 1 ) ;
return outputs [ ( index + outputs . count ( ) - 1 ) % outputs . count ( ) ] ;
}
2011-02-16 18:23:54 +00:00
void Workspace : : slotSwitchToScreen ( )
2011-01-30 14:34:42 +00:00
{
2013-03-23 19:44:10 +00:00
if ( screenSwitchImpossible ( ) )
return ;
2021-08-28 14:48:12 +00:00
AbstractOutput * output = kwinApp ( ) - > platform ( ) - > findOutput ( senderValue ( sender ( ) ) ) ;
if ( output ) {
2021-08-28 18:49:38 +00:00
switchToOutput ( output ) ;
2021-08-28 14:48:12 +00:00
}
2011-01-30 14:34:42 +00:00
}
2007-05-07 13:13:48 +00:00
void Workspace : : slotSwitchToNextScreen ( )
2011-01-30 14:34:42 +00:00
{
2013-03-23 19:44:10 +00:00
if ( screenSwitchImpossible ( ) )
return ;
2021-08-28 18:58:29 +00:00
switchToOutput ( nextOutput ( activeOutput ( ) ) ) ;
2011-01-30 14:34:42 +00:00
}
2007-05-07 13:13:48 +00:00
2013-05-19 12:23:49 +00:00
void Workspace : : slotSwitchToPrevScreen ( )
{
if ( screenSwitchImpossible ( ) )
return ;
2021-08-28 18:58:29 +00:00
switchToOutput ( previousOutput ( activeOutput ( ) ) ) ;
2013-05-19 12:23:49 +00:00
}
2011-02-16 18:23:54 +00:00
void Workspace : : slotWindowToScreen ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT ) {
2021-08-28 14:51:00 +00:00
AbstractOutput * output = kwinApp ( ) - > platform ( ) - > findOutput ( senderValue ( sender ( ) ) ) ;
if ( output ) {
sendClientToOutput ( active_client , output ) ;
2012-02-16 22:44:00 +00:00
}
2007-05-07 13:13:48 +00:00
}
2011-01-30 14:34:42 +00:00
}
2007-05-07 13:13:48 +00:00
void Workspace : : slotWindowToNextScreen ( )
2011-01-30 14:34:42 +00:00
{
2021-08-28 14:51:00 +00:00
if ( USABLE_ACTIVE_CLIENT ) {
sendClientToOutput ( active_client , nextOutput ( active_client - > output ( ) ) ) ;
}
2011-01-30 14:34:42 +00:00
}
2007-05-07 13:13:48 +00:00
2013-05-19 12:23:49 +00:00
void Workspace : : slotWindowToPrevScreen ( )
{
2021-08-28 14:51:00 +00:00
if ( USABLE_ACTIVE_CLIENT ) {
sendClientToOutput ( active_client , previousOutput ( active_client - > output ( ) ) ) ;
}
2013-05-19 12:23:49 +00:00
}
2019-02-02 18:17:44 +00:00
/**
* Maximizes the active client .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowMaximize ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : MaximizeOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Maximizes the active client vertically .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowMaximizeVertical ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : VMaximizeOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Maximizes the active client horiozontally .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowMaximizeHorizontal ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : HMaximizeOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Minimizes the active client .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowMinimize ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : MinimizeOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Shades / unshades the active client respectively .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowShade ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : ShadeOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Raises the active client .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowRaise ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
raiseClient ( active_client ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Lowers the active client .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowLower ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT ) {
lowerClient ( active_client ) ;
2009-01-28 10:03:37 +00:00
// As this most likely makes the window no longer visible change the
// keyboard focus to the next available window.
//activateNextClient( c ); // Doesn't work when we lower a child window
2012-02-21 22:55:55 +00:00
if ( active_client - > isActive ( ) & & options - > focusPolicyIsReasonable ( ) ) {
2012-03-07 23:25:08 +00:00
if ( options - > isNextFocusPrefersMouse ( ) ) {
2021-08-28 14:52:02 +00:00
AbstractClient * next = clientUnderMouse ( active_client - > output ( ) ) ;
2012-02-21 22:55:55 +00:00
if ( next & & next ! = active_client )
requestFocus ( next , false ) ;
} else {
2021-08-28 14:28:54 +00:00
activateClient ( topClientOnDesktop ( VirtualDesktopManager : : self ( ) - > currentDesktop ( ) ) ) ;
2012-02-21 22:55:55 +00:00
}
}
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-02-02 18:17:44 +00:00
/**
* Does a toggle - raise - and - lower on the active client .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowRaiseOrLower ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
raiseOrLowerClient ( active_client ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowOnAllDesktops ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
active_client - > setOnAllDesktops ( ! active_client - > isOnAllDesktops ( ) ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowFullScreen ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : FullScreenOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowNoBorder ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : NoBorderOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowAbove ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : KeepAboveOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowBelow ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : KeepBelowOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotSetupWindowShortcut ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : SetupWindowShortcutOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Toggles show desktop .
2019-07-29 18:58:33 +00:00
*/
2009-09-12 08:01:44 +00:00
void Workspace : : slotToggleShowDesktop ( )
2011-01-30 14:34:42 +00:00
{
setShowingDesktop ( ! showingDesktop ( ) ) ;
}
2009-09-12 08:01:44 +00:00
2012-11-16 07:23:47 +00:00
template < typename Direction >
2015-03-06 14:17:13 +00:00
void windowToDesktop ( AbstractClient * c )
2012-11-16 07:23:47 +00:00
{
VirtualDesktopManager * vds = VirtualDesktopManager : : self ( ) ;
Workspace * ws = Workspace : : self ( ) ;
Direction functor ;
// TODO: why is options->isRollOverDesktops() not honored?
2016-11-10 13:02:14 +00:00
const auto desktop = functor ( nullptr , true ) ;
2012-11-16 07:23:47 +00:00
if ( c & & ! c - > isDesktop ( )
& & ! c - > isDock ( ) ) {
2019-04-18 12:28:11 +00:00
ws - > setMoveResizeClient ( c ) ;
2012-11-16 07:23:47 +00:00
vds - > setCurrent ( desktop ) ;
2019-04-18 12:28:11 +00:00
ws - > setMoveResizeClient ( nullptr ) ;
2012-11-16 07:23:47 +00:00
}
}
2019-02-02 18:17:44 +00:00
/**
* Moves the active client to the next desktop .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowToNextDesktop ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
windowToNextDesktop ( active_client ) ;
2011-01-30 14:34:42 +00:00
}
2008-06-02 19:52:02 +00:00
2015-03-06 14:17:13 +00:00
void Workspace : : windowToNextDesktop ( AbstractClient * c )
2011-01-30 14:34:42 +00:00
{
2012-11-16 07:23:47 +00:00
windowToDesktop < DesktopNext > ( c ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Moves the active client to the previous desktop .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowToPreviousDesktop ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
windowToPreviousDesktop ( active_client ) ;
2011-01-30 14:34:42 +00:00
}
2008-06-02 19:52:02 +00:00
2015-03-06 14:17:13 +00:00
void Workspace : : windowToPreviousDesktop ( AbstractClient * c )
2011-01-30 14:34:42 +00:00
{
2012-11-16 07:23:47 +00:00
windowToDesktop < DesktopPrevious > ( c ) ;
}
template < typename Direction >
void activeClientToDesktop ( )
{
VirtualDesktopManager * vds = VirtualDesktopManager : : self ( ) ;
Workspace * ws = Workspace : : self ( ) ;
2021-08-17 07:19:46 +00:00
VirtualDesktop * current = vds - > currentDesktop ( ) ;
2012-11-16 07:23:47 +00:00
Direction functor ;
2021-08-17 07:19:46 +00:00
VirtualDesktop * newCurrent = functor ( current , options - > isRollOverDesktops ( ) ) ;
if ( newCurrent = = current ) {
2012-11-16 07:23:47 +00:00
return ;
2007-04-29 17:35:43 +00:00
}
2019-04-18 12:28:11 +00:00
ws - > setMoveResizeClient ( ws - > activeClient ( ) ) ;
2021-08-17 07:19:46 +00:00
vds - > setCurrent ( newCurrent ) ;
2019-04-18 12:28:11 +00:00
ws - > setMoveResizeClient ( nullptr ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowToDesktopRight ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT ) {
2012-11-16 07:23:47 +00:00
activeClientToDesktop < DesktopRight > ( ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowToDesktopLeft ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT ) {
2012-11-16 07:23:47 +00:00
activeClientToDesktop < DesktopLeft > ( ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowToDesktopUp ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT ) {
2012-11-16 07:23:47 +00:00
activeClientToDesktop < DesktopAbove > ( ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowToDesktopDown ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT ) {
2012-11-16 07:23:47 +00:00
activeClientToDesktop < DesktopBelow > ( ) ;
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-02-02 18:17:44 +00:00
/**
* Kill Window feature , similar to xkill .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotKillWindow ( )
2011-01-30 14:34:42 +00:00
{
2012-12-27 13:26:46 +00:00
if ( m_windowKiller . isNull ( ) ) {
m_windowKiller . reset ( new KillWindow ( ) ) ;
}
m_windowKiller - > start ( ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Switches to the nearest window in given direction .
2019-07-29 18:58:33 +00:00
*/
2011-01-30 14:34:42 +00:00
void Workspace : : switchWindow ( Direction direction )
{
if ( ! active_client )
2009-10-03 13:09:38 +00:00
return ;
2015-03-12 11:08:54 +00:00
AbstractClient * c = active_client ;
2021-08-17 06:44:30 +00:00
VirtualDesktop * desktop = VirtualDesktopManager : : self ( ) - > currentDesktop ( ) ;
Cycle between windows of the same desktop on switch
Summary:
When switching virtual desktops using shortcuts, the behavior is to
switch to a virtual desktop in the opposite direction if the current
one is on the edges of the layout. For example, in a one row layout with
4 virtual desktops, "Switch One Desktop to the Left" while in virtual
desktop # 1 will send the user to virtual desktop # 4. Likewise, in a 3
rows layout with 9 virtual desktops, "Switch One Desktop Down" while in
virtual desktop # 8 will lead the user to desktop # 2.
This patch uses the same behavior whilst changing windows using
"Switch to Window Above|Below|to the Right|to the Left".
For example, in a 3 display set-up (my set-up), the user would go from an
application in the rightmost position to an application in the leftmost
position using just one key combination: "Switch to Window to the Right".
Currently, the shortcuts are no-op in these cases (ie, trying "Switch to
Window to the Left" from the leftmost window has no outcome, which is
mostly accurate with the shortcut semantics but totally useless in behavior).
Reviewers: #vdg, #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: luebking, subdiff, colomar, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3602
2016-12-22 20:12:46 +00:00
2009-10-03 13:09:38 +00:00
// Centre of the active window
2019-09-27 10:01:10 +00:00
QPoint curPos ( c - > x ( ) + c - > width ( ) / 2 , c - > y ( ) + c - > height ( ) / 2 ) ;
2009-10-03 13:09:38 +00:00
2021-08-17 06:44:30 +00:00
if ( ! switchWindow ( c , direction , curPos , desktop ) ) {
Cycle between windows of the same desktop on switch
Summary:
When switching virtual desktops using shortcuts, the behavior is to
switch to a virtual desktop in the opposite direction if the current
one is on the edges of the layout. For example, in a one row layout with
4 virtual desktops, "Switch One Desktop to the Left" while in virtual
desktop # 1 will send the user to virtual desktop # 4. Likewise, in a 3
rows layout with 9 virtual desktops, "Switch One Desktop Down" while in
virtual desktop # 8 will lead the user to desktop # 2.
This patch uses the same behavior whilst changing windows using
"Switch to Window Above|Below|to the Right|to the Left".
For example, in a 3 display set-up (my set-up), the user would go from an
application in the rightmost position to an application in the leftmost
position using just one key combination: "Switch to Window to the Right".
Currently, the shortcuts are no-op in these cases (ie, trying "Switch to
Window to the Left" from the leftmost window has no outcome, which is
mostly accurate with the shortcut semantics but totally useless in behavior).
Reviewers: #vdg, #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: luebking, subdiff, colomar, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3602
2016-12-22 20:12:46 +00:00
auto opposite = [ & ] {
switch ( direction ) {
case DirectionNorth :
2021-08-30 07:52:27 +00:00
return QPoint ( curPos . x ( ) , geometry ( ) . height ( ) ) ;
Cycle between windows of the same desktop on switch
Summary:
When switching virtual desktops using shortcuts, the behavior is to
switch to a virtual desktop in the opposite direction if the current
one is on the edges of the layout. For example, in a one row layout with
4 virtual desktops, "Switch One Desktop to the Left" while in virtual
desktop # 1 will send the user to virtual desktop # 4. Likewise, in a 3
rows layout with 9 virtual desktops, "Switch One Desktop Down" while in
virtual desktop # 8 will lead the user to desktop # 2.
This patch uses the same behavior whilst changing windows using
"Switch to Window Above|Below|to the Right|to the Left".
For example, in a 3 display set-up (my set-up), the user would go from an
application in the rightmost position to an application in the leftmost
position using just one key combination: "Switch to Window to the Right".
Currently, the shortcuts are no-op in these cases (ie, trying "Switch to
Window to the Left" from the leftmost window has no outcome, which is
mostly accurate with the shortcut semantics but totally useless in behavior).
Reviewers: #vdg, #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: luebking, subdiff, colomar, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3602
2016-12-22 20:12:46 +00:00
case DirectionSouth :
return QPoint ( curPos . x ( ) , 0 ) ;
case DirectionEast :
return QPoint ( 0 , curPos . y ( ) ) ;
case DirectionWest :
2021-08-30 07:52:27 +00:00
return QPoint ( geometry ( ) . width ( ) , curPos . y ( ) ) ;
Cycle between windows of the same desktop on switch
Summary:
When switching virtual desktops using shortcuts, the behavior is to
switch to a virtual desktop in the opposite direction if the current
one is on the edges of the layout. For example, in a one row layout with
4 virtual desktops, "Switch One Desktop to the Left" while in virtual
desktop # 1 will send the user to virtual desktop # 4. Likewise, in a 3
rows layout with 9 virtual desktops, "Switch One Desktop Down" while in
virtual desktop # 8 will lead the user to desktop # 2.
This patch uses the same behavior whilst changing windows using
"Switch to Window Above|Below|to the Right|to the Left".
For example, in a 3 display set-up (my set-up), the user would go from an
application in the rightmost position to an application in the leftmost
position using just one key combination: "Switch to Window to the Right".
Currently, the shortcuts are no-op in these cases (ie, trying "Switch to
Window to the Left" from the leftmost window has no outcome, which is
mostly accurate with the shortcut semantics but totally useless in behavior).
Reviewers: #vdg, #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: luebking, subdiff, colomar, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3602
2016-12-22 20:12:46 +00:00
default :
Q_UNREACHABLE ( ) ;
}
} ;
2021-08-17 06:44:30 +00:00
switchWindow ( c , direction , opposite ( ) , desktop ) ;
Cycle between windows of the same desktop on switch
Summary:
When switching virtual desktops using shortcuts, the behavior is to
switch to a virtual desktop in the opposite direction if the current
one is on the edges of the layout. For example, in a one row layout with
4 virtual desktops, "Switch One Desktop to the Left" while in virtual
desktop # 1 will send the user to virtual desktop # 4. Likewise, in a 3
rows layout with 9 virtual desktops, "Switch One Desktop Down" while in
virtual desktop # 8 will lead the user to desktop # 2.
This patch uses the same behavior whilst changing windows using
"Switch to Window Above|Below|to the Right|to the Left".
For example, in a 3 display set-up (my set-up), the user would go from an
application in the rightmost position to an application in the leftmost
position using just one key combination: "Switch to Window to the Right".
Currently, the shortcuts are no-op in these cases (ie, trying "Switch to
Window to the Left" from the leftmost window has no outcome, which is
mostly accurate with the shortcut semantics but totally useless in behavior).
Reviewers: #vdg, #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: luebking, subdiff, colomar, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3602
2016-12-22 20:12:46 +00:00
}
}
2021-08-17 06:44:30 +00:00
bool Workspace : : switchWindow ( AbstractClient * c , Direction direction , QPoint curPos , VirtualDesktop * desktop )
Cycle between windows of the same desktop on switch
Summary:
When switching virtual desktops using shortcuts, the behavior is to
switch to a virtual desktop in the opposite direction if the current
one is on the edges of the layout. For example, in a one row layout with
4 virtual desktops, "Switch One Desktop to the Left" while in virtual
desktop # 1 will send the user to virtual desktop # 4. Likewise, in a 3
rows layout with 9 virtual desktops, "Switch One Desktop Down" while in
virtual desktop # 8 will lead the user to desktop # 2.
This patch uses the same behavior whilst changing windows using
"Switch to Window Above|Below|to the Right|to the Left".
For example, in a 3 display set-up (my set-up), the user would go from an
application in the rightmost position to an application in the leftmost
position using just one key combination: "Switch to Window to the Right".
Currently, the shortcuts are no-op in these cases (ie, trying "Switch to
Window to the Left" from the leftmost window has no outcome, which is
mostly accurate with the shortcut semantics but totally useless in behavior).
Reviewers: #vdg, #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: luebking, subdiff, colomar, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3602
2016-12-22 20:12:46 +00:00
{
2017-06-19 16:17:46 +00:00
AbstractClient * switchTo = nullptr ;
Cycle between windows of the same desktop on switch
Summary:
When switching virtual desktops using shortcuts, the behavior is to
switch to a virtual desktop in the opposite direction if the current
one is on the edges of the layout. For example, in a one row layout with
4 virtual desktops, "Switch One Desktop to the Left" while in virtual
desktop # 1 will send the user to virtual desktop # 4. Likewise, in a 3
rows layout with 9 virtual desktops, "Switch One Desktop Down" while in
virtual desktop # 8 will lead the user to desktop # 2.
This patch uses the same behavior whilst changing windows using
"Switch to Window Above|Below|to the Right|to the Left".
For example, in a 3 display set-up (my set-up), the user would go from an
application in the rightmost position to an application in the leftmost
position using just one key combination: "Switch to Window to the Right".
Currently, the shortcuts are no-op in these cases (ie, trying "Switch to
Window to the Left" from the leftmost window has no outcome, which is
mostly accurate with the shortcut semantics but totally useless in behavior).
Reviewers: #vdg, #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: luebking, subdiff, colomar, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3602
2016-12-22 20:12:46 +00:00
int bestScore = 0 ;
Drop some custom list typedefs
Summary:
Qt has its own thing where a type might also have corresponding list
alias, e.g. QObject and QObjectList, QWidget and QWidgetList. I don't
know why Qt does that, maybe for some historical reasons, but what
matters is that we copy this pattern here in KWin. While this pattern
might be useful with some long list types, for example
QList<QWeakPointer<TabBoxClient>> TabBoxClientList
in general, it causes more harm than good. For example, we've got two
new client types, do we need corresponding list typedefs for them? If
no, why do we have ClientList and so on?
Another problem with these typedefs is that you need to include utils.h
header in order to use them. A better way to handle such things is to
just forward declare a client class (if that's possible) and use it
directly with QList or QVector. This way translation units don't get
"bloated" with utils.h stuff for no apparent reason.
So, in order to make code more consistent and easier to follow, this
change drops some of our custom typedefs. Namely ConstClientList,
ClientList, DeletedList, UnmanagedList, ToplevelList, and GroupList.
Test Plan: Compiles.
Reviewers: #kwin
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24950
2019-10-16 09:11:04 +00:00
QList < Toplevel * > clist = stackingOrder ( ) ;
2019-08-28 08:46:30 +00:00
for ( auto i = clist . rbegin ( ) ; i ! = clist . rend ( ) ; + + i ) {
2017-06-19 16:17:46 +00:00
auto client = qobject_cast < AbstractClient * > ( * i ) ;
2012-04-08 08:07:35 +00:00
if ( ! client ) {
continue ;
}
if ( client - > wantsTabFocus ( ) & & * i ! = c & &
2021-08-17 06:44:30 +00:00
client - > isOnDesktop ( desktop ) & & ! client - > isMinimized ( ) & & ( * i ) - > isOnCurrentActivity ( ) ) {
2009-10-03 13:09:38 +00:00
// Centre of the other window
2019-09-27 10:01:10 +00:00
const QPoint other ( client - > x ( ) + client - > width ( ) / 2 , client - > y ( ) + client - > height ( ) / 2 ) ;
2009-10-03 13:09:38 +00:00
int distance ;
int offset ;
2011-01-30 14:34:42 +00:00
switch ( direction ) {
case DirectionNorth :
distance = curPos . y ( ) - other . y ( ) ;
offset = qAbs ( other . x ( ) - curPos . x ( ) ) ;
break ;
case DirectionEast :
distance = other . x ( ) - curPos . x ( ) ;
offset = qAbs ( other . y ( ) - curPos . y ( ) ) ;
break ;
case DirectionSouth :
distance = other . y ( ) - curPos . y ( ) ;
offset = qAbs ( other . x ( ) - curPos . x ( ) ) ;
break ;
case DirectionWest :
distance = curPos . x ( ) - other . x ( ) ;
offset = qAbs ( other . y ( ) - curPos . y ( ) ) ;
break ;
default :
distance = - 1 ;
offset = - 1 ;
}
2009-10-03 13:09:38 +00:00
2011-01-30 14:34:42 +00:00
if ( distance > 0 ) {
2009-10-03 13:09:38 +00:00
// Inverse score
2011-01-30 14:34:42 +00:00
int score = distance + offset + ( ( offset * offset ) / distance ) ;
if ( score < bestScore | | ! switchTo ) {
2012-04-08 08:07:35 +00:00
switchTo = client ;
2009-10-03 13:09:38 +00:00
bestScore = score ;
}
}
}
}
2012-03-15 23:13:29 +00:00
if ( switchTo ) {
2011-01-30 14:34:42 +00:00
activateClient ( switchTo ) ;
2012-03-15 23:13:29 +00:00
}
Cycle between windows of the same desktop on switch
Summary:
When switching virtual desktops using shortcuts, the behavior is to
switch to a virtual desktop in the opposite direction if the current
one is on the edges of the layout. For example, in a one row layout with
4 virtual desktops, "Switch One Desktop to the Left" while in virtual
desktop # 1 will send the user to virtual desktop # 4. Likewise, in a 3
rows layout with 9 virtual desktops, "Switch One Desktop Down" while in
virtual desktop # 8 will lead the user to desktop # 2.
This patch uses the same behavior whilst changing windows using
"Switch to Window Above|Below|to the Right|to the Left".
For example, in a 3 display set-up (my set-up), the user would go from an
application in the rightmost position to an application in the leftmost
position using just one key combination: "Switch to Window to the Right".
Currently, the shortcuts are no-op in these cases (ie, trying "Switch to
Window to the Left" from the leftmost window has no outcome, which is
mostly accurate with the shortcut semantics but totally useless in behavior).
Reviewers: #vdg, #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: luebking, subdiff, colomar, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3602
2016-12-22 20:12:46 +00:00
return switchTo ;
2011-01-30 14:34:42 +00:00
}
2009-10-03 13:09:38 +00:00
2019-02-02 18:17:44 +00:00
/**
* Shows the window operations popup menu for the active client .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowOperations ( )
2011-01-30 14:34:42 +00:00
{
if ( ! active_client )
2007-04-29 17:35:43 +00:00
return ;
QPoint pos = active_client - > pos ( ) + active_client - > clientPos ( ) ;
2013-05-03 17:13:12 +00:00
showWindowMenu ( QRect ( pos , pos ) , active_client ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2015-03-06 14:33:13 +00:00
void Workspace : : showWindowMenu ( const QRect & pos , AbstractClient * cl )
2011-01-30 14:34:42 +00:00
{
2012-08-19 10:00:53 +00:00
m_userActionsMenu - > show ( pos , cl ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2017-01-11 09:21:03 +00:00
void Workspace : : showApplicationMenu ( const QRect & pos , AbstractClient * c , int actionId )
{
2019-09-27 10:01:10 +00:00
ApplicationMenu : : self ( ) - > showApplicationMenu ( c - > pos ( ) + pos . bottomLeft ( ) , c , actionId ) ;
2017-01-11 09:21:03 +00:00
}
2019-02-02 18:17:44 +00:00
/**
* Closes the active client .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowClose ( )
2011-01-30 14:34:42 +00:00
{
2009-09-13 11:36:45 +00:00
// TODO: why?
// if ( tab_box->isVisible())
// return;
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : CloseOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Starts keyboard move mode for the active client .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowMove ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : UnrestrictedMoveOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2019-02-02 18:17:44 +00:00
/**
* Starts keyboard resize mode for the active client .
2019-07-29 18:58:33 +00:00
*/
2007-04-29 17:35:43 +00:00
void Workspace : : slotWindowResize ( )
2011-01-30 14:34:42 +00:00
{
2012-02-16 22:44:00 +00:00
if ( USABLE_ACTIVE_CLIENT )
performWindowOperation ( active_client , Options : : UnrestrictedResizeOp ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2012-02-16 22:44:00 +00:00
# undef USABLE_ACTIVE_CLIENT
2017-07-21 18:22:56 +00:00
void AbstractClient : : setShortcut ( const QString & _cut )
2011-01-30 14:34:42 +00:00
{
QString cut = rules ( ) - > checkShortcut ( _cut ) ;
2017-07-21 18:22:56 +00:00
auto updateShortcut = [ this ] ( const QKeySequence & cut = QKeySequence ( ) ) {
if ( _shortcut = = cut )
return ;
_shortcut = cut ;
setShortcutInternal ( ) ;
} ;
if ( cut . isEmpty ( ) ) {
updateShortcut ( ) ;
return ;
}
2013-11-11 23:20:38 +00:00
if ( cut = = shortcut ( ) . toString ( ) ) {
return ; // no change
}
2007-04-29 17:35:43 +00:00
// Format:
// base+(abcdef)<space>base+(abcdef)
2013-02-13 12:57:21 +00:00
// E.g. Alt+Ctrl+(ABCDEF);Meta+X,Meta+(ABCDEF)
2015-11-05 14:14:06 +00:00
if ( ! cut . contains ( QLatin1Char ( ' ( ' ) ) & & ! cut . contains ( QLatin1Char ( ' ) ' ) ) & & ! cut . contains ( QLatin1String ( " - " ) ) ) {
2013-09-06 08:31:38 +00:00
if ( workspace ( ) - > shortcutAvailable ( cut , this ) )
2017-07-21 18:22:56 +00:00
updateShortcut ( QKeySequence ( cut ) ) ;
2007-04-29 17:35:43 +00:00
else
2017-07-21 18:22:56 +00:00
updateShortcut ( ) ;
2007-04-29 17:35:43 +00:00
return ;
2011-01-30 14:34:42 +00:00
}
2021-06-20 10:56:24 +00:00
const QRegularExpression reg ( QStringLiteral ( " (.* \\ +) \ \ ( ( . * ) \ \ ) " )) ;
2013-09-06 08:31:38 +00:00
QList < QKeySequence > keys ;
2013-07-23 05:02:52 +00:00
QStringList groups = cut . split ( QStringLiteral ( " - " ) ) ;
2011-01-30 14:34:42 +00:00
for ( QStringList : : ConstIterator it = groups . constBegin ( ) ;
it ! = groups . constEnd ( ) ;
+ + it ) {
2021-06-20 10:56:24 +00:00
const QRegularExpressionMatch match = reg . match ( * it ) ;
if ( match . hasMatch ( ) ) {
const QString base = match . captured ( 1 ) ;
const QString list = match . captured ( 2 ) ;
2011-01-30 14:34:42 +00:00
for ( int i = 0 ;
i < list . length ( ) ;
+ + i ) {
2013-09-06 08:31:38 +00:00
QKeySequence c ( base + list [ i ] ) ;
2011-01-30 14:34:42 +00:00
if ( ! c . isEmpty ( ) )
keys . append ( c ) ;
2007-04-29 17:35:43 +00:00
}
2013-02-13 12:55:08 +00:00
} else {
// regexp doesn't match, so it should be a normal shortcut
2013-09-06 08:31:38 +00:00
QKeySequence c ( * it ) ;
2013-02-13 12:55:08 +00:00
if ( ! c . isEmpty ( ) ) {
keys . append ( c ) ;
}
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
}
2013-09-06 08:31:38 +00:00
for ( auto it = keys . constBegin ( ) ;
2011-01-30 14:34:42 +00:00
it ! = keys . constEnd ( ) ;
+ + it ) {
if ( _shortcut = = * it ) // current one is in the list
2007-04-29 17:35:43 +00:00
return ;
2011-01-30 14:34:42 +00:00
}
2013-09-06 08:31:38 +00:00
for ( auto it = keys . constBegin ( ) ;
2011-01-30 14:34:42 +00:00
it ! = keys . constEnd ( ) ;
+ + it ) {
if ( workspace ( ) - > shortcutAvailable ( * it , this ) ) {
2017-07-21 18:22:56 +00:00
updateShortcut ( * it ) ;
2007-04-29 17:35:43 +00:00
return ;
}
}
2017-07-21 18:22:56 +00:00
updateShortcut ( ) ;
2011-01-30 14:34:42 +00:00
}
2007-04-29 17:35:43 +00:00
2017-07-21 18:22:56 +00:00
void AbstractClient : : setShortcutInternal ( )
{
2017-08-03 05:11:40 +00:00
updateCaption ( ) ;
2017-07-21 18:22:56 +00:00
workspace ( ) - > clientShortcutUpdated ( this ) ;
}
2019-09-24 08:48:08 +00:00
void X11Client : : setShortcutInternal ( )
2011-01-30 14:34:42 +00:00
{
2007-04-29 17:35:43 +00:00
updateCaption ( ) ;
2008-09-30 12:03:20 +00:00
#if 0
2011-01-30 14:34:42 +00:00
workspace ( ) - > clientShortcutUpdated ( this ) ;
2008-09-30 12:03:20 +00:00
# else
// Workaround for kwin<->kglobalaccel deadlock, when KWin has X grab and the kded
// kglobalaccel module tries to create the key grab. KWin should preferably grab
// they keys itself anyway :(.
2017-07-20 17:07:25 +00:00
QTimer : : singleShot ( 0 , this , std : : bind ( & Workspace : : clientShortcutUpdated , workspace ( ) , this ) ) ;
2008-09-30 12:03:20 +00:00
# endif
2011-01-30 14:34:42 +00:00
}
2008-09-30 12:03:20 +00:00
2017-07-21 18:22:56 +00:00
bool Workspace : : shortcutAvailable ( const QKeySequence & cut , AbstractClient * ignore ) const
2011-01-30 14:34:42 +00:00
{
2013-11-11 23:20:38 +00:00
if ( ignore & & cut = = ignore - > shortcut ( ) )
return true ;
2013-02-13 12:53:45 +00:00
2021-09-09 15:23:03 +00:00
// Check if the shortcut is already registered
2022-01-21 10:02:40 +00:00
const QList < KGlobalShortcutInfo > registeredShortcuts = KGlobalAccel : : globalShortcutsByKey ( cut ) ;
2022-01-04 13:00:41 +00:00
for ( const auto & shortcut : registeredShortcuts ) {
2021-09-09 15:23:03 +00:00
// Only return "not available" if is not a client activation shortcut, as it may be no longer valid
if ( ! shortcut . uniqueName ( ) . startsWith ( QStringLiteral ( " _k_session: " ) ) ) {
return false ;
}
2013-02-13 12:53:45 +00:00
}
2021-09-09 15:23:03 +00:00
// Check now conflicts with activation shortcuts for current clients
for ( const auto client : qAsConst ( m_allClients ) ) {
if ( client ! = ignore & & client - > shortcut ( ) = = cut ) {
2008-06-02 19:52:02 +00:00
return false ;
2021-09-09 15:23:03 +00:00
}
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
return true ;
}
2007-04-29 17:35:43 +00:00
} // namespace