2012-11-16 07:23:47 +00:00
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project .
Copyright ( C ) 2009 Lucas Murray < lmurray @ undefinedfire . com >
Copyright ( C ) 2012 Martin Gräßlin < mgraesslin @ kde . org >
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "virtualdesktops.h"
2013-07-10 09:45:51 +00:00
# include "input.h"
2012-11-16 07:23:47 +00:00
// KDE
2014-03-17 15:24:10 +00:00
# include <KConfigGroup>
# include <KGlobalAccel>
# include <KLocalizedString>
2014-03-18 13:32:53 +00:00
# include <NETWM>
[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
# include <KWayland/Server/plasmavirtualdesktop_interface.h>
2013-12-10 08:11:16 +00:00
// Qt
# include <QAction>
[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
# include <QUuid>
2012-11-16 07:23:47 +00:00
2016-11-10 13:02:14 +00:00
# include <algorithm>
[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
# include <QDebug>
2012-11-16 07:23:47 +00:00
namespace KWin {
extern int screen_number ;
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
static bool s_loadingDesktopSettings = false ;
2012-11-16 07:23:47 +00:00
2019-01-18 10:19:50 +00:00
static QByteArray generateDesktopId ( )
{
return QUuid : : createUuid ( ) . toString ( QUuid : : WithoutBraces ) . toUtf8 ( ) ;
}
2016-11-07 09:55:18 +00:00
VirtualDesktop : : VirtualDesktop ( QObject * parent )
: QObject ( parent )
{
}
2017-04-04 16:56:10 +00:00
VirtualDesktop : : ~ VirtualDesktop ( )
{
emit aboutToBeDestroyed ( ) ;
}
2016-11-07 09:55:18 +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 VirtualDesktopManager : : setVirtualDesktopManagement ( KWayland : : Server : : PlasmaVirtualDesktopManagementInterface * management )
{
using namespace KWayland : : Server ;
Q_ASSERT ( ! m_virtualDesktopManagement ) ;
m_virtualDesktopManagement = management ;
2019-01-17 22:08:54 +00:00
auto createPlasmaVirtualDesktop = [ this ] ( VirtualDesktop * desktop ) {
PlasmaVirtualDesktopInterface * pvd = m_virtualDesktopManagement - > createDesktop ( desktop - > id ( ) , desktop - > x11DesktopNumber ( ) - 1 ) ;
pvd - > setName ( desktop - > name ( ) ) ;
pvd - > sendDone ( ) ;
connect ( desktop , & VirtualDesktop : : nameChanged , pvd ,
[ desktop , pvd ] {
pvd - > setName ( desktop - > name ( ) ) ;
2019-01-25 10:33:24 +00:00
pvd - > sendDone ( ) ;
2019-01-17 22:08:54 +00:00
}
) ;
connect ( pvd , & PlasmaVirtualDesktopInterface : : activateRequested , this ,
[ this , desktop ] {
setCurrent ( desktop ) ;
}
) ;
} ;
2019-01-18 22:31:03 +00:00
connect ( this , & VirtualDesktopManager : : desktopCreated , m_virtualDesktopManagement , createPlasmaVirtualDesktop ) ;
[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
2019-01-22 09:28:50 +00:00
connect ( this , & VirtualDesktopManager : : rowsChanged , m_virtualDesktopManagement ,
2019-01-25 11:44:00 +00:00
[ this ] ( uint rows ) {
m_virtualDesktopManagement - > setRows ( rows ) ;
m_virtualDesktopManagement - > sendDone ( ) ;
}
) ;
[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
//handle removed: from VirtualDesktopManager to the wayland interface
2019-01-18 22:31:03 +00:00
connect ( this , & VirtualDesktopManager : : desktopRemoved , m_virtualDesktopManagement ,
[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
[ this ] ( VirtualDesktop * desktop ) {
m_virtualDesktopManagement - > removeDesktop ( desktop - > id ( ) ) ;
}
) ;
//create a new desktop when the client asks to
connect ( m_virtualDesktopManagement , & PlasmaVirtualDesktopManagementInterface : : desktopCreateRequested , this ,
[ this ] ( const QString & name , quint32 position ) {
2019-01-18 22:12:49 +00:00
createVirtualDesktop ( position , name ) ;
[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
}
) ;
//remove when the client asks to
connect ( m_virtualDesktopManagement , & PlasmaVirtualDesktopManagementInterface : : desktopRemoveRequested , this ,
[ this ] ( const QString & id ) {
//here there can be some nice kauthorized check?
//remove only from VirtualDesktopManager, the other connections will remove it from m_virtualDesktopManagement as well
removeVirtualDesktop ( id . toUtf8 ( ) ) ;
}
) ;
2019-01-17 22:08:54 +00:00
std : : for_each ( m_desktops . constBegin ( ) , m_desktops . constEnd ( ) , createPlasmaVirtualDesktop ) ;
[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
//Now we are sure all ids are there
save ( ) ;
2019-01-18 22:31:03 +00:00
connect ( this , & VirtualDesktopManager : : currentChanged , m_virtualDesktopManagement ,
[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
[ this ] ( ) {
for ( auto * deskInt : m_virtualDesktopManagement - > desktops ( ) ) {
if ( deskInt - > id ( ) = = currentDesktop ( ) - > id ( ) ) {
deskInt - > setActive ( true ) ;
} else {
deskInt - > setActive ( false ) ;
}
}
}
) ;
}
2016-11-07 09:55:18 +00:00
void VirtualDesktop : : setId ( const QByteArray & id )
{
Q_ASSERT ( m_id . isEmpty ( ) ) ;
m_id = id ;
}
void VirtualDesktop : : setX11DesktopNumber ( uint number )
{
[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
//x11DesktopNumber can be changed now
if ( static_cast < uint > ( m_x11DesktopNumber ) = = number ) {
return ;
}
2016-11-07 09:55:18 +00:00
m_x11DesktopNumber = number ;
[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_x11DesktopNumber ! = 0 ) {
emit x11DesktopNumberChanged ( ) ;
}
2016-11-07 09:55:18 +00:00
}
void VirtualDesktop : : setName ( const QString & name )
{
if ( m_name = = name ) {
return ;
}
m_name = name ;
emit nameChanged ( ) ;
}
2012-11-16 07:23:47 +00:00
VirtualDesktopGrid : : VirtualDesktopGrid ( )
: m_size ( 1 , 2 ) // Default to tow rows
2016-11-10 13:02:14 +00:00
, m_grid ( QVector < QVector < VirtualDesktop * > > { QVector < VirtualDesktop * > { } , QVector < VirtualDesktop * > { } } )
[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-11-16 07:23:47 +00:00
}
2016-11-10 13:02:14 +00:00
VirtualDesktopGrid : : ~ VirtualDesktopGrid ( ) = default ;
2012-11-16 07:23:47 +00:00
2016-11-10 13:02:14 +00:00
void VirtualDesktopGrid : : update ( const QSize & size , Qt : : Orientation orientation , const QVector < VirtualDesktop * > & desktops )
2012-11-16 07:23:47 +00:00
{
// Set private variables
m_size = size ;
const uint width = size . width ( ) ;
const uint height = size . height ( ) ;
2016-11-10 13:02:14 +00:00
m_grid . clear ( ) ;
auto it = desktops . begin ( ) ;
auto end = desktops . end ( ) ;
2012-11-16 07:23:47 +00:00
if ( orientation = = Qt : : Horizontal ) {
for ( uint y = 0 ; y < height ; + + y ) {
2016-11-10 13:02:14 +00:00
QVector < VirtualDesktop * > row ;
for ( uint x = 0 ; x < width & & it ! = end ; + + x ) {
row < < * it ;
it + + ;
2012-11-16 07:23:47 +00:00
}
2016-11-10 13:02:14 +00:00
m_grid < < row ;
2012-11-16 07:23:47 +00:00
}
} else {
2016-11-10 13:02:14 +00:00
for ( uint y = 0 ; y < height ; + + y ) {
m_grid < < QVector < VirtualDesktop * > ( ) ;
}
2012-11-16 07:23:47 +00:00
for ( uint x = 0 ; x < width ; + + x ) {
2016-11-10 13:02:14 +00:00
for ( uint y = 0 ; y < height & & it ! = end ; + + y ) {
auto & row = m_grid [ y ] ;
row < < * it ;
it + + ;
2012-11-16 07:23:47 +00:00
}
}
}
}
QPoint VirtualDesktopGrid : : gridCoords ( uint id ) const
{
2016-11-10 13:02:14 +00:00
return gridCoords ( VirtualDesktopManager : : self ( ) - > desktopForX11Id ( id ) ) ;
}
QPoint VirtualDesktopGrid : : gridCoords ( VirtualDesktop * vd ) const
{
for ( int y = 0 ; y < m_grid . count ( ) ; + + y ) {
const auto & row = m_grid . at ( y ) ;
for ( int x = 0 ; x < row . count ( ) ; + + x ) {
if ( row . at ( x ) = = vd ) {
2012-11-16 07:23:47 +00:00
return QPoint ( x , y ) ;
}
}
}
return QPoint ( - 1 , - 1 ) ;
}
2016-11-10 13:02:14 +00:00
VirtualDesktop * VirtualDesktopGrid : : at ( const QPoint & coords ) const
{
if ( coords . y ( ) > = m_grid . count ( ) ) {
return nullptr ;
}
const auto & row = m_grid . at ( coords . y ( ) ) ;
if ( coords . x ( ) > = row . count ( ) ) {
return nullptr ;
}
return row . at ( coords . x ( ) ) ;
}
2013-04-05 07:41:25 +00:00
KWIN_SINGLETON_FACTORY_VARIABLE ( VirtualDesktopManager , s_manager )
2012-11-16 07:23:47 +00:00
VirtualDesktopManager : : VirtualDesktopManager ( QObject * parent )
: QObject ( parent )
, m_navigationWrapsAround ( false )
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
, m_rootInfo ( nullptr )
2012-11-16 07:23:47 +00:00
{
}
VirtualDesktopManager : : ~ VirtualDesktopManager ( )
{
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
s_manager = nullptr ;
2012-11-16 07:23:47 +00:00
}
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
void VirtualDesktopManager : : setRootInfo ( NETRootInfo * info )
{
m_rootInfo = info ;
// Nothing will be connected to rootInfo
if ( m_rootInfo ) {
for ( auto * vd : m_desktops ) {
m_rootInfo - > setDesktopName ( vd - > x11DesktopNumber ( ) , vd - > name ( ) . toUtf8 ( ) . data ( ) ) ;
}
}
}
2012-11-16 07:23:47 +00:00
QString VirtualDesktopManager : : name ( uint desktop ) const
{
2019-08-31 21:42:59 +00:00
if ( uint ( m_desktops . length ( ) ) > desktop - 1 ) {
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
return m_desktops [ desktop - 1 ] - > name ( ) ;
}
2012-11-16 07:23:47 +00:00
if ( ! m_rootInfo ) {
return defaultName ( desktop ) ;
}
return QString : : fromUtf8 ( m_rootInfo - > desktopName ( desktop ) ) ;
}
uint VirtualDesktopManager : : above ( uint id , bool wrap ) const
{
2016-11-10 13:02:14 +00:00
auto vd = above ( desktopForX11Id ( id ) , wrap ) ;
return vd ? vd - > x11DesktopNumber ( ) : 0 ;
}
VirtualDesktop * VirtualDesktopManager : : above ( VirtualDesktop * desktop , bool wrap ) const
{
Q_ASSERT ( m_current ) ;
if ( ! desktop ) {
desktop = m_current ;
2012-11-16 07:23:47 +00:00
}
2016-11-10 13:02:14 +00:00
QPoint coords = m_grid . gridCoords ( desktop ) ;
2012-11-16 07:23:47 +00:00
Q_ASSERT ( coords . x ( ) > = 0 ) ;
while ( true ) {
coords . ry ( ) - - ;
if ( coords . y ( ) < 0 ) {
if ( wrap ) {
coords . setY ( m_grid . height ( ) - 1 ) ;
} else {
2016-11-10 13:02:14 +00:00
return desktop ; // Already at the top-most desktop
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
if ( VirtualDesktop * vd = m_grid . at ( coords ) ) {
return vd ;
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
return nullptr ;
2012-11-16 07:23:47 +00:00
}
uint VirtualDesktopManager : : toRight ( uint id , bool wrap ) const
{
2016-11-10 13:02:14 +00:00
auto vd = toRight ( desktopForX11Id ( id ) , wrap ) ;
return vd ? vd - > x11DesktopNumber ( ) : 0 ;
}
VirtualDesktop * VirtualDesktopManager : : toRight ( VirtualDesktop * desktop , bool wrap ) const
{
Q_ASSERT ( m_current ) ;
if ( ! desktop ) {
desktop = m_current ;
2012-11-16 07:23:47 +00:00
}
2016-11-10 13:02:14 +00:00
QPoint coords = m_grid . gridCoords ( desktop ) ;
2012-11-16 07:23:47 +00:00
Q_ASSERT ( coords . x ( ) > = 0 ) ;
while ( true ) {
coords . rx ( ) + + ;
if ( coords . x ( ) > = m_grid . width ( ) ) {
if ( wrap ) {
coords . setX ( 0 ) ;
} else {
2016-11-10 13:02:14 +00:00
return desktop ; // Already at the right-most desktop
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
if ( VirtualDesktop * vd = m_grid . at ( coords ) ) {
return vd ;
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
return nullptr ;
2012-11-16 07:23:47 +00:00
}
uint VirtualDesktopManager : : below ( uint id , bool wrap ) const
{
2016-11-10 13:02:14 +00:00
auto vd = below ( desktopForX11Id ( id ) , wrap ) ;
return vd ? vd - > x11DesktopNumber ( ) : 0 ;
}
VirtualDesktop * VirtualDesktopManager : : below ( VirtualDesktop * desktop , bool wrap ) const
{
Q_ASSERT ( m_current ) ;
if ( ! desktop ) {
desktop = m_current ;
2012-11-16 07:23:47 +00:00
}
2016-11-10 13:02:14 +00:00
QPoint coords = m_grid . gridCoords ( desktop ) ;
2012-11-16 07:23:47 +00:00
Q_ASSERT ( coords . x ( ) > = 0 ) ;
while ( true ) {
coords . ry ( ) + + ;
if ( coords . y ( ) > = m_grid . height ( ) ) {
if ( wrap ) {
coords . setY ( 0 ) ;
} else {
// Already at the bottom-most desktop
2016-11-10 13:02:14 +00:00
return desktop ;
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
if ( VirtualDesktop * vd = m_grid . at ( coords ) ) {
return vd ;
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
return nullptr ;
2012-11-16 07:23:47 +00:00
}
uint VirtualDesktopManager : : toLeft ( uint id , bool wrap ) const
{
2016-11-10 13:02:14 +00:00
auto vd = toLeft ( desktopForX11Id ( id ) , wrap ) ;
return vd ? vd - > x11DesktopNumber ( ) : 0 ;
}
VirtualDesktop * VirtualDesktopManager : : toLeft ( VirtualDesktop * desktop , bool wrap ) const
{
Q_ASSERT ( m_current ) ;
if ( ! desktop ) {
desktop = m_current ;
2012-11-16 07:23:47 +00:00
}
2016-11-10 13:02:14 +00:00
QPoint coords = m_grid . gridCoords ( desktop ) ;
2012-11-16 07:23:47 +00:00
Q_ASSERT ( coords . x ( ) > = 0 ) ;
while ( true ) {
coords . rx ( ) - - ;
if ( coords . x ( ) < 0 ) {
if ( wrap ) {
coords . setX ( m_grid . width ( ) - 1 ) ;
} else {
2016-11-10 13:02:14 +00:00
return desktop ; // Already at the left-most desktop
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
if ( VirtualDesktop * vd = m_grid . at ( coords ) ) {
return vd ;
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
return nullptr ;
2012-11-16 07:23:47 +00:00
}
2016-11-10 13:02:14 +00:00
VirtualDesktop * VirtualDesktopManager : : next ( VirtualDesktop * desktop , bool wrap ) const
2012-11-16 07:23:47 +00:00
{
2016-11-10 13:02:14 +00:00
Q_ASSERT ( m_current ) ;
if ( ! desktop ) {
desktop = m_current ;
}
auto it = std : : find ( m_desktops . begin ( ) , m_desktops . end ( ) , desktop ) ;
Q_ASSERT ( it ! = m_desktops . end ( ) ) ;
it + + ;
if ( it = = m_desktops . end ( ) ) {
2012-11-16 07:23:47 +00:00
if ( wrap ) {
2016-11-10 13:02:14 +00:00
return m_desktops . first ( ) ;
2012-11-16 07:23:47 +00:00
} else {
2016-11-10 13:02:14 +00:00
return desktop ;
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
return * it ;
2012-11-16 07:23:47 +00:00
}
2016-11-10 13:02:14 +00:00
VirtualDesktop * VirtualDesktopManager : : previous ( VirtualDesktop * desktop , bool wrap ) const
2012-11-16 07:23:47 +00:00
{
2016-11-10 13:02:14 +00:00
Q_ASSERT ( m_current ) ;
if ( ! desktop ) {
desktop = m_current ;
2012-11-16 07:23:47 +00:00
}
2016-11-10 13:02:14 +00:00
auto it = std : : find ( m_desktops . begin ( ) , m_desktops . end ( ) , desktop ) ;
Q_ASSERT ( it ! = m_desktops . end ( ) ) ;
if ( it = = m_desktops . begin ( ) ) {
2012-11-16 07:23:47 +00:00
if ( wrap ) {
2016-11-10 13:02:14 +00:00
return m_desktops . last ( ) ;
2012-11-16 07:23:47 +00:00
} else {
2016-11-10 13:02:14 +00:00
return desktop ;
2012-11-16 07:23:47 +00:00
}
}
2016-11-10 13:02:14 +00:00
it - - ;
return * it ;
}
VirtualDesktop * VirtualDesktopManager : : desktopForX11Id ( uint id ) const
{
if ( id = = 0 | | id > count ( ) ) {
return nullptr ;
}
return m_desktops . at ( id - 1 ) ;
2012-11-16 07:23:47 +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
VirtualDesktop * VirtualDesktopManager : : desktopForId ( const QByteArray & id ) const
{
auto desk = std : : find_if (
m_desktops . constBegin ( ) ,
m_desktops . constEnd ( ) ,
[ id ] ( const VirtualDesktop * desk ) {
return desk - > id ( ) = = id ;
}
) ;
if ( desk ! = m_desktops . constEnd ( ) ) {
return * desk ;
}
return nullptr ;
}
2019-01-17 21:12:11 +00:00
VirtualDesktop * VirtualDesktopManager : : createVirtualDesktop ( uint position , const QString & name )
[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
{
//too many, can't insert new ones
if ( ( uint ) m_desktops . count ( ) = = VirtualDesktopManager : : maximum ( ) ) {
return nullptr ;
}
2019-01-17 21:12:11 +00:00
position = qBound ( 0u , position , static_cast < uint > ( m_desktops . count ( ) ) ) ;
[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
auto * vd = new VirtualDesktop ( this ) ;
2019-01-17 21:12:11 +00:00
vd - > setX11DesktopNumber ( position + 1 ) ;
2019-01-18 10:19:50 +00:00
vd - > setId ( generateDesktopId ( ) ) ;
[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
vd - > setName ( name ) ;
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
connect ( vd , & VirtualDesktop : : nameChanged , this ,
[ this , vd ] ( ) {
if ( m_rootInfo ) {
m_rootInfo - > setDesktopName ( vd - > x11DesktopNumber ( ) , vd - > name ( ) . toUtf8 ( ) . data ( ) ) ;
[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
}
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
}
) ;
if ( m_rootInfo ) {
[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_rootInfo - > setDesktopName ( vd - > x11DesktopNumber ( ) , vd - > name ( ) . toUtf8 ( ) . data ( ) ) ;
}
2019-01-17 21:12:11 +00:00
m_desktops . insert ( position , vd ) ;
[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
//update the id of displaced desktops
2019-01-17 21:12:11 +00:00
for ( uint i = position + 1 ; i < ( uint ) m_desktops . count ( ) ; + + i ) {
[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_desktops [ i ] - > setX11DesktopNumber ( i + 1 ) ;
if ( m_rootInfo ) {
m_rootInfo - > setDesktopName ( i + 1 , m_desktops [ i ] - > name ( ) . toUtf8 ( ) . data ( ) ) ;
}
}
save ( ) ;
updateRootInfo ( ) ;
emit desktopCreated ( vd ) ;
emit countChanged ( m_desktops . count ( ) - 1 , m_desktops . count ( ) ) ;
return vd ;
}
void VirtualDesktopManager : : removeVirtualDesktop ( const QByteArray & id )
{
//don't end up without any desktop
if ( m_desktops . count ( ) = = 1 ) {
return ;
}
auto desktop = desktopForId ( id ) ;
if ( ! desktop ) {
return ;
}
const uint oldCurrent = m_current - > x11DesktopNumber ( ) ;
const uint i = desktop - > x11DesktopNumber ( ) - 1 ;
m_desktops . remove ( i ) ;
for ( uint j = i ; j < ( uint ) m_desktops . count ( ) ; + + j ) {
m_desktops [ j ] - > setX11DesktopNumber ( j + 1 ) ;
if ( m_rootInfo ) {
m_rootInfo - > setDesktopName ( j + 1 , m_desktops [ j ] - > name ( ) . toUtf8 ( ) . data ( ) ) ;
}
}
const uint newCurrent = qMin ( oldCurrent , ( uint ) m_desktops . count ( ) ) ;
m_current = m_desktops . at ( newCurrent - 1 ) ;
if ( oldCurrent ! = newCurrent ) {
emit currentChanged ( oldCurrent , newCurrent ) ;
}
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
save ( ) ;
[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
updateRootInfo ( ) ;
emit desktopRemoved ( desktop ) ;
emit countChanged ( m_desktops . count ( ) + 1 , m_desktops . count ( ) ) ;
desktop - > deleteLater ( ) ;
}
2016-11-07 09:55:18 +00:00
uint VirtualDesktopManager : : current ( ) const
{
return m_current ? m_current - > x11DesktopNumber ( ) : 0 ;
}
2017-04-04 16:56:10 +00:00
VirtualDesktop * VirtualDesktopManager : : currentDesktop ( ) const
{
return m_current ;
}
2012-11-16 07:23:47 +00:00
bool VirtualDesktopManager : : setCurrent ( uint newDesktop )
{
2016-11-07 09:55:18 +00:00
if ( newDesktop < 1 | | newDesktop > count ( ) | | newDesktop = = current ( ) ) {
2012-11-16 07:23:47 +00:00
return false ;
}
2016-11-10 13:02:14 +00:00
auto d = desktopForX11Id ( newDesktop ) ;
Q_ASSERT ( d ) ;
return setCurrent ( d ) ;
}
2016-11-07 09:55:18 +00:00
2016-11-10 13:02:14 +00:00
bool VirtualDesktopManager : : setCurrent ( VirtualDesktop * newDesktop )
{
Q_ASSERT ( newDesktop ) ;
if ( m_current = = newDesktop ) {
return false ;
}
const uint oldDesktop = current ( ) ;
m_current = newDesktop ;
emit currentChanged ( oldDesktop , newDesktop - > x11DesktopNumber ( ) ) ;
2012-11-16 07:23:47 +00:00
return true ;
}
void VirtualDesktopManager : : setCount ( uint count )
{
count = qBound < uint > ( 1 , count , VirtualDesktopManager : : maximum ( ) ) ;
2016-11-07 09:55:18 +00:00
if ( count = = uint ( m_desktops . count ( ) ) ) {
2012-11-16 07:23:47 +00:00
// nothing to change
return ;
}
[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
QList < VirtualDesktop * > newDesktops ;
2016-11-07 09:55:18 +00:00
const uint oldCount = m_desktops . count ( ) ;
[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
//this explicit check makes it more readable
if ( ( uint ) m_desktops . count ( ) > count ) {
const auto desktopsToRemove = m_desktops . mid ( count ) ;
m_desktops . resize ( count ) ;
if ( m_current ) {
uint oldCurrent = current ( ) ;
uint newCurrent = qMin ( oldCurrent , count ) ;
m_current = m_desktops . at ( newCurrent - 1 ) ;
if ( oldCurrent ! = newCurrent ) {
emit currentChanged ( oldCurrent , newCurrent ) ;
}
}
for ( auto desktop : desktopsToRemove ) {
emit desktopRemoved ( desktop ) ;
desktop - > deleteLater ( ) ;
}
} else {
while ( uint ( m_desktops . count ( ) ) < count ) {
auto vd = new VirtualDesktop ( this ) ;
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
const int x11Number = m_desktops . count ( ) + 1 ;
vd - > setX11DesktopNumber ( x11Number ) ;
vd - > setName ( defaultName ( x11Number ) ) ;
2018-12-21 17:24:11 +00:00
if ( ! s_loadingDesktopSettings ) {
2019-01-18 10:19:50 +00:00
vd - > setId ( generateDesktopId ( ) ) ;
[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_desktops < < vd ;
newDesktops < < vd ;
2019-01-24 16:18:49 +00:00
connect ( vd , & VirtualDesktop : : nameChanged , this ,
[ this , vd ] {
if ( m_rootInfo ) {
m_rootInfo - > setDesktopName ( vd - > x11DesktopNumber ( ) , vd - > name ( ) . toUtf8 ( ) . data ( ) ) ;
[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
}
2019-01-24 16:18:49 +00:00
}
) ;
if ( m_rootInfo ) {
[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_rootInfo - > setDesktopName ( vd - > x11DesktopNumber ( ) , vd - > name ( ) . toUtf8 ( ) . data ( ) ) ;
}
}
2016-11-07 09:55:18 +00:00
}
2012-11-16 07:23:47 +00:00
updateRootInfo ( ) ;
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
if ( ! s_loadingDesktopSettings ) {
save ( ) ;
}
[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
for ( auto vd : newDesktops ) {
emit desktopCreated ( vd ) ;
}
2016-11-07 09:55:18 +00:00
emit countChanged ( oldCount , m_desktops . count ( ) ) ;
2012-11-16 07:23:47 +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
uint VirtualDesktopManager : : rows ( ) const
2012-11-16 07:23:47 +00:00
{
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
return m_rows ;
[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 VirtualDesktopManager : : setRows ( uint rows )
{
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
if ( rows = = 0 | | rows > count ( ) | | rows = = m_rows ) {
[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
return ;
}
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
m_rows = rows ;
int columns = count ( ) / m_rows ;
if ( count ( ) % m_rows > 0 ) {
[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
columns + + ;
2012-11-16 07:23:47 +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 ( m_rootInfo ) {
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
m_rootInfo - > setDesktopLayout ( NET : : OrientationHorizontal , columns , m_rows , NET : : DesktopLayoutCornerTopLeft ) ;
[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_rootInfo - > activate ( ) ;
}
updateLayout ( ) ;
//rowsChanged will be emitted by setNETDesktopLayout called by updateLayout
2012-11-16 07:23:47 +00:00
}
void VirtualDesktopManager : : updateRootInfo ( )
{
if ( ! m_rootInfo ) {
// Make sure the layout is still valid
updateLayout ( ) ;
return ;
}
const int n = count ( ) ;
m_rootInfo - > setNumberOfDesktops ( n ) ;
NETPoint * viewports = new NETPoint [ n ] ;
m_rootInfo - > setDesktopViewport ( n , * viewports ) ;
delete [ ] viewports ;
// Make sure the layout is still valid
updateLayout ( ) ;
}
void VirtualDesktopManager : : updateLayout ( )
{
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
m_rows = qMin ( m_rows , count ( ) ) ;
int columns = count ( ) / m_rows ;
2012-11-16 07:23:47 +00:00
Qt : : Orientation orientation = Qt : : Horizontal ;
if ( m_rootInfo ) {
// TODO: Is there a sane way to avoid overriding the existing grid?
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
columns = m_rootInfo - > desktopLayoutColumnsRows ( ) . width ( ) ;
m_rows = qMax ( 1 , m_rootInfo - > desktopLayoutColumnsRows ( ) . height ( ) ) ;
2012-11-16 07:23:47 +00:00
orientation = m_rootInfo - > desktopLayoutOrientation ( ) = = NET : : OrientationHorizontal ? Qt : : Horizontal : Qt : : Vertical ;
}
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
if ( columns = = 0 ) {
2012-11-16 07:23:47 +00:00
// Not given, set default layout
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
m_rows = count ( ) = = 1u ? 1 : 2 ;
columns = count ( ) / m_rows ;
2012-11-16 07:23:47 +00:00
}
setNETDesktopLayout ( orientation ,
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
columns , m_rows , 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now.
2012-11-16 07:23:47 +00:00
) ;
}
void VirtualDesktopManager : : load ( )
{
s_loadingDesktopSettings = true ;
2013-08-26 09:26:12 +00:00
if ( ! m_config ) {
2012-11-16 07:23:47 +00:00
return ;
}
QString groupname ;
if ( screen_number = = 0 ) {
2013-07-23 05:02:52 +00:00
groupname = QStringLiteral ( " Desktops " ) ;
2012-11-16 07:23:47 +00:00
} else {
2019-09-18 08:33:18 +00:00
groupname = QStringLiteral ( " Desktops-screen-%1 " ) . arg ( screen_number ) ;
2012-11-16 07:23:47 +00:00
}
KConfigGroup group ( m_config , groupname ) ;
const int n = group . readEntry ( " Number " , 1 ) ;
setCount ( n ) ;
[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
for ( int i = 1 ; i < = n ; i + + ) {
QString s = group . readEntry ( QStringLiteral ( " Name_%1 " ) . arg ( i ) , i18n ( " Desktop %1 " , i ) ) ;
if ( m_rootInfo ) {
2012-11-16 07:23:47 +00:00
m_rootInfo - > setDesktopName ( i , s . toUtf8 ( ) . data ( ) ) ;
[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_desktops [ i - 1 ] - > setName ( s . toUtf8 ( ) . data ( ) ) ;
2019-01-18 10:19:50 +00:00
const QString sId = group . readEntry ( QStringLiteral ( " Id_%1 " ) . arg ( i ) , QString ( ) ) ;
[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
//load gets called 2 times, see workspace.cpp line 416 and BUG 385260
if ( m_desktops [ i - 1 ] - > id ( ) . isEmpty ( ) ) {
2019-01-18 10:19:50 +00:00
m_desktops [ i - 1 ] - > setId ( sId . isEmpty ( ) ? generateDesktopId ( ) : sId . toUtf8 ( ) ) ;
[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 {
Q_ASSERT ( sId . isEmpty ( ) | | m_desktops [ i - 1 ] - > id ( ) = = sId . toUtf8 ( ) . data ( ) ) ;
2012-11-16 07:23:47 +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
// TODO: update desktop focus chain, why?
// m_desktopFocusChain.value()[i-1] = i;
}
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
int rows = group . readEntry < int > ( " Rows " , 2 ) ;
m_rows = qBound ( 1 , rows , n ) ;
[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_rootInfo ) {
2012-11-16 07:23:47 +00:00
// avoid weird cases like having 3 rows for 4 desktops, where the last row is unused
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
int columns = n / m_rows ;
if ( n % m_rows > 0 ) {
2012-11-16 07:23:47 +00:00
columns + + ;
}
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
m_rootInfo - > setDesktopLayout ( NET : : OrientationHorizontal , columns , m_rows , NET : : DesktopLayoutCornerTopLeft ) ;
2012-11-16 07:23:47 +00:00
m_rootInfo - > activate ( ) ;
}
[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-11-16 07:23:47 +00:00
s_loadingDesktopSettings = false ;
}
void VirtualDesktopManager : : save ( )
{
if ( s_loadingDesktopSettings ) {
return ;
}
2013-08-26 09:26:12 +00:00
if ( ! m_config ) {
2012-11-16 07:23:47 +00:00
return ;
}
QString groupname ;
if ( screen_number = = 0 ) {
2013-07-23 05:02:52 +00:00
groupname = QStringLiteral ( " Desktops " ) ;
2012-11-16 07:23:47 +00:00
} else {
2019-09-18 08:33:18 +00:00
groupname = QStringLiteral ( " Desktops-screen-%1 " ) . arg ( screen_number ) ;
2012-11-16 07:23:47 +00:00
}
KConfigGroup group ( m_config , groupname ) ;
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
for ( int i = count ( ) + 1 ; group . hasKey ( QStringLiteral ( " Id_%1 " ) . arg ( i ) ) ; i + + ) {
group . deleteEntry ( QStringLiteral ( " Id_%1 " ) . arg ( i ) ) ;
2019-01-18 21:42:02 +00:00
group . deleteEntry ( QStringLiteral ( " Name_%1 " ) . arg ( i ) ) ;
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
}
2012-11-16 07:23:47 +00:00
group . writeEntry ( " Number " , count ( ) ) ;
for ( uint i = 1 ; i < = count ( ) ; + + i ) {
QString s = name ( i ) ;
const QString defaultvalue = defaultName ( i ) ;
if ( s . isEmpty ( ) ) {
s = defaultvalue ;
if ( m_rootInfo ) {
m_rootInfo - > setDesktopName ( i , s . toUtf8 ( ) . data ( ) ) ;
}
}
if ( s ! = defaultvalue ) {
2013-07-23 05:02:52 +00:00
group . writeEntry ( QStringLiteral ( " Name_%1 " ) . arg ( i ) , s ) ;
2012-11-16 07:23:47 +00:00
} else {
2013-07-23 05:02:52 +00:00
QString currentvalue = group . readEntry ( QStringLiteral ( " Name_%1 " ) . arg ( i ) , QString ( ) ) ;
2012-11-16 07:23:47 +00:00
if ( currentvalue ! = defaultvalue ) {
2013-07-23 05:02:52 +00:00
group . deleteEntry ( QStringLiteral ( " Name_%1 " ) . arg ( i ) ) ;
2012-11-16 07:23:47 +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
group . writeEntry ( QStringLiteral ( " Id_%1 " ) . arg ( i ) , m_desktops [ i - 1 ] - > id ( ) ) ;
2012-11-16 07:23:47 +00:00
}
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
group . writeEntry ( " Rows " , m_rows ) ;
2012-11-16 07:23:47 +00:00
// Save to disk
group . sync ( ) ;
}
QString VirtualDesktopManager : : defaultName ( int desktop ) const
{
return i18n ( " Desktop %1 " , desktop ) ;
}
void VirtualDesktopManager : : setNETDesktopLayout ( Qt : : Orientation orientation , uint width , uint height , int startingCorner )
{
Q_UNUSED ( startingCorner ) ; // Not really worth implementing right now.
2016-11-07 09:55:18 +00:00
const uint count = m_desktops . count ( ) ;
2012-11-16 07:23:47 +00:00
// Calculate valid grid size
Q_ASSERT ( width > 0 | | height > 0 ) ;
if ( ( width < = 0 ) & & ( height > 0 ) ) {
2016-11-07 09:55:18 +00:00
width = ( count + height - 1 ) / height ;
2012-11-16 07:23:47 +00:00
} else if ( ( height < = 0 ) & & ( width > 0 ) ) {
2016-11-07 09:55:18 +00:00
height = ( count + width - 1 ) / width ;
2012-11-16 07:23:47 +00:00
}
2016-11-07 09:55:18 +00:00
while ( width * height < count ) {
2012-11-16 07:23:47 +00:00
if ( orientation = = Qt : : Horizontal ) {
+ + width ;
} else {
+ + height ;
}
}
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
m_rows = qMax ( 1u , height ) ;
2016-11-10 13:02:14 +00:00
m_grid . update ( QSize ( width , height ) , orientation , m_desktops ) ;
2012-11-16 07:23:47 +00:00
// TODO: why is there no call to m_rootInfo->setDesktopLayout?
emit layoutChanged ( width , height ) ;
[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
emit rowsChanged ( height ) ;
2012-11-16 07:23:47 +00:00
}
2013-12-10 08:11:16 +00:00
void VirtualDesktopManager : : initShortcuts ( )
2012-11-16 07:23:47 +00:00
{
2013-12-10 08:11:16 +00:00
initSwitchToShortcuts ( ) ;
2017-03-18 10:00:30 +00:00
QAction * nextAction = addAction ( QStringLiteral ( " Switch to Next Desktop " ) , i18n ( " Switch to Next Desktop " ) , & VirtualDesktopManager : : slotNext ) ;
input ( ) - > registerTouchpadSwipeShortcut ( SwipeDirection : : Right , nextAction ) ;
QAction * previousAction = addAction ( QStringLiteral ( " Switch to Previous Desktop " ) , i18n ( " Switch to Previous Desktop " ) , & VirtualDesktopManager : : slotPrevious ) ;
input ( ) - > registerTouchpadSwipeShortcut ( SwipeDirection : : Left , previousAction ) ;
Add default shortcut to switch to the desktop to the left/right/top/bottom
Summary:
Very useful when you use virtual desktops. See T11520 for more information.
This reverts commit d72e96802b3c48ce69d8072cf30038d6ad552d0c.
Test Plan: Have 2 or more virtual desktops and use the new shortcut.
Reviewers: #kwin, #plasma, #vdg, romangg, ngraham, davidedmundson
Reviewed By: #vdg, ngraham, davidedmundson
Subscribers: alexisd, alexde, ognarb, hpereiradacosta, broulik, davidedmundson, thiagosueto, ngraham, romangg, zzag, #vdg, #plasma, kwin, #kwin
Tags: #kwin
Maniphest Tasks: T11520
Differential Revision: https://phabricator.kde.org/D24281
2020-01-13 14:56:32 +00:00
QAction * slotRightAction = addAction ( QStringLiteral ( " Switch One Desktop to the Right " ) , i18n ( " Switch One Desktop to the Right " ) , & VirtualDesktopManager : : slotRight ) ;
KGlobalAccel : : setGlobalShortcut ( slotRightAction , QKeySequence ( Qt : : CTRL + Qt : : META + Qt : : Key_Right ) ) ;
QAction * slotLeftAction = addAction ( QStringLiteral ( " Switch One Desktop to the Left " ) , i18n ( " Switch One Desktop to the Left " ) , & VirtualDesktopManager : : slotLeft ) ;
KGlobalAccel : : setGlobalShortcut ( slotLeftAction , QKeySequence ( Qt : : CTRL + Qt : : META + Qt : : Key_Left ) ) ;
QAction * slotUpAction = addAction ( QStringLiteral ( " Switch One Desktop Up " ) , i18n ( " Switch One Desktop Up " ) , & VirtualDesktopManager : : slotUp ) ;
KGlobalAccel : : setGlobalShortcut ( slotUpAction , QKeySequence ( Qt : : CTRL + Qt : : META + Qt : : Key_Up ) ) ;
QAction * slotDownAction = addAction ( QStringLiteral ( " Switch One Desktop Down " ) , i18n ( " Switch One Desktop Down " ) , & VirtualDesktopManager : : slotDown ) ;
KGlobalAccel : : setGlobalShortcut ( slotDownAction , QKeySequence ( Qt : : CTRL + Qt : : META + Qt : : Key_Down ) ) ;
2013-07-15 09:34:36 +00:00
// axis events
input ( ) - > registerAxisShortcut ( Qt : : ControlModifier | Qt : : AltModifier , PointerAxisDown ,
findChild < QAction * > ( QStringLiteral ( " Switch to Next Desktop " ) ) ) ;
input ( ) - > registerAxisShortcut ( Qt : : ControlModifier | Qt : : AltModifier , PointerAxisUp ,
findChild < QAction * > ( QStringLiteral ( " Switch to Previous Desktop " ) ) ) ;
2012-11-16 07:23:47 +00:00
}
2013-12-10 08:11:16 +00:00
void VirtualDesktopManager : : initSwitchToShortcuts ( )
2012-11-16 07:23:47 +00:00
{
2013-07-23 05:02:52 +00:00
const QString toDesktop = QStringLiteral ( " Switch to Desktop %1 " ) ;
2012-11-16 07:23:47 +00:00
const KLocalizedString toDesktopLabel = ki18n ( " Switch to Desktop %1 " ) ;
2013-12-10 08:11:16 +00:00
addAction ( toDesktop , toDesktopLabel , 1 , QKeySequence ( Qt : : CTRL + Qt : : Key_F1 ) , & VirtualDesktopManager : : slotSwitchTo ) ;
addAction ( toDesktop , toDesktopLabel , 2 , QKeySequence ( Qt : : CTRL + Qt : : Key_F2 ) , & VirtualDesktopManager : : slotSwitchTo ) ;
addAction ( toDesktop , toDesktopLabel , 3 , QKeySequence ( Qt : : CTRL + Qt : : Key_F3 ) , & VirtualDesktopManager : : slotSwitchTo ) ;
addAction ( toDesktop , toDesktopLabel , 4 , QKeySequence ( Qt : : CTRL + Qt : : Key_F4 ) , & VirtualDesktopManager : : slotSwitchTo ) ;
2012-11-16 07:23:47 +00:00
for ( uint i = 5 ; i < = maximum ( ) ; + + i ) {
2013-12-10 08:11:16 +00:00
addAction ( toDesktop , toDesktopLabel , i , QKeySequence ( ) , & VirtualDesktopManager : : slotSwitchTo ) ;
2012-11-16 07:23:47 +00:00
}
}
2017-03-18 10:00:30 +00:00
QAction * VirtualDesktopManager : : addAction ( const QString & name , const KLocalizedString & label , uint value , const QKeySequence & key , void ( VirtualDesktopManager : : * slot ) ( ) )
2012-11-16 07:23:47 +00:00
{
2013-12-10 08:11:16 +00:00
QAction * a = new QAction ( this ) ;
2016-09-13 11:02:20 +00:00
a - > setProperty ( " componentName " , QStringLiteral ( KWIN_NAME ) ) ;
2013-12-10 08:11:16 +00:00
a - > setObjectName ( name . arg ( value ) ) ;
2012-11-16 07:23:47 +00:00
a - > setText ( label . subs ( value ) . toString ( ) ) ;
a - > setData ( value ) ;
2014-07-01 06:09:27 +00:00
KGlobalAccel : : setGlobalShortcut ( a , key ) ;
2015-02-19 09:38:49 +00:00
input ( ) - > registerShortcut ( key , a , this , slot ) ;
2017-03-18 10:00:30 +00:00
return a ;
2012-11-16 07:23:47 +00:00
}
2017-03-18 10:00:30 +00:00
QAction * VirtualDesktopManager : : addAction ( const QString & name , const QString & label , void ( VirtualDesktopManager : : * slot ) ( ) )
2012-11-16 07:23:47 +00:00
{
2013-12-10 08:11:16 +00:00
QAction * a = new QAction ( this ) ;
2016-09-13 11:02:20 +00:00
a - > setProperty ( " componentName " , QStringLiteral ( KWIN_NAME ) ) ;
2013-12-10 08:11:16 +00:00
a - > setObjectName ( name ) ;
2012-11-16 07:23:47 +00:00
a - > setText ( label ) ;
2014-07-01 06:09:27 +00:00
KGlobalAccel : : setGlobalShortcut ( a , QKeySequence ( ) ) ;
2015-02-19 09:38:49 +00:00
input ( ) - > registerShortcut ( QKeySequence ( ) , a , this , slot ) ;
2017-03-18 10:00:30 +00:00
return a ;
2012-11-16 07:23:47 +00:00
}
void VirtualDesktopManager : : slotSwitchTo ( )
{
QAction * act = qobject_cast < QAction * > ( sender ( ) ) ;
if ( ! act ) {
return ;
}
bool ok = false ;
const uint i = act - > data ( ) . toUInt ( & ok ) ;
if ( ! ok ) {
return ;
}
setCurrent ( i ) ;
}
void VirtualDesktopManager : : setNavigationWrappingAround ( bool enabled )
{
if ( enabled = = m_navigationWrapsAround ) {
return ;
}
m_navigationWrapsAround = enabled ;
emit navigationWrappingAroundChanged ( ) ;
}
void VirtualDesktopManager : : slotDown ( )
{
moveTo < DesktopBelow > ( isNavigationWrappingAround ( ) ) ;
}
void VirtualDesktopManager : : slotLeft ( )
{
moveTo < DesktopLeft > ( isNavigationWrappingAround ( ) ) ;
}
void VirtualDesktopManager : : slotPrevious ( )
{
moveTo < DesktopPrevious > ( isNavigationWrappingAround ( ) ) ;
}
void VirtualDesktopManager : : slotNext ( )
{
moveTo < DesktopNext > ( isNavigationWrappingAround ( ) ) ;
}
void VirtualDesktopManager : : slotRight ( )
{
moveTo < DesktopRight > ( isNavigationWrappingAround ( ) ) ;
}
void VirtualDesktopManager : : slotUp ( )
{
moveTo < DesktopAbove > ( isNavigationWrappingAround ( ) ) ;
}
} // KWin