Review Request 126287: [text-ui] Use KWindowSystem to detect active window change for keyboard layout switching

Martin Gräßlin mgraesslin at kde.org
Fri Dec 11 09:19:58 UTC 2015



> On Dec. 11, 2015, 9:11 a.m., Martin Gräßlin wrote:
> > The problem is not the OSD, the problem is the global shortcut.
> > 
> > Take for example:
> > 
> > sleep 5 && qdbus org.kde.plasmashell /org/kde/osdService brightnessChanged 100
> > 
> > It doesn't expose the problem. But when pressing a global shortcut a keyboard grab is performed and for comparison please see: http://commits.kde.org/kwin/fab806df9297d901625edf03eccd8f4a77875ac9
> > 
> > Now I even more think that we need to properly fix this and not try to workaround in the applications (as it affects all
> 
> Martin Gräßlin wrote:
>     Checking X spec for GrabKeyboard: "This request generates FocusIn and FocusOut events". Which explains why there is a QEvent::WindowDeactivate and QEvent::WindowActivate events in the app.
>     
>     I'll try whether I can work around inside Qt by delaying the events.
> 
> Martin Gräßlin wrote:
>     > I'll try whether I can work around inside Qt by delaying the events.
>     
>     Ah Qt has wonderful code there. On a FocusOut event it only handles if there is no FocusIn in the current event queue. So actually it should work(TM).

proof of concept patch against Qt
    diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
    index a20d957..debe18f 100644
    --- a/src/plugins/platforms/xcb/qxcbconnection.cpp
    +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
    @@ -1631,6 +1631,8 @@ void QXcbConnection::processXcbEvents()
             }
             m_reader->unlock();
             handleXcbEvent(event);
    +        if (!m_peekFuncs.isEmpty() && i+1 == eventqueue->size())
    +            QThread::msleep(100);
             m_reader->lock();
         }
 
The idea is to give the xcb event reader thread enough time to get the event. Qt is too performant!


- Martin


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/126287/#review89331
-----------------------------------------------------------


On Dec. 9, 2015, 6:03 a.m., Martin Klapetek wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/126287/
> -----------------------------------------------------------
> 
> (Updated Dec. 9, 2015, 6:03 a.m.)
> 
> 
> Review request for Telepathy and Martin Gräßlin.
> 
> 
> Bugs: 356220
>     http://bugs.kde.org/show_bug.cgi?id=356220
> 
> 
> Repository: ktp-text-ui
> 
> 
> Description
> -------
> 
> So it turns out that with text-ui's "remember layout per tab" feature
> and Plasma's OSD, there's a problem when activating the global keyboard
> layout change shortcut. It triggers the OSD and in turn that causes
> QEvent::WindowDeactivate and QEvent::WindowActivate events in the app,
> leading to text-ui immediately setting the old keyboard layout, making
> it look like it's actualy blocking the changes.
> 
> While checking KWindowSystem::activeWindowChanged I noticed that the
> active window actually does not change. So I've moved setting the kbd
> layout to KWindowSystem::activeWindowChanged slot rather than in the
> event() handler. Seems to work perfectly.
> 
> I think this is the same bug that is causing the hidden panel to raise
> on OSD/notifications and the one that is showing the "plasma" task in
> task manager for split second, these two:
> 
> https://bugs.kde.org/show_bug.cgi?id=352278
> https://bugs.kde.org/show_bug.cgi?id=332024
> 
> 
> Diffs
> -----
> 
>   app/chat-window.h 0d1e0bb 
>   app/chat-window.cpp fdde18d 
> 
> Diff: https://git.reviewboard.kde.org/r/126287/diff/
> 
> 
> Testing
> -------
> 
> With "remember keyboard layout per tab" I can now successfully change
> keyboard layout from text-ui and the keyboard layout is properly restored
> when switching to the window.
> 
> 
> Thanks,
> 
> Martin Klapetek
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-telepathy/attachments/20151211/6a489ab1/attachment.html>


More information about the KDE-Telepathy mailing list