Bug 416319

Summary: forceActiveWindow() function raises window but may not give it focus.
Product: [Frameworks and Libraries] frameworks-kwindowsystem Reporter: Xu Zhao <i>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: nate
Priority: NOR    
Version First Reported In: 5.65.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: The screenshot showing the specified window is not getting focus

Description Xu Zhao 2020-01-16 02:41:59 UTC
Created attachment 125159 [details]
The screenshot showing the specified window is not getting focus

SUMMARY
I discover this bug when developing a simple KRunner extension that switches windows on Plasma. 

In this extension, I use forceActiveWindow(Wid w) call to raise and focus a window, see https://github.com/xuzhao9/krunner-switcher/blob/master/src/switcher.cpp#L135

This function call successfully returns, the window specified in argument always raises, but may not get focus (non-deterministic).

STEPS TO REPRODUCE
1. Install the krunner-switcher plugin of KRunner
2. Use KRunner to activate a window

OBSERVED RESULT
The specified window is activated and gets focus.

EXPECTED RESULT
The specified window is raised to the front, but may not get focus (the old window keeps focus). If you call activeWindow() at this moment, it returns the new window, i.e., the one specified in the argument of forceActiveWindow().

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:   openSUSE Tumbleweed 20200113
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.65.0
Qt Version: 5.13.1

ADDITIONAL INFORMATION
This bug is non-deterministic. You may need to try it multiple times to reproduce it.
Comment 1 Xu Zhao 2020-04-11 01:42:23 UTC
Superseded by bug 419937.

*** This bug has been marked as a duplicate of bug 419937 ***