Bug 54375 - keyboard doesn't work when previewing files using Netscape plugins
Summary: keyboard doesn't work when previewing files using Netscape plugins
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: nsplugins (show other bugs)
Version: unspecified
Platform: Mandrake RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-10 01:53 UTC by Anonymous Coward
Modified: 2003-02-22 05:41 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anonymous Coward 2003-02-10 01:53:40 UTC
Version:           3.1.0 (using KDE 3.1.0)
Installed from:    Mandrake Linux Cooker athlon - Cooker
Compiler:          gcc version 3.2 (Mandrake Linux 9.0 3.2-1mdk)
OS:          Linux (i686) release 2.4.19-16mdkcustom

After upgrading from KDE 3.0.4 to KDE 3.1, keyboard stopped working when viewing files using Netscape plugins in Konqueror ("Preview in -> Netscape plugin viewer" in context menu). For example, pressing PageUp/PageDown does nothing in Acrobat Reader plugin. Same for DjVu viewer (djvu.sf.net) when it is even more deadly because you can't enter zoom level. The keyboard works fine in dialog boxes displayed by plugins.
Comment 1 Anonymous Coward 2003-02-11 00:26:20 UTC
Actually, the keyboard does work immediately after opening the preview.But as
soon as the embedded Netscape plugin window looses focus (because, e.g. I click
on toolbar's >> or << button in acroread), it can't be restored back by clicking
on the window.
Comment 2 Leon Bottou 2003-02-15 22:40:37 UTC
I think it used to work because the plugin viewer 
was based on the old javaembed.  The QXEmbed 
protocol (www.freedesktop.org) now says that 
the embedding apps should set the input focus 
to an invisible proxy window.  This is fine with 
QXEmbed aware apps.  But this kills apps 
that (1) are non aware of this, and (2) use 
they own embedding protocol to display 
the actual viewer.  That includes acroread,  
djvu, plugger, and may be more. 
 
I see no simple fix... 
- Leon Bottou 
 
 
Comment 3 Leon Bottou 2003-02-17 00:14:05 UTC
I just retrofitted the knspluginembed class from kde-3.0.5 
and got the usual keyboard behavior in the djvu plugin. 
Recipe: checkout knspluginembed,  
            change define in nspluginloader.h. 
 
This is a short term fix. 
 
The problem is that this is not a valid long term solution. 
 
The essential difference is that knspluginembed  
leaves the X11 focus on the toplevel window while  
qxembed sets it on an invisible proxy window. 
See www.freedesktop.org/standards/xembed.html. 
As a consequence the embedded nspluginviewer  
receives keystrokes when (and only when) the pointer  
is located in the plugin area. 
 
QXEmbed provides a more refined embedding by defining 
a number of protocols for managing the keyboard focus. 
In particular it defines a message XEMBED_REQUEST_FOCUS 
that QXEmbed aware embedded applications must use to request focus. 
 
The problem is that nspluginviewer is not a QXEmbed aware  
embedded application.  The windows it offers for embedding 
are not Qt widgets but Xt widgets.  This is so because 
the nsplugin protocol heavily relies on Xt event dispatching. 
 
Conclusion: as soon as a QXEmbed class exists on the embedder side, 
it redefines the X11 focus to enforce its own focus management. 
When you click on a lineedit widget, the lineedit request the focus 
and shows it by flashing the cursor.  Your keystrokes are then 
redirected to that widget until someone else requests the focus. 
The problem is that embedded applications that do not know 
the XEmbed protocol will never be able to request the focus 
in the first place. 
 
This happens regardless of whether the QXEmbed is used 
for embedding the non-qxembed application.  Even if we use 
KNSPluginEmbed for embedding nspluginviewer, keyboard 
events will stop as soon as a QXEmbed becomes active 
in the same toplevel window.  The most scary thing is that 
the QXEmbed way of doing things might be the default 
in some future version of Qt. 
 
Solutions might come from two directions: 
- Make Xt/Motif aware of the XEmbed protocol 
- Make QXEmbed do smart things when it notices 
  that its client does not know the XEmbed protocol. 
  For instance it might monitor mouse clicks 
  and request the focus on behalf of its unaware client. 
  A little bit like the point-to-click window managers. 
 
- Leon Bottou 
 
 
 
 
Comment 4 Anonymous Coward 2003-02-17 00:25:56 UTC
> Recipe: checkout knspluginembed,  
> change define in nspluginloader.h.  
 
Thanks! 
  
> As a consequence the embedded nspluginviewer  
> receives keystrokes when (and only when) the pointer  
> is located in the plugin area.  
  
Strange, it behaves a bit differently here: the embedded plugin *never* gets 
keystrokes, except for the time before first mouse click or focus change. When I 
open the viewer, keystrokes are sent to the plugin only after I change focus to another 
widget or even click with the mouse onto plugin area. After then, no keystrokes ever 
made it to the plugin, regardless of mouse pointer position. 
Comment 5 Leon Bottou 2003-02-17 03:21:55 UTC
This is the behavior *after* retrofitting knspluginembed from kde-3.0. 
What you describe is the behavior in kde-3.1 with qxembed. 
 
Also note that I just did experiments in my computer 
I did not change anything in the repository. 
 
 -L. 
Comment 6 Leon Bottou 2003-02-21 18:56:40 UTC
See http://lists.kde.org/?l=kde-devel&m=104584743531077&w=2  -Leon 
Comment 7 George Staikos 2003-02-22 05:41:16 UTC
Excellent work Leon