Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Workspace
Commits
7df9ad19
Commit
7df9ad19
authored
May 26, 2022
by
Fushan Wen
Committed by
Nate Graham
May 30, 2022
Browse files
shell/panelview: restore old window focus when panel loses focus
CCBUG: 453166
CCBUG: 352476
(cherry picked from commit
53fdac77
)
parent
74f54bce
Pipeline
#183006
passed with stage
in 12 minutes and 15 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
shell/panelview.cpp
View file @
7df9ad19
...
...
@@ -30,6 +30,7 @@
#include
<Plasma/Package>
#include
<KWayland/Client/plasmashell.h>
#include
<KWayland/Client/plasmawindowmanagement.h>
#include
<KWayland/Client/surface.h>
#if HAVE_X11
...
...
@@ -1400,11 +1401,31 @@ void PanelView::refreshStatus(Plasma::Types::ItemStatus status)
}
}
else
if
(
status
==
Plasma
::
Types
::
AcceptingInputStatus
)
{
setFlags
(
flags
()
&
~
Qt
::
WindowDoesNotAcceptFocus
);
#ifdef HAVE_X11
if
(
KWindowSystem
::
isPlatformX11
())
{
m_previousWId
=
KWindowSystem
::
activeWindow
();
}
KWindowSystem
::
forceActiveWindow
(
winId
());
#endif
if
(
m_shellSurface
)
{
m_previousPlasmaWindow
=
m_corona
->
waylandPlasmaWindowManagementInterface
()
->
activeWindow
();
m_shellSurface
->
setPanelTakesFocus
(
true
);
}
}
else
{
if
(
status
==
Plasma
::
Types
::
PassiveStatus
)
{
// Restores the previous focus
#ifdef HAVE_X11
if
(
KWindowSystem
::
isPlatformX11
()
&&
m_previousWId
)
{
KWindowSystem
::
forceActiveWindow
(
m_previousWId
);
m_previousWId
=
0
;
}
#endif
if
(
m_previousPlasmaWindow
)
{
m_previousPlasmaWindow
->
requestActivate
();
m_previousPlasmaWindow
=
nullptr
;
}
}
restoreAutoHide
();
setFlags
(
flags
()
|
Qt
::
WindowDoesNotAcceptFocus
);
if
(
m_shellSurface
)
{
...
...
shell/panelview.h
View file @
7df9ad19
...
...
@@ -9,6 +9,9 @@
#include
<Plasma/Theme>
#include
<QPointer>
#include
<QTimer>
#ifdef HAVE_X11
#include
<QWindow>
// For WId
#endif
#include
<PlasmaQuick/ConfigView>
#include
<PlasmaQuick/ContainmentView>
...
...
@@ -20,6 +23,7 @@ namespace KWayland
namespace
Client
{
class
PlasmaShellSurface
;
class
PlasmaWindow
;
}
}
...
...
@@ -279,5 +283,11 @@ private:
QPointer
<
QScreen
>
m_screenToFollow
;
QMetaObject
::
Connection
m_transientWindowVisibleWatcher
;
// Used to restore the previous activated window after the panel loses focus
#ifdef HAVE_X11
WId
m_previousWId
=
0
;
#endif
KWayland
::
Client
::
PlasmaWindow
*
m_previousPlasmaWindow
=
nullptr
;
static
const
int
STRUTSTIMERDELAY
=
200
;
};
shell/shellcorona.cpp
View file @
7df9ad19
...
...
@@ -46,6 +46,7 @@
#include
<KWayland/Client/connection_thread.h>
#include
<KWayland/Client/plasmashell.h>
#include
<KWayland/Client/plasmawindowmanagement.h>
#include
<KWayland/Client/registry.h>
#include
"config-ktexteditor.h"
// HAVE_KTEXTEDITOR
...
...
@@ -2181,6 +2182,9 @@ void ShellCorona::setupWaylandIntegration()
connect
(
registry
,
&
Registry
::
plasmaShellAnnounced
,
this
,
[
this
,
registry
](
quint32
name
,
quint32
version
)
{
m_waylandPlasmaShell
=
registry
->
createPlasmaShell
(
name
,
version
,
this
);
});
connect
(
registry
,
&
KWayland
::
Client
::
Registry
::
plasmaWindowManagementAnnounced
,
this
,
[
this
,
registry
](
quint32
name
,
quint32
version
)
{
m_waylandWindowManagement
=
registry
->
createPlasmaWindowManagement
(
name
,
version
,
this
);
});
registry
->
setup
();
connection
->
roundtrip
();
qApp
->
installEventFilter
(
new
DismissPopupEventFilter
(
this
));
...
...
@@ -2191,6 +2195,11 @@ KWayland::Client::PlasmaShell *ShellCorona::waylandPlasmaShellInterface() const
return
m_waylandPlasmaShell
;
}
KWayland
::
Client
::
PlasmaWindowManagement
*
ShellCorona
::
waylandPlasmaWindowManagementInterface
()
const
{
return
m_waylandWindowManagement
;
}
ScreenPool
*
ShellCorona
::
screenPool
()
const
{
return
m_screenPool
;
...
...
shell/shellcorona.h
View file @
7df9ad19
...
...
@@ -52,6 +52,7 @@ namespace KWayland
namespace
Client
{
class
PlasmaShell
;
class
PlasmaWindowManagement
;
}
}
...
...
@@ -100,6 +101,7 @@ public:
Plasma
::
Containment
*
createContainmentForActivity
(
const
QString
&
activity
,
int
screenNum
);
KWayland
::
Client
::
PlasmaShell
*
waylandPlasmaShellInterface
()
const
;
KWayland
::
Client
::
PlasmaWindowManagement
*
waylandPlasmaWindowManagementInterface
()
const
;
ScreenPool
*
screenPool
()
const
;
...
...
@@ -268,6 +270,8 @@ private:
QTimer
m_invariantsTimer
;
#endif
KWayland
::
Client
::
PlasmaShell
*
m_waylandPlasmaShell
;
// For getting the active window on Wayland
KWayland
::
Client
::
PlasmaWindowManagement
*
m_waylandWindowManagement
=
nullptr
;
bool
m_closingDown
:
1
;
QString
m_testModeLayout
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment