Bug 317930

Summary: Activate a client in KWin scripting
Product: [Plasma] kwin Reporter: Michail Vourlakos <mvourlakos>
Component: scriptingAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: normal CC: kde.org
Priority: NOR    
Version First Reported In: 4.10.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Michail Vourlakos 2013-04-06 14:31:26 UTC
I cannot activate a Client through KWin scripting...

according to documentation:
bool active: Whether this Client is active or not. Use Workspace::activateClient() to activate a Client

but activateClient() function is load available in KWin Scripting,
there is also a read-write property for Workspace:
 KWin::Client activeClient 
but this also didnt help by setting it directly...

Reproducible: Always
Comment 1 Thomas Lübking 2013-04-06 14:41:49 UTC
What kind of client under what circumstances?
(the workspace wrapper does not enforce focus acquirement)
Comment 2 Michail Vourlakos 2013-04-06 15:05:25 UTC
(In reply to comment #1)
> What kind of client under what circumstances?
just simple windows 

> (the workspace wrapper does not enforce focus acquirement)
Ohhh I see, so is there any way to force focus for a client through KWin Scripting?
Comment 3 Thomas Lübking 2013-04-06 15:11:02 UTC
there's usually no need since your not requesting - you're already past the "kwindowsystem::forceactivewindow" condition.
the force applies to docks etc.

so it will be about the circumstances, your implementation - or a bug.

you should be assigning the workspace member.
is yor grabbing popup up when trying this?
Comment 4 Martin Flöser 2013-04-06 15:12:58 UTC
Actually it should just be:

workspace.activeClient = client;
Comment 5 Michail Vourlakos 2013-04-06 16:29:02 UTC
Thomas---
> you should be assigning the workspace member.
> is yor grabbing popup up when trying this?
yes

Martin--- 
> workspace.activeClient = client;
this is exactly what I am using... For Present Windows 2 , Martin are you using this code and it works ok?

----
A small update: after playing the surgery for a few days... :) KWindowSystem is not used any more in any part for the KWin Script so all the functionality is directly from Workspace and Clients. No qml plugin that is in the kwin script contains KWindowSystem.
Comment 6 Thomas Lübking 2013-04-06 17:58:54 UTC
iirc it grabs the keyboard focus (on X11 layer, Qt Popup hint) - you cannot activate another client at that time.

-> This needs to be scheduled to when the popup closes.

I've not tried the script function but assume this to be the issue.
Comment 7 Michail Vourlakos 2013-04-06 18:33:47 UTC
(In reply to comment #6)
> iirc it grabs the keyboard focus (on X11 layer, Qt Popup hint) - you cannot
> activate another client at that time.
> 
> -> This needs to be scheduled to when the popup closes.
by closing I hope you mean hiding....
I scheduled:
workspace.activeClient = client;

after the popup has been set visible=false and I have even added a Timer in order to trigger this 1sec after the popup has been hidden....

but no change, the code is doing nothing for me...
Comment 8 Thomas Lübking 2013-04-06 19:03:02 UTC
Just tried:

   workspace.activeClient = workspace.clientList()[2];

from the scripting console [1] - no problem here (git master, ensure to have > 2 windows open ;-).
Even a minimized window gets activated (and thus unminimized)

[1] qdbus org.kde.plasma-desktop /MainApplication showInteractiveKWinConsole
Comment 9 Michail Vourlakos 2013-04-06 22:43:20 UTC
(In reply to comment #8)
> Just tried:
> 
>    workspace.activeClient = workspace.clientList()[2];

Thomas I can confirm that from the interactive console it also works for me e.g:
var client = workspace.getClient("65011734");
workspace.activeClient = client;

So is this again an issue with PlasmaCore.Dialog(popup) in KWIn?
Is there any alternative to follow?
Comment 10 Thomas Lübking 2013-04-06 23:19:28 UTC
(In reply to comment #9)

> So is this again an issue with PlasmaCore.Dialog(popup) in KWIn?

Not sure. If the client is unmapped it should have no particular impact (unmapped clients cannot possess input focus and the keyboard is supposed to become auto-ungrabbed by the server when the assigned window is set upmapped)

Have you tried hooking onto workspace.clientActivated and printing the workspace.activeClient (just to see whether the client might get activated interim and the active window is then restored by the core for other reasons)
Comment 11 Andrew Crouthamel 2018-11-10 03:19:56 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 12 Andrew Crouthamel 2018-11-20 04:00:08 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? This bug will be moved back to REPORTED Status for manual review later, which may take a while. If you are able to, please lend us a hand.

Thank you for helping us make KDE software even better for everyone!
Comment 13 kde.org 2021-11-07 00:39:39 UTC
This issue report is quite old. Can you please confirm, that it still persists with Plasma 5.23?
Comment 14 Bug Janitor Service 2021-11-22 04:38:38 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 15 Bug Janitor Service 2021-12-07 04:36:19 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!